mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/storage: avoid superflouos copy of block header data
This commit is contained in:
parent
34aa25d681
commit
463bc27312
1 changed files with 2 additions and 3 deletions
|
@ -223,15 +223,14 @@ func (bsr *blockStreamReader) readBlock() error {
|
||||||
return fmt.Errorf("too short index data for reading block header at offset %d; got %d bytes; want %d bytes",
|
return fmt.Errorf("too short index data for reading block header at offset %d; got %d bytes; want %d bytes",
|
||||||
bsr.prevIndexBlockOffset(), len(bsr.indexCursor), marshaledBlockHeaderSize)
|
bsr.prevIndexBlockOffset(), len(bsr.indexCursor), marshaledBlockHeaderSize)
|
||||||
}
|
}
|
||||||
bsr.Block.headerData = append(bsr.Block.headerData[:0], bsr.indexCursor[:marshaledBlockHeaderSize]...)
|
tail, err := bsr.Block.bh.Unmarshal(bsr.indexCursor[:marshaledBlockHeaderSize])
|
||||||
bsr.indexCursor = bsr.indexCursor[marshaledBlockHeaderSize:]
|
|
||||||
tail, err := bsr.Block.bh.Unmarshal(bsr.Block.headerData)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("cannot parse block header read from index data at offset %d: %w", bsr.prevIndexBlockOffset(), err)
|
return fmt.Errorf("cannot parse block header read from index data at offset %d: %w", bsr.prevIndexBlockOffset(), err)
|
||||||
}
|
}
|
||||||
if len(tail) > 0 {
|
if len(tail) > 0 {
|
||||||
return fmt.Errorf("non-empty tail left after parsing block header at offset %d: %x", bsr.prevIndexBlockOffset(), tail)
|
return fmt.Errorf("non-empty tail left after parsing block header at offset %d: %x", bsr.prevIndexBlockOffset(), tail)
|
||||||
}
|
}
|
||||||
|
bsr.indexCursor = bsr.indexCursor[marshaledBlockHeaderSize:]
|
||||||
|
|
||||||
bsr.blocksCount++
|
bsr.blocksCount++
|
||||||
if bsr.blocksCount > bsr.ph.BlocksCount {
|
if bsr.blocksCount > bsr.ph.BlocksCount {
|
||||||
|
|
Loading…
Reference in a new issue