WencongLiu commented on code in PR #3384: URL: https://github.com/apache/paimon/pull/3384#discussion_r1616626295
########## paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/sorter/TableSortInfo.java: ########## @@ -0,0 +1,175 @@ +/* + * 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.sorter; + +import org.apache.paimon.flink.FlinkConnectorOptions; + +import java.util.Collections; +import java.util.List; + +import static org.apache.flink.shaded.guava31.com.google.common.base.Preconditions.checkArgument; + +/** + * {@link TableSortInfo} is used to indicate the configuration details for table data sorting. This + * includes information about which columns to sort by, the sorting strategy (e.g., order, Z-order), + * whether to sort within each cluster, and sample sizes for local and global sample nodes. + */ +public class TableSortInfo { + + private final List<String> sortColumns; + + private final String sortStrategy; + + private final boolean sortInCluster; + + private final int rangeNumber; + + private final int sinkParallelism; + + private final int localSampleSize; + + private final int globalSampleSize; + + private TableSortInfo( + List<String> sortColumns, + String sortStrategy, + boolean sortInCluster, + int rangeNumber, + int sinkParallelism, + int localSampleSize, + int globalSampleSize) { + checkArgument(!sortColumns.isEmpty(), "Sort columns cannot be empty"); + checkArgument(!sortStrategy.isEmpty(), "Sort strategy cannot be empty"); + checkArgument(rangeNumber > 0, "Range number must be positive"); + checkArgument( + sinkParallelism > 0, + "The sink parallelism must be specified when sorting the table data. Please set it using the key: " + + FlinkConnectorOptions.SINK_PARALLELISM.key()); + checkArgument(localSampleSize > 0, "Local sample size must be positive"); + checkArgument(globalSampleSize > 0, "Global sample size must be positive"); + this.sortColumns = sortColumns; + this.sortStrategy = sortStrategy; + this.sortInCluster = sortInCluster; + this.rangeNumber = rangeNumber; + this.sinkParallelism = sinkParallelism; + this.localSampleSize = localSampleSize; + this.globalSampleSize = globalSampleSize; + } + + public List<String> getSortColumns() { + return sortColumns; + } + + public String getSortStrategy() { + return sortStrategy; + } + + public boolean isSortInCluster() { + return sortInCluster; + } + + public int getRangeNumber() { + return rangeNumber; + } + + public int getLocalSampleSize() { + return localSampleSize; + } + + public int getGlobalSampleSize() { + return globalSampleSize; + } + + public int getSinkParallelism() { + return sinkParallelism; + } + + /** Builder for {@link TableSortInfo}. */ + public static class Builder { + + private List<String> sortColumns = Collections.emptyList(); + + private String sortStrategy = "order"; + + private boolean sortInCluster = true; + + private int rangeNumber = -1; + + private int sinkParallelism = -1; + + private int localSampleSize = -1; + + private int globalSampleSize = -1; + + public Builder setSortColumns(List<String> sortColumns) { + checkArgument(!sortColumns.isEmpty(), "Sort columns cannot be empty"); + this.sortColumns = sortColumns; + return this; + } + + public Builder setSortStrategy(String sortStrategy) { + checkArgument(!sortStrategy.isEmpty(), "Sort strategy cannot be empty"); + this.sortStrategy = sortStrategy; + return this; + } + + public Builder setSortInCluster(boolean sortInCluster) { + this.sortInCluster = sortInCluster; + return this; + } + + public Builder setRangeNumber(int rangeNumber) { + checkArgument(rangeNumber > 0, "Range number must be positive"); + this.rangeNumber = rangeNumber; + return this; + } + + public Builder setSinkParallelism(int sinkParallelism) { + checkArgument( + sinkParallelism > 0, + "The sink parallelism must be specified when sorting the table data. Please set it using the key: " Review Comment: Done. ########## paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/sorter/TableSortInfo.java: ########## @@ -0,0 +1,175 @@ +/* + * 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.sorter; + +import org.apache.paimon.flink.FlinkConnectorOptions; + +import java.util.Collections; +import java.util.List; + +import static org.apache.flink.shaded.guava31.com.google.common.base.Preconditions.checkArgument; + +/** + * {@link TableSortInfo} is used to indicate the configuration details for table data sorting. This + * includes information about which columns to sort by, the sorting strategy (e.g., order, Z-order), + * whether to sort within each cluster, and sample sizes for local and global sample nodes. + */ +public class TableSortInfo { + + private final List<String> sortColumns; + + private final String sortStrategy; + + private final boolean sortInCluster; + + private final int rangeNumber; + + private final int sinkParallelism; + + private final int localSampleSize; + + private final int globalSampleSize; + + private TableSortInfo( + List<String> sortColumns, + String sortStrategy, + boolean sortInCluster, + int rangeNumber, + int sinkParallelism, + int localSampleSize, + int globalSampleSize) { + checkArgument(!sortColumns.isEmpty(), "Sort columns cannot be empty"); + checkArgument(!sortStrategy.isEmpty(), "Sort strategy cannot be empty"); + checkArgument(rangeNumber > 0, "Range number must be positive"); + checkArgument( + sinkParallelism > 0, + "The sink parallelism must be specified when sorting the table data. Please set it using the key: " + + FlinkConnectorOptions.SINK_PARALLELISM.key()); + checkArgument(localSampleSize > 0, "Local sample size must be positive"); + checkArgument(globalSampleSize > 0, "Global sample size must be positive"); + this.sortColumns = sortColumns; + this.sortStrategy = sortStrategy; + this.sortInCluster = sortInCluster; + this.rangeNumber = rangeNumber; + this.sinkParallelism = sinkParallelism; + this.localSampleSize = localSampleSize; + this.globalSampleSize = globalSampleSize; + } + + public List<String> getSortColumns() { + return sortColumns; + } + + public String getSortStrategy() { + return sortStrategy; + } + + public boolean isSortInCluster() { + return sortInCluster; + } + + public int getRangeNumber() { + return rangeNumber; + } + + public int getLocalSampleSize() { + return localSampleSize; + } + + public int getGlobalSampleSize() { + return globalSampleSize; + } + + public int getSinkParallelism() { + return sinkParallelism; + } + + /** Builder for {@link TableSortInfo}. */ + public static class Builder { + + private List<String> sortColumns = Collections.emptyList(); + + private String sortStrategy = "order"; + + private boolean sortInCluster = true; + + private int rangeNumber = -1; + + private int sinkParallelism = -1; + + private int localSampleSize = -1; + + private int globalSampleSize = -1; + + public Builder setSortColumns(List<String> sortColumns) { + checkArgument(!sortColumns.isEmpty(), "Sort columns cannot be empty"); + this.sortColumns = sortColumns; + return this; + } + + public Builder setSortStrategy(String sortStrategy) { + checkArgument(!sortStrategy.isEmpty(), "Sort strategy cannot be empty"); + this.sortStrategy = sortStrategy; + return this; + } + + public Builder setSortInCluster(boolean sortInCluster) { + this.sortInCluster = sortInCluster; + return this; + } + + public Builder setRangeNumber(int rangeNumber) { + checkArgument(rangeNumber > 0, "Range number must be positive"); Review Comment: Done. -- 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]
