func (b *baseBlockset) Trim(from, to int) error { if from >= len(b.blocks) { return nil } if to > len(b.blocks) { to = len(b.blocks) } for i := from; i < to; i++ { b.blocks[i] = torus.ZeroBlock() } return nil }
func (b *baseBlockset) Truncate(lastIndex int, _ uint64) error { if lastIndex <= len(b.blocks) { b.blocks = b.blocks[:lastIndex] return nil } toadd := lastIndex - len(b.blocks) for toadd != 0 { b.blocks = append(b.blocks, torus.ZeroBlock()) toadd-- } return nil }
func (b *replicationBlockset) Trim(from, to int) error { err := b.sub.Trim(from, to) if err != nil { return err } if from >= len(b.repBlocks[0]) { return nil } if to > len(b.repBlocks[0]) { to = len(b.repBlocks[0]) } for i := from; i < to; i++ { for _, blist := range b.repBlocks { blist[i] = torus.ZeroBlock() } } return nil }
func (b *replicationBlockset) Truncate(lastIndex int, blocksize uint64) error { err := b.sub.Truncate(lastIndex, blocksize) if err != nil { return err } if lastIndex <= len(b.repBlocks[0]) { for i := range b.repBlocks { b.repBlocks[i] = b.repBlocks[i][:lastIndex] } return nil } for i := range b.repBlocks { toadd := lastIndex - len(b.repBlocks[0]) for toadd != 0 { b.repBlocks[i] = append(b.repBlocks[i], torus.ZeroBlock()) toadd-- } } return nil }