nastra commented on code in PR #10735:
URL: https://github.com/apache/iceberg/pull/10735#discussion_r1711104519


##########
core/src/main/java/org/apache/iceberg/ManifestFileParser.java:
##########
@@ -0,0 +1,277 @@
+/*
+ * 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 com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonNode;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.List;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
+import org.apache.iceberg.relocated.com.google.common.io.BaseEncoding;
+import org.apache.iceberg.util.ByteBuffers;
+import org.apache.iceberg.util.JsonUtil;
+
+class ManifestFileParser {
+  private static final String PATH = "path";
+  private static final String LENGTH = "length";
+  private static final String SPEC_ID = "partition-spec-id";
+  private static final String CONTENT = "content";
+  private static final String SEQUENCE_NUMBER = "sequence-number";
+  private static final String MIN_SEQUENCE_NUMBER = "min-sequence-number";
+  private static final String ADDED_SNAPSHOT_ID = "added-snapshot-id";
+  private static final String ADDED_FILES_COUNT = "added-files-count";
+  private static final String EXISTING_FILES_COUNT = "existing-files-count";
+  private static final String DELETED_FILES_COUNT = "deleted-files-count";
+  private static final String ADDED_ROWS_COUNT = "added-rows-count";
+  private static final String EXISTING_ROWS_COUNT = "existing-rows-count";
+  private static final String DELETED_ROWS_COUNT = "deleted-rows-count";
+  private static final String PARTITION_FIELD_SUMMARY = 
"partition-field-summary";
+  private static final String KEY_METADATA = "key-metadata";
+
+  private ManifestFileParser() {}
+
+  static void toJson(ManifestFile manifestFile, JsonGenerator generator) 
throws IOException {
+    Preconditions.checkArgument(manifestFile != null, "Invalid manifest file: 
null");
+    Preconditions.checkArgument(generator != null, "Invalid JSON generator: 
null");
+
+    generator.writeStartObject();
+
+    generator.writeStringField(PATH, manifestFile.path());
+    generator.writeNumberField(LENGTH, manifestFile.length());
+    generator.writeNumberField(SPEC_ID, manifestFile.partitionSpecId());
+
+    if (manifestFile.content() != null) {
+      generator.writeNumberField(CONTENT, manifestFile.content().id());
+    }
+
+    generator.writeNumberField(SEQUENCE_NUMBER, manifestFile.sequenceNumber());
+    generator.writeNumberField(MIN_SEQUENCE_NUMBER, 
manifestFile.minSequenceNumber());
+
+    if (manifestFile.snapshotId() != null) {
+      generator.writeNumberField(ADDED_SNAPSHOT_ID, manifestFile.snapshotId());
+    }
+
+    if (manifestFile.addedFilesCount() != null) {
+      generator.writeNumberField(ADDED_FILES_COUNT, 
manifestFile.addedFilesCount());
+    }
+
+    if (manifestFile.existingFilesCount() != null) {
+      generator.writeNumberField(EXISTING_FILES_COUNT, 
manifestFile.existingFilesCount());
+    }
+
+    if (manifestFile.deletedFilesCount() != null) {
+      generator.writeNumberField(DELETED_FILES_COUNT, 
manifestFile.deletedFilesCount());
+    }
+
+    if (manifestFile.addedRowsCount() != null) {
+      generator.writeNumberField(ADDED_ROWS_COUNT, 
manifestFile.addedRowsCount());
+    }
+
+    if (manifestFile.existingRowsCount() != null) {
+      generator.writeNumberField(EXISTING_ROWS_COUNT, 
manifestFile.existingRowsCount());
+    }
+
+    if (manifestFile.deletedRowsCount() != null) {
+      generator.writeNumberField(DELETED_ROWS_COUNT, 
manifestFile.deletedRowsCount());
+    }
+
+    if (manifestFile.partitions() != null) {
+      generator.writeArrayFieldStart(PARTITION_FIELD_SUMMARY);
+      for (ManifestFile.PartitionFieldSummary summary : 
manifestFile.partitions()) {
+        PartitionFieldSummaryParser.toJson(summary, generator);
+      }
+
+      generator.writeEndArray();
+    }
+
+    if (manifestFile.keyMetadata() != null) {
+      generator.writeStringField(

Review Comment:
   should this be doing the same thing as we're doing in 
https://github.com/apache/iceberg/blob/ccaeb2f4d5be44b4ab177b8fb790194eff8070a5/core/src/main/java/org/apache/iceberg/ContentFileParser.java#L97?



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

Reply via email to