Skip to content

Commit e59e03d

Browse files
committed
refactor: abstract
1 parent 32e86d0 commit e59e03d

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

kll/items_sketch.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -593,11 +593,7 @@ func (s *ItemsSketch[C]) currentSerializedSizeBytes() (int, error) {
593593
}
594594
totalBytes = _DATA_START_ADR_SINGLE_ITEM + v
595595
} else if tgtStructure == _COMPACT_FULL {
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
596+
totalBytes = _DATA_START_ADR + s.getLevelsArrSizeBytes(tgtStructure) + s.getMinMaxSizeBytes() + s.getRetainedItemsSizeBytes()
601597
} else { //structure = UPDATABLE
602598
return 0, fmt.Errorf("updatable serialization not implemented")
603599
}
@@ -672,6 +668,14 @@ func (s *ItemsSketch[C]) getRetainedItemsByteArr() []byte {
672668
return s.serde.SerializeManyToSlice(retArr)
673669
}
674670

671+
func (s *ItemsSketch[C]) getRetainedItemsSizeBytes() int {
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
677+
}
678+
675679
func (s *ItemsSketch[C]) setupSortedView() error {
676680
if s.sortedView == nil {
677681
sView, err := newItemsSketchSortedView[C](s)

0 commit comments

Comments
 (0)