rdblue commented on code in PR #3221:
URL: https://github.com/apache/parquet-java/pull/3221#discussion_r2130618861
##########
parquet-variant/src/main/java/org/apache/parquet/variant/VariantUtil.java:
##########
@@ -848,4 +848,73 @@ static HashMap<String, Integer> getMetadataMap(ByteBuffer
metadata) {
}
return result;
}
+
+ /**
+ * Computes the actual size (in bytes) of the Variant value at
`value[pos...]`
+ * @param value The Variant value
+ * @return The size (in bytes) of the Variant value
+ */
+ public static int valueSize(ByteBuffer value) {
+ int pos = value.position();
+ checkIndex(pos, value.limit());
+ int basicType = value.get(pos) & BASIC_TYPE_MASK;
+ int typeInfo = (value.get(pos) >> BASIC_TYPE_BITS) & PRIMITIVE_TYPE_MASK;
+ switch (basicType) {
+ case SHORT_STR:
+ return 1 + typeInfo;
Review Comment:
This made me go check the spec. It may be easier to maintain/read if you
just duplicated the logic.
--
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]