You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "JingsongLi (via GitHub)" <gi...@apache.org> on 2023/03/10 04:31:22 UTC

[GitHub] [flink-table-store] JingsongLi opened a new pull request, #589: [FLINK-31392] Refactor classes code of full-compaction

JingsongLi opened a new pull request, #589:
URL: https://github.com/apache/flink-table-store/pull/589

   Refactor classes code of full-compaction, this is to prepare some shared codes for lookup changelog producer.
   
   


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

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


[GitHub] [flink-table-store] JingsongLi merged pull request #589: [FLINK-31392] Refactor classes code of full-compaction

Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi merged PR #589:
URL: https://github.com/apache/flink-table-store/pull/589


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

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


[GitHub] [flink-table-store] tsreaper commented on a diff in pull request #589: [FLINK-31392] Refactor classes code of full-compaction

Posted by "tsreaper (via GitHub)" <gi...@apache.org>.
tsreaper commented on code in PR #589:
URL: https://github.com/apache/flink-table-store/pull/589#discussion_r1132137625


##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/mergetree/compact/ChangelogMergeTreeRewriter.java:
##########
@@ -0,0 +1,128 @@
+/*
+ * 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.flink.table.store.file.mergetree.compact;
+
+import org.apache.flink.table.store.data.InternalRow;
+import org.apache.flink.table.store.file.KeyValue;
+import org.apache.flink.table.store.file.compact.CompactResult;
+import org.apache.flink.table.store.file.io.DataFileMeta;
+import org.apache.flink.table.store.file.io.KeyValueFileReaderFactory;
+import org.apache.flink.table.store.file.io.KeyValueFileWriterFactory;
+import org.apache.flink.table.store.file.io.RollingFileWriter;
+import org.apache.flink.table.store.file.mergetree.MergeTreeReaders;
+import org.apache.flink.table.store.file.mergetree.SortedRun;
+import org.apache.flink.table.store.reader.RecordReader;
+import org.apache.flink.table.store.reader.RecordReaderIterator;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+/** A {@link MergeTreeCompactRewriter} which produces changelog files for the compaction. */
+public abstract class ChangelogMergeTreeRewriter extends MergeTreeCompactRewriter {
+
+    public ChangelogMergeTreeRewriter(
+            KeyValueFileReaderFactory readerFactory,
+            KeyValueFileWriterFactory writerFactory,
+            Comparator<InternalRow> keyComparator,
+            MergeFunctionFactory<KeyValue> mfFactory) {
+        super(readerFactory, writerFactory, keyComparator, mfFactory);
+    }
+
+    protected abstract boolean rewriteChangelog(
+            int outputLevel, boolean dropDelete, List<List<SortedRun>> sections);
+
+    protected abstract boolean upgradeChangelog(int outputLevel, DataFileMeta file);
+
+    protected abstract MergeFunctionWrapper<ChangelogResult> createMergeWrapper(int outputLevel);
+
+    @Override
+    public CompactResult rewrite(
+            int outputLevel, boolean dropDelete, List<List<SortedRun>> sections) throws Exception {
+        if (rewriteChangelog(outputLevel, dropDelete, sections)) {
+            return rewriteLookupCompaction(outputLevel, sections);
+        } else {
+            return rewriteCompaction(outputLevel, dropDelete, sections);
+        }
+    }
+
+    private CompactResult rewriteLookupCompaction(int outputLevel, List<List<SortedRun>> sections)

Review Comment:
   Why name it `rewriteLookupCompaction`? There is no logic related to lookup in this method.



##########
flink-table-store-core/src/test/java/org/apache/flink/table/store/file/mergetree/compact/FullChangelogMergeFunctionWrapperTestBase.java:
##########
@@ -70,12 +71,17 @@ public void beforeEach() {
                                     .replace(row(6), 8, RowKind.INSERT, row(3))
                                     .setLevel(MAX_LEVEL),
                             new KeyValue().replace(row(6), 9, RowKind.INSERT, row(-3)).setLevel(0)),
+                    Arrays.asList(
+                            new KeyValue()
+                                    .replace(row(7), 10, RowKind.INSERT, row(3))
+                                    .setLevel(MAX_LEVEL),
+                            new KeyValue().replace(row(7), 11, RowKind.DELETE, row(3)).setLevel(0)),
                     Arrays.asList(
                             new KeyValue()
                                     .replace(row(7), 10, RowKind.INSERT, row(3))
                                     .setLevel(MAX_LEVEL),
                             new KeyValue()
-                                    .replace(row(7), 11, RowKind.DELETE, row(3))
+                                    .replace(row(7), 11, RowKind.UPDATE_BEFORE, row(3))
                                     .setLevel(0)));

Review Comment:
   Change sequence numbers to 12 and 13.



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

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


[GitHub] [flink-table-store] JingsongLi commented on a diff in pull request #589: [FLINK-31392] Refactor classes code of full-compaction

Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #589:
URL: https://github.com/apache/flink-table-store/pull/589#discussion_r1132193097


##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/mergetree/compact/ChangelogMergeTreeRewriter.java:
##########
@@ -0,0 +1,128 @@
+/*
+ * 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.flink.table.store.file.mergetree.compact;
+
+import org.apache.flink.table.store.data.InternalRow;
+import org.apache.flink.table.store.file.KeyValue;
+import org.apache.flink.table.store.file.compact.CompactResult;
+import org.apache.flink.table.store.file.io.DataFileMeta;
+import org.apache.flink.table.store.file.io.KeyValueFileReaderFactory;
+import org.apache.flink.table.store.file.io.KeyValueFileWriterFactory;
+import org.apache.flink.table.store.file.io.RollingFileWriter;
+import org.apache.flink.table.store.file.mergetree.MergeTreeReaders;
+import org.apache.flink.table.store.file.mergetree.SortedRun;
+import org.apache.flink.table.store.reader.RecordReader;
+import org.apache.flink.table.store.reader.RecordReaderIterator;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+/** A {@link MergeTreeCompactRewriter} which produces changelog files for the compaction. */
+public abstract class ChangelogMergeTreeRewriter extends MergeTreeCompactRewriter {
+
+    public ChangelogMergeTreeRewriter(
+            KeyValueFileReaderFactory readerFactory,
+            KeyValueFileWriterFactory writerFactory,
+            Comparator<InternalRow> keyComparator,
+            MergeFunctionFactory<KeyValue> mfFactory) {
+        super(readerFactory, writerFactory, keyComparator, mfFactory);
+    }
+
+    protected abstract boolean rewriteChangelog(
+            int outputLevel, boolean dropDelete, List<List<SortedRun>> sections);
+
+    protected abstract boolean upgradeChangelog(int outputLevel, DataFileMeta file);
+
+    protected abstract MergeFunctionWrapper<ChangelogResult> createMergeWrapper(int outputLevel);
+
+    @Override
+    public CompactResult rewrite(
+            int outputLevel, boolean dropDelete, List<List<SortedRun>> sections) throws Exception {
+        if (rewriteChangelog(outputLevel, dropDelete, sections)) {
+            return rewriteLookupCompaction(outputLevel, sections);
+        } else {
+            return rewriteCompaction(outputLevel, dropDelete, sections);
+        }
+    }
+
+    private CompactResult rewriteLookupCompaction(int outputLevel, List<List<SortedRun>> sections)

Review Comment:
   `rewriteChangelogCompaction`



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

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