mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/{storage,mergeset}: cleanup: remove unused partSearch.indexBlockReuse
This commit is contained in:
parent
4bc3d284fa
commit
f442d81648
4 changed files with 15 additions and 57 deletions
|
@ -256,9 +256,7 @@ func (idxbc *indexBlockCache) Get(k uint64) *indexBlock {
|
|||
}
|
||||
|
||||
// Put puts idxb under the key k into idxbc.
|
||||
//
|
||||
// Returns true if the idxb has been put into idxbc.
|
||||
func (idxbc *indexBlockCache) Put(k uint64, idxb *indexBlock) bool {
|
||||
func (idxbc *indexBlockCache) Put(k uint64, idxb *indexBlock) {
|
||||
idxbc.mu.Lock()
|
||||
|
||||
// Remove superflouos entries.
|
||||
|
@ -283,7 +281,6 @@ func (idxbc *indexBlockCache) Put(k uint64, idxb *indexBlock) bool {
|
|||
}
|
||||
idxbc.m[k] = idxbe
|
||||
idxbc.mu.Unlock()
|
||||
return true
|
||||
}
|
||||
|
||||
func (idxbc *indexBlockCache) Len() uint64 {
|
||||
|
@ -407,9 +404,7 @@ func (ibc *inmemoryBlockCache) Get(k inmemoryBlockCacheKey) *inmemoryBlock {
|
|||
}
|
||||
|
||||
// Put puts ib under key k into ibc.
|
||||
//
|
||||
// Returns true if ib was put into ibc.
|
||||
func (ibc *inmemoryBlockCache) Put(k inmemoryBlockCacheKey, ib *inmemoryBlock) bool {
|
||||
func (ibc *inmemoryBlockCache) Put(k inmemoryBlockCacheKey, ib *inmemoryBlock) {
|
||||
ibc.mu.Lock()
|
||||
|
||||
// Clean superflouos entries in cache.
|
||||
|
@ -434,7 +429,6 @@ func (ibc *inmemoryBlockCache) Put(k inmemoryBlockCacheKey, ib *inmemoryBlock) b
|
|||
}
|
||||
ibc.m[k] = ibe
|
||||
ibc.mu.Unlock()
|
||||
return true
|
||||
}
|
||||
|
||||
func (ibc *inmemoryBlockCache) Len() uint64 {
|
||||
|
|
|
@ -25,9 +25,6 @@ type partSearch struct {
|
|||
// The remaining block headers to scan in the current metaindexRow.
|
||||
bhs []blockHeader
|
||||
|
||||
// Pointer to index block, which may be reused.
|
||||
indexBlockReuse *indexBlock
|
||||
|
||||
// Pointer to inmemory block, which may be reused.
|
||||
inmemoryBlockReuse *inmemoryBlock
|
||||
|
||||
|
@ -53,10 +50,6 @@ func (ps *partSearch) reset() {
|
|||
ps.p = nil
|
||||
ps.mrs = nil
|
||||
ps.bhs = nil
|
||||
if ps.indexBlockReuse != nil {
|
||||
putIndexBlock(ps.indexBlockReuse)
|
||||
ps.indexBlockReuse = nil
|
||||
}
|
||||
if ps.inmemoryBlockReuse != nil {
|
||||
putInmemoryBlock(ps.inmemoryBlockReuse)
|
||||
ps.inmemoryBlockReuse = nil
|
||||
|
@ -275,40 +268,25 @@ func (ps *partSearch) nextBlock() error {
|
|||
}
|
||||
|
||||
func (ps *partSearch) nextBHS() error {
|
||||
if ps.indexBlockReuse != nil {
|
||||
putIndexBlock(ps.indexBlockReuse)
|
||||
ps.indexBlockReuse = nil
|
||||
}
|
||||
if len(ps.mrs) == 0 {
|
||||
return io.EOF
|
||||
}
|
||||
mr := &ps.mrs[0]
|
||||
ps.mrs = ps.mrs[1:]
|
||||
idxb, mayReuseIndexBlock, err := ps.getIndexBlock(mr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot get index block: %s", err)
|
||||
}
|
||||
if mayReuseIndexBlock {
|
||||
ps.indexBlockReuse = idxb
|
||||
idxbKey := mr.indexBlockOffset
|
||||
idxb := ps.idxbCache.Get(idxbKey)
|
||||
if idxb == nil {
|
||||
var err error
|
||||
idxb, err = ps.readIndexBlock(mr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot read index block: %s", err)
|
||||
}
|
||||
ps.idxbCache.Put(idxbKey, idxb)
|
||||
}
|
||||
ps.bhs = idxb.bhs
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ps *partSearch) getIndexBlock(mr *metaindexRow) (*indexBlock, bool, error) {
|
||||
idxbKey := mr.indexBlockOffset
|
||||
idxb := ps.idxbCache.Get(idxbKey)
|
||||
if idxb != nil {
|
||||
return idxb, false, nil
|
||||
}
|
||||
idxb, err := ps.readIndexBlock(mr)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
ok := ps.idxbCache.Put(idxbKey, idxb)
|
||||
return idxb, !ok, nil
|
||||
}
|
||||
|
||||
func (ps *partSearch) readIndexBlock(mr *metaindexRow) (*indexBlock, error) {
|
||||
ps.compressedIndexBuf = bytesutil.Resize(ps.compressedIndexBuf, int(mr.indexBlockSize))
|
||||
ps.p.indexFile.MustReadAt(ps.compressedIndexBuf, int64(mr.indexBlockOffset))
|
||||
|
@ -347,8 +325,8 @@ func (ps *partSearch) getInmemoryBlock(bh *blockHeader) (*inmemoryBlock, bool, e
|
|||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
ok := ps.ibCache.Put(ibKey, ib)
|
||||
return ib, !ok, nil
|
||||
ps.ibCache.Put(ibKey, ib)
|
||||
return ib, false, nil
|
||||
}
|
||||
|
||||
func (ps *partSearch) readInmemoryBlock(bh *blockHeader) (*inmemoryBlock, error) {
|
||||
|
|
|
@ -257,7 +257,7 @@ func (ibc *indexBlockCache) Get(k uint64) *indexBlock {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (ibc *indexBlockCache) Put(k uint64, ib *indexBlock) bool {
|
||||
func (ibc *indexBlockCache) Put(k uint64, ib *indexBlock) {
|
||||
ibc.mu.Lock()
|
||||
|
||||
// Clean superflouos cache entries.
|
||||
|
@ -281,7 +281,6 @@ func (ibc *indexBlockCache) Put(k uint64, ib *indexBlock) bool {
|
|||
}
|
||||
ibc.m[k] = ibe
|
||||
ibc.mu.Unlock()
|
||||
return true
|
||||
}
|
||||
|
||||
func (ibc *indexBlockCache) Requests() uint64 {
|
||||
|
|
|
@ -36,9 +36,6 @@ type partSearch struct {
|
|||
|
||||
bhs []blockHeader
|
||||
|
||||
// Pointer to index block, which may be reused
|
||||
indexBlockReuse *indexBlock
|
||||
|
||||
compressedIndexBuf []byte
|
||||
indexBuf []byte
|
||||
|
||||
|
@ -53,10 +50,6 @@ func (ps *partSearch) reset() {
|
|||
ps.metaindex = nil
|
||||
ps.ibCache = nil
|
||||
ps.bhs = nil
|
||||
if ps.indexBlockReuse != nil {
|
||||
putIndexBlock(ps.indexBlockReuse)
|
||||
ps.indexBlockReuse = nil
|
||||
}
|
||||
ps.compressedIndexBuf = ps.compressedIndexBuf[:0]
|
||||
ps.indexBuf = ps.indexBuf[:0]
|
||||
ps.err = nil
|
||||
|
@ -161,10 +154,6 @@ func (ps *partSearch) nextBHS() bool {
|
|||
|
||||
// Found the index block which may contain the required data
|
||||
// for the ps.BlockRef.bh.TSID and the given timestamp range.
|
||||
if ps.indexBlockReuse != nil {
|
||||
putIndexBlock(ps.indexBlockReuse)
|
||||
ps.indexBlockReuse = nil
|
||||
}
|
||||
indexBlockKey := mr.IndexBlockOffset
|
||||
ib := ps.ibCache.Get(indexBlockKey)
|
||||
if ib == nil {
|
||||
|
@ -176,9 +165,7 @@ func (ps *partSearch) nextBHS() bool {
|
|||
&ps.p.ph, mr.IndexBlockOffset, mr.IndexBlockSize, err)
|
||||
return false
|
||||
}
|
||||
if ok := ps.ibCache.Put(indexBlockKey, ib); !ok {
|
||||
ps.indexBlockReuse = ib
|
||||
}
|
||||
ps.ibCache.Put(indexBlockKey, ib)
|
||||
}
|
||||
ps.bhs = ib.bhs
|
||||
return true
|
||||
|
|
Loading…
Reference in a new issue