Skip to content

Commit d5f6e04

Browse files
authored
Merge pull request apache#132 from proost/perf-reduce-serialization
perf: reduce unnecessary serialization in KLL sketch
2 parents 054d7ad + e59e03d commit d5f6e04

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

kll/items_sketch.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,6 @@ func (s *ItemsSketch[C]) currentSerializedSizeBytes() (int, error) {
593593
}
594594
totalBytes = _DATA_START_ADR_SINGLE_ITEM + v
595595
} else if tgtStructure == _COMPACT_FULL {
596-
597596
totalBytes = _DATA_START_ADR + s.getLevelsArrSizeBytes(tgtStructure) + s.getMinMaxSizeBytes() + s.getRetainedItemsSizeBytes()
598597
} else { //structure = UPDATABLE
599598
return 0, fmt.Errorf("updatable serialization not implemented")
@@ -670,7 +669,11 @@ func (s *ItemsSketch[C]) getRetainedItemsByteArr() []byte {
670669
}
671670

672671
func (s *ItemsSketch[C]) getRetainedItemsSizeBytes() int {
673-
return len(s.getRetainedItemsByteArr())
672+
retainedSize := 0
673+
for i := s.levels[0]; i < s.levels[s.numLevels]; i++ {
674+
retainedSize += s.serde.SizeOf(s.items[i])
675+
}
676+
return retainedSize
674677
}
675678

676679
func (s *ItemsSketch[C]) setupSortedView() error {

0 commit comments

Comments
 (0)