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 2021/12/16 12:32:03 UTC

[GitHub] [iceberg] findepi commented on a change in pull request #3210: Core: add Jackson serialization util for Trino and Presto

findepi commented on a change in pull request #3210:
URL: https://github.com/apache/iceberg/pull/3210#discussion_r770497463



##########
File path: core/src/main/java/org/apache/iceberg/JacksonSerializationUtil.java
##########
@@ -0,0 +1,156 @@
+/*
+ * 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;
+
+import java.math.BigDecimal;
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import org.apache.iceberg.expressions.ResidualEvaluator;
+
+/**
+ * Util methods to help Jackson serialization of Iceberg objects, useful in systems like Presto and Trino.
+ */
+public class JacksonSerializationUtil {
+
+  private JacksonSerializationUtil() {
+  }
+
+  public static FileScanTask createFileScanTask(DataFile file, DeleteFile[] deletes, String schemaString,
+                                                String specString, ResidualEvaluator residuals) {
+    return new BaseFileScanTask(file, deletes, schemaString, specString, residuals);
+  }
+
+  public static DataFile createDataFile(int specId, FileContent content, String filePath, FileFormat format,
+                                        PartitionData partitionData, long fileSizeInBytes, long recordCount,
+                                        Map<Integer, Long> columnSizes, Map<Integer, Long> valueCounts,
+                                        Map<Integer, Long> nullValueCounts, Map<Integer, Long> nanValueCounts,
+                                        Map<Integer, ByteBuffer> lowerBounds, Map<Integer, ByteBuffer> upperBounds,
+                                        List<Long> splitOffsets, int[] equalityFieldIds, Integer sortOrderId,
+                                        ByteBuffer keyMetadata) {
+    return new GenericDataFile(specId, content, filePath, format, partitionData, fileSizeInBytes, recordCount,
+        columnSizes, valueCounts, nullValueCounts, nanValueCounts, lowerBounds, upperBounds, splitOffsets,
+        equalityFieldIds, sortOrderId, keyMetadata);
+  }
+
+  public static DeleteFile createDeleteFile(int specId, FileContent content, String filePath, FileFormat format,
+                                            PartitionData partitionData, long fileSizeInBytes, long recordCount,
+                                            Map<Integer, Long> columnSizes, Map<Integer, Long> valueCounts,
+                                            Map<Integer, Long> nullValueCounts, Map<Integer, Long> nanValueCounts,
+                                            Map<Integer, ByteBuffer> lowerBounds, Map<Integer, ByteBuffer> upperBounds,
+                                            List<Long> splitOffsets, int[] equalityFieldIds, Integer sortOrderId,
+                                            ByteBuffer keyMetadata) {
+    return new GenericDeleteFile(specId, content, filePath, format, partitionData, fileSizeInBytes, recordCount,
+        columnSizes, valueCounts, nullValueCounts, nanValueCounts, lowerBounds, upperBounds, splitOffsets,
+        equalityFieldIds, sortOrderId, keyMetadata);
+  }
+
+  public static List<byte[]> partitionDataToBytesMap(PartitionData partition) {
+    return IntStream.of(partition.size())
+        .mapToObj(i -> partitionValueToBytes(partition.get(i), i))
+        .collect(Collectors.toList());
+  }
+
+  public static PartitionData bytesMapToPartitionData(List<byte[]> values, PartitionSpec spec) {

Review comment:
       This seems unused. Do i understand correctly, it's for Trino's consumption?
   We should exercise this code within Iceberg. Let's have a test.




-- 
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-unsubscribe@iceberg.apache.org

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



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