rdblue commented on code in PR #3117:
URL: https://github.com/apache/parquet-java/pull/3117#discussion_r1927826823


##########
parquet-variant/src/main/java/org/apache/parquet/variant/Variant.java:
##########
@@ -0,0 +1,435 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.parquet.variant;
+
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonGenerator;
+
+import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.time.ZoneOffset;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeFormatterBuilder;
+import java.time.temporal.ChronoUnit;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Locale;
+
+import static java.time.temporal.ChronoField.*;
+import static java.time.temporal.ChronoField.SECOND_OF_MINUTE;
+import static org.apache.parquet.variant.VariantUtil.*;
+
+/**
+ * This Variant class holds the Variant-encoded value and metadata binary 
values.
+ */
+public final class Variant {
+  final byte[] value;
+  final byte[] metadata;
+  /**
+   * The starting index into `value` where the variant value starts. This is 
used to avoid copying
+   * the value binary when reading a sub-variant in the array/object element.
+   */
+  final int pos;
+
+  public Variant(byte[] value, byte[] metadata) {
+    this(value, metadata, 0);
+  }
+
+  Variant(byte[] value, byte[] metadata, int pos) {
+    this.value = value;
+    this.metadata = metadata;
+    this.pos = pos;
+    // There is currently only one allowed version.
+    if (metadata.length < 1 || (metadata[0] & VERSION_MASK) != VERSION) {
+      throw malformedVariant();

Review Comment:
   I agree. It would be nice to have an error message like `"Unsupported 
variant metadata version: %s"`.



-- 
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: issues-unsubscr...@parquet.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@parquet.apache.org
For additional commands, e-mail: issues-h...@parquet.apache.org

Reply via email to