Skip to content

Commit a3b9539

Browse files
committed
Added some explanation to the deltaCapacity function
1 parent 4f8b1fb commit a3b9539

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

exporter/exporterhelper/logs_batch.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,16 @@ func extractScopeLogsBasedOnByteSize(srcSL plog.ScopeLogs, capacity int) (plog.S
204204
}
205205

206206
// deltaCapacity() returns the delta size of a proto slice when a new item is added.
207+
// Example:
208+
//
209+
// prevSize := proto1.Size()
210+
// proto1.RepeatedField().AppendEmpty() = proto2
211+
//
212+
// Then currSize of proto1 can be calculated as
213+
//
214+
// currSize := (prevSize + deltaCapacity(proto2.Size()))
215+
//
216+
// This is derived from gogo/protobuf 's Size() function
207217
func deltaCapacity(newItemSize int) int {
208218
return 1 + newItemSize + int(math_bits.Len64(uint64(newItemSize|1)+6)/7)
209219
}

0 commit comments

Comments
 (0)