Skip to content

Commit

Permalink
Remove retrievable properties and methods
Browse files Browse the repository at this point in the history
  • Loading branch information
justinjc committed Oct 18, 2018
1 parent 449854f commit 8b26fe7
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 95 deletions.
61 changes: 0 additions & 61 deletions src/dbnode/storage/block/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,24 +96,6 @@ func NewDatabaseBlock(
return b
}

// NewRetrievableDatabaseBlock creates a new retrievable DatabaseBlock instance.
func NewRetrievableDatabaseBlock(
start time.Time,
blockSize time.Duration,
retriever DatabaseShardBlockRetriever,
metadata RetrievableBlockMetadata,
opts Options,
) DatabaseBlock {
b := &dbBlock{
opts: opts,
startUnixNanos: start.UnixNano(),
blockSize: blockSize,
closed: false,
}
b.resetRetrievableWithLock(retriever, metadata)
return b
}

func (b *dbBlock) StartTime() time.Time {
b.RLock()
start := b.startWithRLock()
Expand Down Expand Up @@ -185,26 +167,6 @@ func (b *dbBlock) Checksum() (uint32, error) {
return b.checksum, nil
}

func (b *dbBlock) OnRetrieveBlock(
id ident.ID,
_ ident.TagIterator,
startTime time.Time,
segment ts.Segment,
) {
b.Lock()
defer b.Unlock()

if b.closed ||
!id.Equal(b.retrieveID) ||
!startTime.Equal(b.startWithRLock()) {
return
}

b.resetSegmentWithLock(segment)
b.retrieveID = id
b.wasRetrievedFromDisk = true
}

func (b *dbBlock) Stream(blocker context.Context) (xio.BlockReader, error) {
lockUpgraded := false

Expand Down Expand Up @@ -296,18 +258,6 @@ func (b *dbBlock) Reset(start time.Time, blockSize time.Duration, segment ts.Seg
b.resetSegmentWithLock(segment)
}

func (b *dbBlock) ResetRetrievable(
start time.Time,
blockSize time.Duration,
retriever DatabaseShardBlockRetriever,
metadata RetrievableBlockMetadata,
) {
b.Lock()
defer b.Unlock()
b.resetNewBlockStartWithLock(start, blockSize)
b.resetRetrievableWithLock(retriever, metadata)
}

func (b *dbBlock) streamWithRLock(ctx context.Context) (xio.BlockReader, error) {
start := b.startWithRLock()

Expand Down Expand Up @@ -370,17 +320,6 @@ func (b *dbBlock) resetSegmentWithLock(seg ts.Segment) {
b.wasRetrievedFromDisk = false
}

func (b *dbBlock) resetRetrievableWithLock(
retriever DatabaseShardBlockRetriever,
metadata RetrievableBlockMetadata,
) {
b.segment = ts.Segment{}
b.length = metadata.Length
b.checksum = metadata.Checksum
b.retrieveID = metadata.ID
b.wasRetrievedFromDisk = false
}

func (b *dbBlock) Discard() ts.Segment {
seg, _ := b.closeAndDiscardConditionally(nil)
return seg
Expand Down
10 changes: 0 additions & 10 deletions src/dbnode/storage/block/block_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions src/dbnode/storage/block/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ type NewDatabaseBlockFn func() DatabaseBlock

// DatabaseBlock is the interface for a DatabaseBlock
type DatabaseBlock interface {
OnRetrieveBlock

// StartTime returns the start time of the block.
StartTime() time.Time

Expand Down Expand Up @@ -174,14 +172,6 @@ type DatabaseBlock interface {
// Reset resets the block start time, duration, and the segment.
Reset(startTime time.Time, blockSize time.Duration, segment ts.Segment)

// ResetRetrievable resets the block to become retrievable.
ResetRetrievable(
startTime time.Time,
blockSize time.Duration,
retriever DatabaseShardBlockRetriever,
metadata RetrievableBlockMetadata,
)

// Discard closes the block, but returns the (unfinalized) segment.
Discard() ts.Segment

Expand Down
15 changes: 1 addition & 14 deletions src/dbnode/storage/series/series.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,21 +520,8 @@ func (s *dbSeries) OnRetrieveBlock(
}

b = s.opts.DatabaseBlockOptions().DatabaseBlockPool().Get()
metadata := block.RetrievableBlockMetadata{
ID: s.id,
Length: segment.Len(),
Checksum: digest.SegmentChecksum(segment),
}
blockSize := s.opts.RetentionOptions().BlockSize()
b.ResetRetrievable(startTime, blockSize, s.blockRetriever, metadata)
// Use s.id instead of id here, because id is finalized by the context whereas
// we rely on the G.C to reclaim s.id. This is important because the block will
// hold onto the id ref, and (if the LRU caching policy is enabled) the shard
// will need it later when the WiredList calls its OnEvictedFromWiredList method.
// Also note that ResetRetrievable will mark the block as not retrieved from disk,
// but OnRetrieveBlock will then properly mark it as retrieved from disk so subsequent
// calls to WasRetrievedFromDisk will return true.
b.OnRetrieveBlock(s.id, tags, startTime, segment)
b.Reset(startTime, blockSize, segment)

// NB(r): Blocks retrieved have been triggered by a read, so set the last
// read time as now so caching policies are followed.
Expand Down

0 comments on commit 8b26fe7

Please sign in to comment.