prashantwason commented on a change in pull request #2064:
URL: https://github.com/apache/hudi/pull/2064#discussion_r491331857



##########
File path: 
hudi-client/src/main/java/org/apache/hudi/metadata/HoodieMetadataPayload.java
##########
@@ -0,0 +1,227 @@
+/*
+ * 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.hudi.metadata;
+
+import org.apache.hudi.common.model.HoodieKey;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.model.HoodieRecordPayload;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.exception.HoodieMetadataException;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.avro.generic.IndexedRecord;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.Path;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * This is a payload which saves information about a single entry in the 
Metadata Table. The type of the entry is
+ * determined by the "type" saved within the record. The following types of 
entries are saved:
+ *
+ *   1. List of partitions: There is a single such record
+ *         key="__all_partitions__"
+ *         filenameToSizeMap={"2020/01/01": 0, "2020/01/02": 0, ...}
+ *
+ *   2. List of files in a Partition: There is one such record for each 
partition
+ *         key=Partition name
+ *         filenameToSizeMap={"file1.parquet": 12345, "file2.parquet": 56789, 
"file1.log": 9876,
+ *                            "file0.parquet": -1, ...}
+ *
+ *      For deleted files, -1 is used as the size.
+ *
+ *  During compaction on the table, the deletions are merged with additions 
and hence pruned.
+ */
+public class HoodieMetadataPayload implements 
HoodieRecordPayload<HoodieMetadataPayload> {
+  private static final Logger LOG = 
LogManager.getLogger(HoodieMetadataPayload.class);
+
+  // Represents the size stored for a deleted file
+  private static final long DELETED_FILE_SIZE = -1;
+
+  // Key and type for the metadata record
+  private final String metadataKey;
+  private final PayloadType type;
+
+  // Filenames which are part of this record
+  // key=filename, value=file size (or DELETED_FILE_SIZE to represent a 
deleted file)
+  private final Map<String, Long> filenameMap = new HashMap<>();
+
+  // Type of the metadata record
+  public enum PayloadType {
+    PARTITION_LIST(1),        // list of partitions
+    PARTITION_FILES(2);       // list of files in a partition
+
+    private final int value;

Review comment:
       That and the fact that I want to avoid 0. 




----------------------------------------------------------------
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:
[email protected]


Reply via email to