Skip to content

Commit 32e86d0

Browse files
committed
perf: reduce serialization
1 parent 054d7ad commit 32e86d0

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

kll/items_sketch.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,11 @@ func (s *ItemsSketch[C]) currentSerializedSizeBytes() (int, error) {
593593
}
594594
totalBytes = _DATA_START_ADR_SINGLE_ITEM + v
595595
} else if tgtStructure == _COMPACT_FULL {
596-
597-
totalBytes = _DATA_START_ADR + s.getLevelsArrSizeBytes(tgtStructure) + s.getMinMaxSizeBytes() + s.getRetainedItemsSizeBytes()
596+
retainedSize := 0
597+
for i := s.levels[0]; i < s.levels[s.numLevels]; i++ {
598+
retainedSize += s.serde.SizeOf(s.items[i])
599+
}
600+
totalBytes = _DATA_START_ADR + s.getLevelsArrSizeBytes(tgtStructure) + s.getMinMaxSizeBytes() + retainedSize
598601
} else { //structure = UPDATABLE
599602
return 0, fmt.Errorf("updatable serialization not implemented")
600603
}
@@ -669,10 +672,6 @@ func (s *ItemsSketch[C]) getRetainedItemsByteArr() []byte {
669672
return s.serde.SerializeManyToSlice(retArr)
670673
}
671674

672-
func (s *ItemsSketch[C]) getRetainedItemsSizeBytes() int {
673-
return len(s.getRetainedItemsByteArr())
674-
}
675-
676675
func (s *ItemsSketch[C]) setupSortedView() error {
677676
if s.sortedView == nil {
678677
sView, err := newItemsSketchSortedView[C](s)

0 commit comments

Comments
 (0)