nssalian commented on code in PR #16568:
URL: https://github.com/apache/iceberg/pull/16568#discussion_r3531115028
##########
api/src/main/java/org/apache/iceberg/variants/VariantUtil.java:
##########
@@ -30,8 +32,38 @@ class VariantUtil {
private static final int BASIC_TYPE_OBJECT = 2;
private static final int BASIC_TYPE_ARRAY = 3;
+ /**
+ * Maximum permitted nesting depth of a Variant value. The top-level value
is depth 0, so a
+ * Variant may contain up to {@code MAX_VARIANT_DEPTH} nested levels.
+ */
+ static final int MAX_VARIANT_DEPTH = 500;
+
private VariantUtil() {}
+ /** Parses a variant value from {@code value} using {@code metadata} for
field-name resolution. */
+ static VariantValue fromBuffer(VariantMetadata metadata, ByteBuffer value,
int depth) {
+ Preconditions.checkArgument(
+ depth <= MAX_VARIANT_DEPTH,
+ "Invalid variant: nesting depth %s exceeds maximum %s",
Review Comment:
Fixed the doc to match: "top-level value is depth 0, so a Variant may
contain up to MAX_VARIANT_DEPTH + 1 nested levels."
--
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]