JingsongLi commented on code in PR #1256:
URL: https://github.com/apache/incubator-paimon/pull/1256#discussion_r1209733866


##########
paimon-core/src/main/java/org/apache/paimon/table/AppendOnlyFileStoreTable.java:
##########
@@ -141,4 +160,16 @@ public TableWriteImpl<InternalRow> newWrite(
                     return record.row();
                 });
     }
+

Review Comment:
   ```
   public NonBucketCompaction createNonBucketCompaction() {
        1. check bucket is -1
        2. create NonBucketCompaction
   }
   
   class NonBucketCompaction {
        1. createCoordinator
        2. createWorker
   }
   ```



##########
paimon-core/src/main/java/org/apache/paimon/append/AppendOnlyTableCompactionCoordinator.java:
##########
@@ -0,0 +1,270 @@
+/*
+ * 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.paimon.append;
+
+import org.apache.paimon.data.BinaryRow;
+import org.apache.paimon.io.DataFileMeta;
+import org.apache.paimon.manifest.FileKind;
+import org.apache.paimon.manifest.ManifestEntry;
+import org.apache.paimon.operation.AppendOnlyFileStoreScan;
+import org.apache.paimon.operation.ScanKind;
+import org.apache.paimon.table.AppendOnlyFileStoreTable;
+import org.apache.paimon.table.sink.CommitMessage;
+import org.apache.paimon.table.sink.CommitMessageImpl;
+import org.apache.paimon.utils.SnapshotManager;
+
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Queue;
+import java.util.stream.Collectors;
+
+/** {@link AppendOnlyFileStoreTable} compact coordinator. */
+public class AppendOnlyTableCompactionCoordinator {
+    private final SnapshotManager snapshotManager;
+    private final AppendOnlyFileStoreScan scan;
+    private Long snapshotId;
+
+    private final long targetFileSize;
+    private final int minFileNum;
+    private final int maxFileNum;
+
+    private final Map<BinaryRow, PartitionCompactCoordinator> 
partitionCompactCoordinators =
+            new HashMap<>();
+
+    public AppendOnlyTableCompactionCoordinator(
+            AppendOnlyFileStoreTable table, long targetFileSize, int 
minFileNum, int maxFileNum) {
+        scan = table.store().newScan();
+        snapshotManager = table.snapshotManager();
+        this.targetFileSize = targetFileSize;
+        this.minFileNum = minFileNum;
+        this.maxFileNum = maxFileNum;
+        snapshotId = snapshotManager.latestSnapshotId();
+
+        if (snapshotId != null) {
+            updateFull();
+        }
+    }
+
+    public void updateRestore() {

Review Comment:
   I cannot image how to use these methods.



##########
paimon-core/src/main/java/org/apache/paimon/append/CompactionTask.java:
##########
@@ -0,0 +1,176 @@
+/*
+ * 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.paimon.append;
+
+import org.apache.paimon.data.BinaryRow;
+import org.apache.paimon.io.CompactIncrement;
+import org.apache.paimon.io.DataFileMeta;
+import org.apache.paimon.io.DataInputViewStreamWrapper;
+import org.apache.paimon.io.DataOutputViewStreamWrapper;
+import org.apache.paimon.io.NewFilesIncrement;
+import org.apache.paimon.table.AppendOnlyFileStoreTable;
+import org.apache.paimon.table.sink.CommitMessage;
+import org.apache.paimon.table.sink.CommitMessageImpl;
+import org.apache.paimon.table.sink.CommitMessageSerializer;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+
+import static org.apache.paimon.utils.SerializationUtils.deserializedBytes;
+import static org.apache.paimon.utils.SerializationUtils.serializeBytes;
+
+/**
+ * Compaction task generated by {@link AppendOnlyTableCompactionCoordinator} 
and executed be {@link
+ * AppendOnlyTableCompactionWorker}.
+ */
+public class CompactionTask implements CommitMessage {
+
+    private static final long serialVersionUID = 1L;
+
+    private static final ThreadLocal<CommitMessageSerializer> CACHE =
+            ThreadLocal.withInitial(CommitMessageSerializer::new);
+
+    private BinaryRow partition;
+    private transient List<DataFileMeta> newFiles;
+    private transient List<DataFileMeta> restoredFiles;
+    private transient List<DataFileMeta> compactBefore;
+    private transient List<DataFileMeta> compactAfter;

Review Comment:
   What is used?



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

Reply via email to