kfaraz commented on a change in pull request #12073:
URL: https://github.com/apache/druid/pull/12073#discussion_r782359195
##########
File path:
extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/theta/SketchAggregator.java
##########
@@ -133,4 +174,34 @@ static void updateUnion(Union union, Object update)
throw new ISE("Illegal type received while theta sketch merging [%s]",
update.getClass());
}
}
+
+ /**
+ * Gets the initial size of this aggregator in bytes.
+ */
+ public long getInitialSizeBytes()
+ {
+ // SketchAggregator has 3 references and an int
+ // UnionImpl has a reference, a short, a long, a boolean
+ long sizeOfReferences = 3L * Long.BYTES + Integer.BYTES
+ + Long.BYTES + Short.BYTES + Long.BYTES + 1;
+ if (sketchField == null) {
+ return sizeOfReferences;
+ }
+
+ // Initialize the sketch if not already initialized
+ if (union == null) {
+ initUnion();
Review comment:
Re-structured the code to initialize lazily and account for the size
only when initializing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]