Fix merge of code files (#495)

Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
This commit is contained in:
ledgerwatch 2022-06-17 19:24:56 +01:00 committed by GitHub
parent d7693ce094
commit 945b0e9e0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 26 deletions

View File

@ -378,12 +378,11 @@ const (
// CursorItem is the item in the priority queue used to do merge interation
// over storage of a given account
type CursorItem struct {
t CursorType // Whether this item represents state file or DB record, or tree
endTxNum uint64
key, val []byte
dg *compress.Getter
c kv.CursorDupSort
valCompressed bool
t CursorType // Whether this item represents state file or DB record, or tree
endTxNum uint64
key, val []byte
dg *compress.Getter
c kv.CursorDupSort
}
type CursorHeap []*CursorItem

View File

@ -289,27 +289,19 @@ func (d *Domain) mergeFiles(files [][NumberOfTypes]*filesItem, r DomainRanges, m
g.Reset(0)
if g.HasNext() {
key, _ := g.NextUncompressed()
if d.compressVals && fType != EfHistory && item.endTxNum-item.startTxNum > d.aggregationStep {
val, _ := g.Next(nil)
heap.Push(&cp, &CursorItem{
t: FILE_CURSOR,
dg: g,
key: key,
val: val,
endTxNum: item.endTxNum,
valCompressed: true,
})
var val []byte
if d.compressVals {
val, _ = g.Next(nil)
} else {
val, _ := g.NextUncompressed()
heap.Push(&cp, &CursorItem{
t: FILE_CURSOR,
dg: g,
key: key,
val: val,
endTxNum: item.endTxNum,
valCompressed: false,
})
val, _ = g.NextUncompressed()
}
heap.Push(&cp, &CursorItem{
t: FILE_CURSOR,
dg: g,
key: key,
val: val,
endTxNum: item.endTxNum,
})
}
}
count := 0
@ -335,7 +327,7 @@ func (d *Domain) mergeFiles(files [][NumberOfTypes]*filesItem, r DomainRanges, m
}
if ci1.dg.HasNext() {
ci1.key, _ = ci1.dg.NextUncompressed()
if ci1.valCompressed {
if d.compressVals {
ci1.val, _ = ci1.dg.Next(ci1.val[:0])
} else {
ci1.val, _ = ci1.dg.NextUncompressed()