Skip to content

Commit 6facb71

Browse files
authored
[Core] Add order type in paimon (#5020)
1 parent 47cc1a1 commit 6facb71

File tree

13 files changed

+55
-84
lines changed

13 files changed

+55
-84
lines changed

paimon-common/src/main/java/org/apache/paimon/CoreOptions.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3226,4 +3226,37 @@ public String toString() {
32263226
return value;
32273227
}
32283228
}
3229+
3230+
/** The order type of table sort. */
3231+
public enum OrderType {
3232+
ORDER("order"),
3233+
ZORDER("zorder"),
3234+
HILBERT("hilbert"),
3235+
NONE("none");
3236+
3237+
private final String orderType;
3238+
3239+
OrderType(String orderType) {
3240+
this.orderType = orderType;
3241+
}
3242+
3243+
@Override
3244+
public String toString() {
3245+
return "order type: " + orderType;
3246+
}
3247+
3248+
public static OrderType of(String orderType) {
3249+
if (ORDER.orderType.equalsIgnoreCase(orderType)) {
3250+
return ORDER;
3251+
} else if (ZORDER.orderType.equalsIgnoreCase(orderType)) {
3252+
return ZORDER;
3253+
} else if (HILBERT.orderType.equalsIgnoreCase(orderType)) {
3254+
return HILBERT;
3255+
} else if (NONE.orderType.equalsIgnoreCase(orderType)) {
3256+
return NONE;
3257+
}
3258+
3259+
throw new IllegalArgumentException("cannot match type: " + orderType + " for ordering");
3260+
}
3261+
}
32293262
}

paimon-core/src/main/java/org/apache/paimon/sort/zorder/ZIndexer.java renamed to paimon-common/src/main/java/org/apache/paimon/sort/zorder/ZIndexer.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
import org.apache.paimon.types.VarBinaryType;
4848
import org.apache.paimon.types.VarCharType;
4949
import org.apache.paimon.types.VariantType;
50-
import org.apache.paimon.utils.ZOrderByteUtils;
5150

5251
import java.io.Serializable;
5352
import java.nio.ByteBuffer;
@@ -57,8 +56,8 @@
5756
import java.util.Set;
5857
import java.util.function.BiFunction;
5958

60-
import static org.apache.paimon.utils.ZOrderByteUtils.NULL_BYTES;
61-
import static org.apache.paimon.utils.ZOrderByteUtils.PRIMITIVE_BUFFER_SIZE;
59+
import static org.apache.paimon.sort.zorder.ZOrderByteUtils.NULL_BYTES;
60+
import static org.apache.paimon.sort.zorder.ZOrderByteUtils.PRIMITIVE_BUFFER_SIZE;
6261

6362
/** Z-indexer for responsibility to generate z-index. */
6463
public class ZIndexer implements Serializable {

paimon-core/src/main/java/org/apache/paimon/utils/ZOrderByteUtils.java renamed to paimon-common/src/main/java/org/apache/paimon/sort/zorder/ZOrderByteUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* limitations under the License.
1717
*/
1818

19-
package org.apache.paimon.utils;
19+
package org.apache.paimon.sort.zorder;
2020

2121
import java.nio.ByteBuffer;
2222
import java.nio.CharBuffer;

paimon-core/src/test/java/org/apache/paimon/utils/TestZOrderByteUtil.java renamed to paimon-common/src/test/java/org/apache/paimon/sort/zorder/TestZOrderByteUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* limitations under the License.
1717
*/
1818

19-
package org.apache.paimon.utils;
19+
package org.apache.paimon.sort.zorder;
2020

2121
import org.junit.Assert;
2222
import org.junit.Test;

paimon-core/src/test/java/org/apache/paimon/sort/zorder/ZIndexerTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.apache.paimon.types.IntType;
2626
import org.apache.paimon.types.RowType;
2727
import org.apache.paimon.types.VarCharType;
28-
import org.apache.paimon.utils.ZOrderByteUtils;
2928

3029
import org.assertj.core.api.Assertions;
3130
import org.junit.jupiter.api.Test;

paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/action/SortCompactAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
package org.apache.paimon.flink.action;
2020

2121
import org.apache.paimon.CoreOptions;
22+
import org.apache.paimon.CoreOptions.OrderType;
2223
import org.apache.paimon.flink.FlinkConnectorOptions;
2324
import org.apache.paimon.flink.sink.SortCompactSinkBuilder;
2425
import org.apache.paimon.flink.sorter.TableSortInfo;
2526
import org.apache.paimon.flink.sorter.TableSorter;
26-
import org.apache.paimon.flink.sorter.TableSorter.OrderType;
2727
import org.apache.paimon.flink.source.FlinkSourceBuilder;
2828
import org.apache.paimon.table.BucketMode;
2929
import org.apache.paimon.table.FileStoreTable;

paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/sink/FlinkSinkBuilder.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818

1919
package org.apache.paimon.flink.sink;
2020

21+
import org.apache.paimon.CoreOptions.OrderType;
2122
import org.apache.paimon.annotation.Public;
2223
import org.apache.paimon.data.InternalRow;
2324
import org.apache.paimon.flink.FlinkConnectorOptions;
2425
import org.apache.paimon.flink.FlinkRowWrapper;
2526
import org.apache.paimon.flink.sink.index.GlobalDynamicBucketSink;
2627
import org.apache.paimon.flink.sorter.TableSortInfo;
2728
import org.apache.paimon.flink.sorter.TableSorter;
28-
import org.apache.paimon.flink.sorter.TableSorter.OrderType;
2929
import org.apache.paimon.table.BucketMode;
3030
import org.apache.paimon.table.FileStoreTable;
3131
import org.apache.paimon.table.Table;
@@ -51,14 +51,14 @@
5151
import java.util.List;
5252
import java.util.Map;
5353

54+
import static org.apache.paimon.CoreOptions.OrderType.HILBERT;
55+
import static org.apache.paimon.CoreOptions.OrderType.ORDER;
56+
import static org.apache.paimon.CoreOptions.OrderType.ZORDER;
5457
import static org.apache.paimon.flink.FlinkConnectorOptions.CLUSTERING_SAMPLE_FACTOR;
5558
import static org.apache.paimon.flink.FlinkConnectorOptions.CLUSTERING_STRATEGY;
5659
import static org.apache.paimon.flink.FlinkConnectorOptions.MIN_CLUSTERING_SAMPLE_FACTOR;
5760
import static org.apache.paimon.flink.sink.FlinkSink.isStreaming;
5861
import static org.apache.paimon.flink.sink.FlinkStreamPartitioner.partition;
59-
import static org.apache.paimon.flink.sorter.TableSorter.OrderType.HILBERT;
60-
import static org.apache.paimon.flink.sorter.TableSorter.OrderType.ORDER;
61-
import static org.apache.paimon.flink.sorter.TableSorter.OrderType.ZORDER;
6262
import static org.apache.paimon.table.BucketMode.BUCKET_UNAWARE;
6363
import static org.apache.paimon.utils.Preconditions.checkArgument;
6464
import static org.apache.paimon.utils.Preconditions.checkState;

paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/sorter/TableSortInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
package org.apache.paimon.flink.sorter;
2020

21+
import org.apache.paimon.CoreOptions.OrderType;
2122
import org.apache.paimon.flink.FlinkConnectorOptions;
22-
import org.apache.paimon.flink.sorter.TableSorter.OrderType;
2323

2424
import java.util.Collections;
2525
import java.util.List;

paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/sorter/TableSorter.java

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
package org.apache.paimon.flink.sorter;
2020

21+
import org.apache.paimon.CoreOptions.OrderType;
2122
import org.apache.paimon.flink.action.SortCompactAction;
2223
import org.apache.paimon.table.FileStoreTable;
2324

@@ -83,34 +84,4 @@ public static TableSorter getSorter(
8384
throw new IllegalArgumentException("cannot match order type: " + sortStrategy);
8485
}
8586
}
86-
87-
/** The order type of table sort. */
88-
public enum OrderType {
89-
ORDER("order"),
90-
ZORDER("zorder"),
91-
HILBERT("hilbert");
92-
93-
private final String orderType;
94-
95-
OrderType(String orderType) {
96-
this.orderType = orderType;
97-
}
98-
99-
@Override
100-
public String toString() {
101-
return "order type: " + orderType;
102-
}
103-
104-
public static OrderType of(String orderType) {
105-
if (ORDER.orderType.equalsIgnoreCase(orderType)) {
106-
return ORDER;
107-
} else if (ZORDER.orderType.equalsIgnoreCase(orderType)) {
108-
return ZORDER;
109-
} else if (HILBERT.orderType.equalsIgnoreCase(orderType)) {
110-
return HILBERT;
111-
}
112-
113-
throw new IllegalArgumentException("cannot match type: " + orderType + " for ordering");
114-
}
115-
}
11687
}

paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/sorter/TableSortInfoTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
package org.apache.paimon.flink.sorter;
2020

21+
import org.apache.paimon.CoreOptions.OrderType;
2122
import org.apache.paimon.flink.FlinkConnectorOptions;
22-
import org.apache.paimon.flink.sorter.TableSorter.OrderType;
2323

2424
import org.junit.jupiter.api.Test;
2525

0 commit comments

Comments
 (0)