You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@parquet.apache.org by GitBox <gi...@apache.org> on 2020/07/31 16:49:17 UTC

[GitHub] [parquet-mr] shangxinli commented on a change in pull request #808: Parquet-1396: Cryptodata Interface for Schema Activation of Parquet E…

shangxinli commented on a change in pull request #808:
URL: https://github.com/apache/parquet-mr/pull/808#discussion_r463719447



##########
File path: parquet-column/src/main/java/org/apache/parquet/schema/ExtType.java
##########
@@ -0,0 +1,148 @@
+/*
+ * 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.schema;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * This class decorates the class 'Type' by adding a Map field 'metadata'.
+ *
+ * This decoration is needed to add metadata to each column without changing existing class 'MessageType', which is used
+ * extensively. Here is the example usage to add column metadata to schema with type of 'MessageType'.
+ *
+ * MessageType oldSchema = ...
+ * Map metadata = ...
+ * List newFields = new ArrayList();
+ * for (Type field = oldSchema.getFields()) {
+ *     Type newField = new ExtType(field);
+ *     newField.setMetadata(metadata);
+ *     newFields.add(newField);
+ * }
+ * MessageType newSchema = new MessageType(oldSchema.getName(), newFields);
+ *
+ * The implementation is mostly following decoration pattern. Most of the methods are just thin wrappers of existing
+ * implementation of PrimitiveType or GroupType.
+ */
+public class ExtType<T> extends Type {
+  private Type type;
+  private Map<String, T> metadata;
+
+  public ExtType(Type type) {
+    super(type.getName(), type.getRepetition(), type.getOriginalType(), type.getId());
+    this.type = type;
+  }
+
+  public ExtType(Type type, String name) {
+    super(name, type.getRepetition(), OriginalType.UINT_64, type.getId());
+    this.type = new PrimitiveType(type.getRepetition(), type.asPrimitiveType().getPrimitiveTypeName(), name);
+  }
+
+  public Type withId(int id) {

Review comment:
       Sounds good




----------------------------------------------------------------
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.

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