tsreaper commented on code in PR #1366:
URL: https://github.com/apache/incubator-paimon/pull/1366#discussion_r1231835218
##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/compact/UnawareBucketCompactionTopoBuilder.java:
##########
@@ -73,14 +74,22 @@ public void withPartitions(List<Map<String, String>>
partitions) {
}
public void build() {
-
// build source from UnawareSourceFunction
DataStreamSource<AppendOnlyCompactionTask> source = buildSource();
// from source, construct the full flink job
sinkFromSource(source);
}
+ public DataStream<Committable> fetchUncommitted(String commitUser) {
+ DataStreamSource<AppendOnlyCompactionTask> source = buildSource();
+
+ // rebalance input to default or assigned parallelism
+ DataStream<AppendOnlyCompactionTask> rebalanced =
rebalanceInput(source);
+
+ return new UnawareBucketCompactionSink(table).doWrite(rebalanced,
commitUser);
+ }
+
private DataStreamSource<AppendOnlyCompactionTask> buildSource() {
long scanInterval =
table.coreOptions().continuousDiscoveryInterval().toMillis();
UnawareBucketSourceFunction source =
Review Comment:
This `UnawareBucketSourceFunction` is actually the "compactor coordinator"
in the description of this pull request? Please change the class name to make
it clear.
Also the Java doc of `UnawareBucketSourceFunction` says nothing about
compaction. Please write a detailed Java doc explaining what this class does
and why.
##########
paimon-core/src/main/java/org/apache/paimon/operation/AppendOnlyFileStoreWrite.java:
##########
@@ -159,7 +161,20 @@ public AppendOnlyCompactManager.CompactRewriter
compactRewriter(
};
}
- public void skipCompaction() {
- skipCompaction = true;
+ public AppendOnlyFileStoreWrite withBucketMode(BucketMode bucketMode) {
+ // AppendOnlyFileStoreWrite is sensitive with bucket mode. It will act
difference in
+ // unaware-bucket mode (no compaction and force empty-writer).
+ this.bucketMode = bucketMode;
+ if (bucketMode == BucketMode.UNAWARE) {
+ super.withIgnorePreviousFiles(true);
+ skipCompaction = true;
+ }
+ return this;
+ }
+
+ @Override
+ public void withIgnorePreviousFiles(boolean emptyWriter) {
+ // in unaware bucket mode, we need all writers to be empty
+ super.withIgnorePreviousFiles(emptyWriter || bucketMode ==
BucketMode.UNAWARE);
Review Comment:
Why are we ignoring previous files in unaware bucket mode? This might result
in a lot of small, uncompacted files if the job restarts multiple times.
##########
paimon-core/src/main/java/org/apache/paimon/append/AppendOnlyCompactionTask.java:
##########
@@ -69,7 +69,7 @@ public CommitMessage
doCompact(AppendOnlyCompactManager.CompactRewriter rewriter
new CompactIncrement(compactBefore, compactAfter,
Collections.emptyList());
return new CommitMessageImpl(
partition,
- 0, // bucket 0 is temp bucket for non-bucket table
+ 0, // bucket 0 is temp bucket for unaware-bucket table
Review Comment:
"temp bucket"? What do you mean here?
##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/sink/UnawareBucketWriteSink.java:
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.flink.sink;
+
+import org.apache.paimon.flink.compact.UnawareBucketCompactionTopoBuilder;
+import org.apache.paimon.operation.Lock;
+import org.apache.paimon.table.AppendOnlyFileStoreTable;
+
+import org.apache.flink.api.common.RuntimeExecutionMode;
+import org.apache.flink.configuration.ExecutionOptions;
+import org.apache.flink.streaming.api.datastream.DataStream;
+import org.apache.flink.streaming.api.datastream.DataStreamSink;
+import org.apache.flink.streaming.api.transformations.PartitionTransformation;
+import org.apache.flink.table.data.RowData;
+
+import java.util.Map;
+
+/**
+ * Build topology for unaware bucket table sink.
+ *
+ * <p>Note: in unaware-bucket mode, we don't shuffle by bucket in inserting.
We can assign
+ * compaction to the inserting jobs aside.
+ */
+public class UnawareBucketWriteSink extends FileStoreSink {
+
+ private final boolean enableCompaction;
+ private final AppendOnlyFileStoreTable table;
+
+ public UnawareBucketWriteSink(
+ AppendOnlyFileStoreTable table,
+ Lock.Factory lock,
+ Map<String, String> overwritePartitions,
+ LogSinkFunction logSinkFunction) {
+ super(table, lock, overwritePartitions, logSinkFunction);
+ this.table = table;
+ this.enableCompaction = !table.coreOptions().writeOnly();
+ }
+
+ public DataStreamSink<?> build(DataStream<RowData> input, Integer
parallelism) {
+ DataStream<RowData> partitioned = partition(input, parallelism);
+
+ return sinkFrom(partitioned);
+ }
Review Comment:
This `build` method looks strange to me. This is not a builder class. Why
not just merge all these into `sinkFrom`?
--
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]