Skip to content

Commit a1ee6dc

Browse files
committed
save
1 parent 467a24f commit a1ee6dc

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

db/state/deduplicate.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ func (iit *InvertedIndexRoTx) deduplicateFiles(ctx context.Context, files []*Fil
257257
for _, item := range files {
258258
cnt += item.decompressor.Count()
259259
}
260-
p := ps.AddNew(path.Base(datPath), uint64(cnt))
260+
p := ps.AddNew(path.Base(datPath), uint64(cnt/2))
261261
defer ps.Delete(p)
262262

263263
var cp CursorHeap
@@ -340,15 +340,17 @@ func (iit *InvertedIndexRoTx) deduplicateFiles(ctx context.Context, files []*Fil
340340
mergedOnce = true
341341
}
342342
// fmt.Printf("multi-way %s [%d] %x\n", ii.KeysTable, ci1.endTxNum, ci1.key)
343-
i++
344343
if ci1.kvReader.HasNext() {
345344
ci1.key, _ = ci1.kvReader.Next(ci1.key[:0])
346345
ci1.val, _ = ci1.kvReader.Next(ci1.val[:0])
346+
i += 2
347347
// fmt.Printf("heap next push %s [%d] %x\n", ii.KeysTable, ci1.endTxNum, ci1.key)
348348
heap.Push(&cp, ci1)
349349
}
350350
}
351-
p.Processed.Store(i)
351+
if i%1024 == 0 {
352+
p.Processed.Store(i)
353+
}
352354
if keyBuf != nil {
353355
// fmt.Printf("pput %x->%x\n", keyBuf, valBuf)
354356
if _, err = write.Write(keyBuf); err != nil {

db/state/merge.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -683,15 +683,17 @@ func (iit *InvertedIndexRoTx) mergeFiles(ctx context.Context, files []*FilesItem
683683
mergedOnce = true
684684
}
685685
// fmt.Printf("multi-way %s [%d] %x\n", ii.KeysTable, ci1.endTxNum, ci1.key)
686-
i++
687686
if ci1.kvReader.HasNext() {
688687
ci1.key, _ = ci1.kvReader.Next(ci1.key[:0])
689688
ci1.val, _ = ci1.kvReader.Next(ci1.val[:0])
689+
i += 2
690690
// fmt.Printf("heap next push %s [%d] %x\n", ii.KeysTable, ci1.endTxNum, ci1.key)
691691
heap.Push(&cp, ci1)
692692
}
693693
}
694-
p.Processed.Store(i)
694+
if i%1024 == 0 {
695+
p.Processed.Add(1)
696+
}
695697
if keyBuf != nil {
696698
// fmt.Printf("pput %x->%x\n", keyBuf, valBuf)
697699
if _, err = write.Write(keyBuf); err != nil {
@@ -798,7 +800,7 @@ func (ht *HistoryRoTx) mergeFiles(ctx context.Context, indexFiles, historyFiles
798800
for _, item := range indexFiles {
799801
cnt += item.decompressor.Count()
800802
}
801-
p := ps.AddNew(path.Base(datPath), uint64(cnt))
803+
p := ps.AddNew(path.Base(datPath), uint64(cnt/2))
802804
defer ps.Delete(p)
803805

804806
var cp CursorHeap
@@ -845,7 +847,6 @@ func (ht *HistoryRoTx) mergeFiles(ctx context.Context, indexFiles, historyFiles
845847
var lastKey, valBuf, histKeyBuf []byte
846848
seq := &multiencseq.SequenceReader{}
847849
ss := &multiencseq.SequenceIterator{}
848-
i := uint64(0)
849850
for cp.Len() > 0 {
850851
lastKey = append(lastKey[:0], cp[0].key...)
851852
// Advance all the items that have this key (including the top)
@@ -876,14 +877,13 @@ func (ht *HistoryRoTx) mergeFiles(ctx context.Context, indexFiles, historyFiles
876877
}
877878

878879
// fmt.Printf("fput '%x'->%x\n", lastKey, ci1.val)
879-
i++
880+
p.Processed.Add(1)
880881
if ci1.kvReader.HasNext() {
881882
ci1.key, _ = ci1.kvReader.Next(ci1.key[:0])
882883
ci1.val, _ = ci1.kvReader.Next(ci1.val[:0])
883884
heap.Push(&cp, ci1)
884885
}
885886
}
886-
p.Processed.Store(i)
887887
}
888888
if err := pagedWr.Compress(); err != nil {
889889
return nil, nil, err

0 commit comments

Comments
 (0)