You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/07/01 03:56:25 UTC

[GitHub] [flink-table-store] LadyForest commented on a diff in pull request #182: [FLINK-27708] Add background compaction task for append-only table when ingesting

LadyForest commented on code in PR #182:
URL: https://github.com/apache/flink-table-store/pull/182#discussion_r911595201


##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/compact/CompactManager.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.compact;
+
+import java.util.Optional;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+
+/**
+ * Manager to submit compaction task.
+ *
+ * @param <I> The type of subject to be compacted.
+ * @param <T> The record type of rewriter to write.
+ * @param <O> The type of compact strategy's output.
+ */
+public abstract class CompactManager<I, T, O> {
+
+    protected final ExecutorService executor;
+
+    protected final CompactStrategy<I, O> strategy;
+
+    protected final CompactRewriter<T> rewriter;
+
+    protected Future<CompactResult> taskFuture;
+
+    public CompactManager(
+            ExecutorService executor, CompactStrategy<I, O> strategy, CompactRewriter<T> rewriter) {
+        this.executor = executor;
+        this.strategy = strategy;
+        this.rewriter = rewriter;
+    }
+
+    /** Submit a new compaction task. */
+    public void submitCompaction(I input) {
+        if (taskFuture != null) {
+            throw new IllegalStateException(
+                    "Please finish the previous compaction before submitting new one.");
+        }
+        strategy.pick(input)

Review Comment:
   > Abstraction is for code reuse, but I feel that `CompactStrategy`'s abstraction here does not reuse any code. I think `CompactManager` makes sense, they both deal with asynchronous tasks and taskFuture, but other things look no need. What do you think?
    `CompactManager` hold a reference to `CompactStrategy`?
   



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