Skip to content

Commit e6763bc

Browse files
committed
[Fix] int32/int16/int8 in range partition
Support int32/int16/int8 as partition key in range partition Link: https://code.alibaba-inc.com/oceanbase/obkv-table-client-java/codereview/12763931 * [Fix] int32/int16/int8 in range partition
1 parent c442d4c commit e6763bc

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/main/java/com/alipay/oceanbase/rpc/location/model/partition/ObPartitionKey.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ public int compareTo(ObPartitionKey that) {
115115
tmpRet = ((String) thisElement).toUpperCase().compareTo(
116116
((String) thatElement).toUpperCase());
117117
} else {
118+
// make number into long value for compare
119+
if (thisElement instanceof Number && thatElement instanceof Number) {
120+
thisElement = ((Number) thisElement).longValue();
121+
thatElement = ((Number) thatElement).longValue();
122+
}
118123
tmpRet = thisElement.compareTo(thatElement);
119124
}
120125

src/test/java/ci.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ PRIMARY KEY (`c1`, `c2`, `c3`, `c4`)
113113
partition by key(`c1`, `c2`, `c3`) subpartition by key(`c4`) subpartitions 4 partitions 16;
114114

115115
CREATE TABLE IF NOT EXISTS `testPartitionRangeComplex` (
116-
`c1` bigint NOT NULL,
116+
`c1` int NOT NULL,
117117
`c2` bigint NOT NULL,
118118
`c3` varbinary(1024) NOT NULL,
119119
`c4` varchar(1024) NOT NULL,

src/test/java/com/alipay/oceanbase/rpc/ObTableClientPartitionRangeTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ public void testPartitionLocation() throws Exception {
620620
Connection connection = ObTableClientTestUtil.getConnection();
621621
Statement statement = connection.createStatement();
622622
for (int i = 0; i < 64; i++) {
623-
long c1 = abs(rng.nextLong()) % 2000;
623+
int c1 = abs(rng.nextInt()) % 2000;
624624
long c2 = abs(rng.nextLong()) % 2000;
625625
String c3 = generateRandomStringByUUID(10);
626626
String c4 = generateRandomStringByUUID(5) + c3 + generateRandomStringByUUID(5);

0 commit comments

Comments
 (0)