gene-db commented on code in PR #48172:
URL: https://github.com/apache/spark/pull/48172#discussion_r1796151027
##########
common/variant/src/main/java/org/apache/spark/types/variant/VariantBuilder.java:
##########
@@ -53,17 +53,21 @@ public VariantBuilder(boolean allowDuplicateKeys) {
public static Variant parseJson(String json, boolean allowDuplicateKeys)
throws IOException {
try (JsonParser parser = new JsonFactory().createParser(json)) {
parser.nextToken();
- return parseJson(parser, allowDuplicateKeys);
+ return parseJson(parser, allowDuplicateKeys, new VariantMetrics());
}
}
/**
* Similar {@link #parseJson(String, boolean)}, but takes a JSON parser
instead of string input.
+ * The variantMetrics object is used to collect statistics about the variant
being built.
*/
- public static Variant parseJson(JsonParser parser, boolean
allowDuplicateKeys)
- throws IOException {
+ public static Variant parseJson(JsonParser parser, boolean
allowDuplicateKeys,
+ VariantMetrics variantMetrics) throws
IOException {
VariantBuilder builder = new VariantBuilder(allowDuplicateKeys);
- builder.buildJson(parser);
+ builder.buildJson(parser, variantMetrics, 0);
+ variantMetrics.variantCount += 1;
+ Variant v = builder.result();
+ variantMetrics.byteSize += v.value.length + v.metadata.length;
return builder.result();
Review Comment:
Can we just return `v` here? We already did `Variant v = builder.result()`
above.
--
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]