You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2019/07/03 16:41:34 UTC

[GitHub] [incubator-iceberg] rdblue commented on a change in pull request #227: ORC column map fix

rdblue commented on a change in pull request #227: ORC column map fix
URL: https://github.com/apache/incubator-iceberg/pull/227#discussion_r300056977
 
 

 ##########
 File path: orc/src/main/java/org/apache/iceberg/orc/ORCSchemaUtil.java
 ##########
 @@ -0,0 +1,89 @@
+/*
+ * 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.iceberg.orc;
+
+import com.google.common.base.Splitter;
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+import java.util.IdentityHashMap;
+import java.util.Map;
+import java.util.stream.Collectors;
+import org.apache.orc.TypeDescription;
+
+/**
+ * Utilities for mapping Iceberg to ORC schemas.
+ */
+final class ORCSchemaUtil {
+
+  private ORCSchemaUtil() {}
+
+  static Map<TypeDescription, IcebergColumn> newColumMap() {
+    return new IdentityHashMap<>();
+  }
+
+  static <K, V> Map<K, V> inverse(Map<V, K> mapToFlip) {
+    return mapToFlip.entrySet()
+        .stream()
+        .collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey));
+  }
+
+  /**
+   * Serializes the column mapping into a comma separated list of values in the form:
+   * <code>
+   *   orc_id:iceberg_id:(required|optional),orc_id:iceberg_id:(required|optional),...
+   * </code>
+   * For example:
+   * <code>
+   *   0:2:required,1:3:optional
+   * </code>
+   * The above example defines two column mappings:
+   * - ORC column 0 maps to Iceberg column 2 and it's required.
+   * - ORC column 1 maps to Iceberg column 3 and it's optiona.
+   * @param idMap the Map with the column mapping of ORC type to Iceberg column.
 
 Review comment:
   Nit: typo in "optiona", and there should be an empty line between docs and `@param`.

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org