Skip to content

Commit cbaa84a

Browse files
committed
merge master
2 parents 9a71482 + 142249c commit cbaa84a

30 files changed

+710
-414
lines changed

pom.xml

Lines changed: 49 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,24 @@
5454
<dependencyManagement>
5555
<dependencies>
5656
<dependency>
57-
<groupId>org.testcontainers</groupId>
58-
<artifactId>testcontainers-bom</artifactId>
59-
<version>1.15.3</version>
60-
<type>pom</type>
61-
<scope>import</scope>
57+
<groupId>com.alipay.sofa.common</groupId>
58+
<artifactId>sofa-common-tools</artifactId>
59+
<version>1.3.12</version>
60+
</dependency>
61+
<dependency>
62+
<groupId>org.slf4j</groupId>
63+
<artifactId>slf4j-api</artifactId>
64+
<version>1.7.36</version>
65+
</dependency>
66+
<dependency>
67+
<groupId>com.google.guava</groupId>
68+
<artifactId>guava</artifactId>
69+
<version>31.1-jre</version>
70+
</dependency>
71+
<dependency>
72+
<groupId>junit</groupId>
73+
<artifactId>junit</artifactId>
74+
<version>4.13.2</version>
6275
</dependency>
6376
</dependencies>
6477
</dependencyManagement>
@@ -67,7 +80,6 @@
6780
<dependency>
6881
<groupId>com.alipay.sofa.common</groupId>
6982
<artifactId>sofa-common-tools</artifactId>
70-
<version>1.3.12</version>
7183
</dependency>
7284

7385
<dependency>
@@ -91,21 +103,6 @@
91103
<dependency>
92104
<groupId>com.google.guava</groupId>
93105
<artifactId>guava</artifactId>
94-
<version>31.1-jre</version>
95-
</dependency>
96-
97-
<dependency>
98-
<groupId>org.springframework</groupId>
99-
<artifactId>spring-core</artifactId>
100-
<version>5.2.25.RELEASE</version>
101-
<scope>test</scope>
102-
</dependency>
103-
104-
<dependency>
105-
<groupId>org.springframework</groupId>
106-
<artifactId>spring-beans</artifactId>
107-
<version>5.2.25.RELEASE</version>
108-
<scope>test</scope>
109106
</dependency>
110107

111108
<dependency>
@@ -129,13 +126,11 @@
129126
<dependency>
130127
<groupId>org.slf4j</groupId>
131128
<artifactId>slf4j-api</artifactId>
132-
<version>1.7.36</version>
133129
</dependency>
134130

135131
<dependency>
136132
<groupId>junit</groupId>
137133
<artifactId>junit</artifactId>
138-
<version>4.13.2</version>
139134
<scope>test</scope>
140135
</dependency>
141136

@@ -144,6 +139,12 @@
144139
<artifactId>powermock-api-mockito2</artifactId>
145140
<version>2.0.9</version>
146141
<scope>test</scope>
142+
<exclusions>
143+
<exclusion>
144+
<artifactId>objenesis</artifactId>
145+
<groupId>org.objenesis</groupId>
146+
</exclusion>
147+
</exclusions>
147148
</dependency>
148149

149150
<dependency>
@@ -153,17 +154,17 @@
153154
<scope>test</scope>
154155
</dependency>
155156

156-
<dependency>
157-
<groupId>ch.qos.logback</groupId>
158-
<artifactId>logback-classic</artifactId>
159-
<version>1.2.12</version>
160-
<scope>test</scope>
161-
</dependency>
162-
163157
<dependency>
164158
<groupId>org.testcontainers</groupId>
165159
<artifactId>jdbc</artifactId>
166160
<scope>test</scope>
161+
<version>1.15.3</version>
162+
<exclusions>
163+
<exclusion>
164+
<groupId>org.rnorth.visible-assertions</groupId>
165+
<artifactId>visible-assertions</artifactId>
166+
</exclusion>
167+
</exclusions>
167168
</dependency>
168169
</dependencies>
169170

@@ -361,6 +362,24 @@
361362
</execution>
362363
</executions>
363364
</plugin>
365+
<plugin>
366+
<groupId>org.apache.maven.plugins</groupId>
367+
<artifactId>maven-enforcer-plugin</artifactId>
368+
<version>3.0.0-M3</version>
369+
<executions>
370+
<execution>
371+
<id>enforce-dependency-convergence</id>
372+
<goals>
373+
<goal>enforce</goal>
374+
</goals>
375+
<configuration>
376+
<rules>
377+
<DependencyConvergence/>
378+
</rules>
379+
</configuration>
380+
</execution>
381+
</executions>
382+
</plugin>
364383
</plugins>
365384
</build>
366385
</profile>

src/main/java/com/alipay/oceanbase/rpc/ObGlobal.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,14 @@ public static String getObVsnString(long version) {
8383

8484
public static boolean isLsOpSupport() {
8585
return OB_VERSION >= OB_VERSION_4_2_3_0 && OB_VERSION < OB_VERSION_4_3_0_0
86-
|| OB_VERSION >= OB_VERSION_4_3_4_0;
86+
|| OB_VERSION >= OB_VERSION_4_3_4_0;
8787
}
8888

8989
public static boolean isReturnOneResultSupport() {
9090
return OB_VERSION >= OB_VERSION_4_2_3_0 && OB_VERSION < OB_VERSION_4_3_0_0
91-
|| OB_VERSION >= OB_VERSION_4_3_4_0;
91+
|| OB_VERSION >= OB_VERSION_4_3_4_0;
9292
}
9393

94-
9594
public static final long OB_VERSION_4_2_3_0 = calcVersion(4, (short) 2, (byte) 3, (byte) 0);
9695

9796
public static final long OB_VERSION_4_3_0_0 = calcVersion(4, (short) 3, (byte) 0, (byte) 0);

src/main/java/com/alipay/oceanbase/rpc/ObTableClient.java

Lines changed: 51 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,9 @@ private <T> T executeMutation(String tableName, MutationExecuteCallback<T> callb
815815
if (tryTimes > 1) {
816816
TableEntry entry = getOrRefreshTableEntry(tableName, false, false, false);
817817
Long partId = getPartition(entry, callback.getRowKey());
818-
refreshTableLocationByTabletId(entry, tableName, getTabletIdByPartId(entry, partId));
818+
if (ObGlobal.obVsnMajor() >= 4) {
819+
refreshTableLocationByTabletId(entry, tableName, getTabletIdByPartId(entry, partId));
820+
}
819821
}
820822
// using row key
821823
obPair = getTable(tableName, callback.getRowKey(), needRefreshTableEntry, tableEntryRefreshIntervalWait, false, route);
@@ -1672,8 +1674,7 @@ private ObPair<Long, ObTableParam> getTable(String tableName, Object[] rowKey,
16721674
TableEntry tableEntry = getOrRefreshTableEntry(tableName, refresh, waitForRefresh,
16731675
needFetchAll);
16741676
Row row = new Row();
1675-
if (tableEntry.isPartitionTable()
1676-
&& tableEntry.getPartitionInfo().getLevel() != ObPartitionLevel.LEVEL_ZERO) {
1677+
if (tableEntry.isPartitionTable()) {
16771678
List<String> curTableRowKeyNames = new ArrayList<String>();
16781679
Map<String, Integer> tableRowKeyEle = getRowKeyElement(tableName);
16791680
if (tableRowKeyEle != null) {
@@ -1694,7 +1695,7 @@ private ObPair<Long, ObTableParam> getTable(String tableName, Object[] rowKey,
16941695
}
16951696

16961697
long partId = getPartition(tableEntry, row); // partition id in 3.x, origin partId in 4.x, logicId
1697-
if (refresh) {
1698+
if (refresh && ObGlobal.obVsnMajor() >= 4) {
16981699
refreshTableLocationByTabletId(tableEntry, tableName, getTabletIdByPartId(tableEntry, partId));
16991700
}
17001701
return getTableInternal(tableName, tableEntry, partId, waitForRefresh, route);
@@ -1929,14 +1930,20 @@ public ObPair<Long, ObTableParam> getTableInternal(String tableName, TableEntry
19291930
ObServerRoute route) throws Exception {
19301931
ReplicaLocation replica = null;
19311932
long tabletId = getTabletIdByPartId(tableEntry, partId);
1933+
long partitionId = partId;
19321934
ObPartitionLocationInfo obPartitionLocationInfo = null;
19331935
if (ObGlobal.obVsnMajor() >= 4) {
19341936

19351937
obPartitionLocationInfo = getOrRefreshPartitionInfo(tableEntry, tableName, tabletId);
19361938

19371939
replica = getPartitionLocation(obPartitionLocationInfo, route);
19381940
} else {
1939-
ObPair<Long, ReplicaLocation> partitionReplica = getPartitionReplica(tableEntry, partId,
1941+
if (tableEntry.isPartitionTable()
1942+
&& null != tableEntry.getPartitionInfo().getSubPartDesc()) {
1943+
partitionId = ObPartIdCalculator.getPartIdx(partId, tableEntry
1944+
.getPartitionInfo().getSubPartDesc().getPartNum());
1945+
}
1946+
ObPair<Long, ReplicaLocation> partitionReplica = getPartitionReplica(tableEntry, partitionId,
19401947
route);
19411948
replica = partitionReplica.getRight();
19421949
}
@@ -1961,7 +1968,7 @@ public ObPair<Long, ObTableParam> getTableInternal(String tableName, TableEntry
19611968
replica = getPartitionLocation(obPartitionLocationInfo, route);
19621969
} else {
19631970
tableEntry = getOrRefreshTableEntry(tableName, true, waitForRefresh, false);
1964-
replica = getPartitionReplica(tableEntry, partId, route).getRight();
1971+
replica = getPartitionReplica(tableEntry, partitionId, route).getRight();
19651972
}
19661973

19671974
addr = replica.getAddr();
@@ -1972,9 +1979,8 @@ public ObPair<Long, ObTableParam> getTableInternal(String tableName, TableEntry
19721979
throw new ObTableGetException("Cannot get table by addr: " + addr);
19731980
}
19741981
}
1975-
ObTableParam param = null;
1982+
ObTableParam param = createTableParam(obTable, tableEntry, obPartitionLocationInfo, partId, tabletId);
19761983
if (ObGlobal.obVsnMajor() >= 4) {
1977-
param = createTableParam(obTable, tableEntry, obPartitionLocationInfo, partId, tabletId);
19781984
} else {
19791985
param.setPartId(partId);
19801986
param.setTableId(tableEntry.getTableId());
@@ -2047,19 +2053,36 @@ private List<ObPair<Long, ReplicaLocation>> getPartitionReplica(TableEntry table
20472053
List<ObPair<Long, ReplicaLocation>> replicas = new ArrayList<>();
20482054

20492055
if (!tableEntry.isPartitionTable() || tableEntry.getPartitionInfo().getLevel() == ObPartitionLevel.LEVEL_ZERO) {
2050-
long tabletId = getTabletIdByPartId(tableEntry, 0L);
2051-
ObPartitionLocationInfo locationInfo = getOrRefreshPartitionInfo(tableEntry, tableName, tabletId);
2052-
replicas.add(new ObPair<>(tabletId, getPartitionLocation(locationInfo, route)));
2056+
if (ObGlobal.obVsnMajor() >= 4) {
2057+
long tabletId = getTabletIdByPartId(tableEntry, 0L);
2058+
ObPartitionLocationInfo locationInfo = getOrRefreshPartitionInfo(tableEntry, tableName, tabletId);
2059+
replicas.add(new ObPair<>(tabletId, getPartitionLocation(locationInfo, route)));
2060+
} else {
2061+
replicas.add(new ObPair<Long, ReplicaLocation>(0L, getPartitionLocation(tableEntry, 0L,
2062+
route)));
2063+
}
20532064
return replicas;
20542065
}
20552066

20562067
ObPartitionLevel partitionLevel = tableEntry.getPartitionInfo().getLevel();
20572068
List<Long> partIds = getPartitionTablePartitionIds(tableEntry, startRow, startIncluded, endRow, endIncluded, partitionLevel);
20582069

2059-
for (Long partId : partIds) {
2060-
long tabletId = getTabletIdByPartId(tableEntry, partId);
2061-
ObPartitionLocationInfo locationInfo = getOrRefreshPartitionInfo(tableEntry, tableName, tabletId);
2062-
replicas.add(new ObPair<>(tabletId, getPartitionLocation(locationInfo, route)));
2070+
if (ObGlobal.obVsnMajor() >= 4) {
2071+
for (Long partId : partIds) {
2072+
long tabletId = getTabletIdByPartId(tableEntry, partId);
2073+
ObPartitionLocationInfo locationInfo = getOrRefreshPartitionInfo(tableEntry, tableName, tabletId);
2074+
replicas.add(new ObPair<>(tabletId, getPartitionLocation(locationInfo, route)));
2075+
}
2076+
} else {
2077+
for (Long partId : partIds) {
2078+
long partitionId = partId;
2079+
if (tableEntry.getPartitionInfo().getLevel() == ObPartitionLevel.LEVEL_TWO) {
2080+
partitionId = ObPartIdCalculator.getPartIdx(partId, tableEntry
2081+
.getPartitionInfo().getSubPartDesc().getPartNum());
2082+
}
2083+
replicas.add(new ObPair<Long, ReplicaLocation>(partId, getPartitionLocation(
2084+
tableEntry, partitionId, route)));
2085+
}
20632086
}
20642087

20652088
return replicas;
@@ -2182,8 +2205,7 @@ public List<ObPair<Long, ObTableParam>> getTables(String tableName, ObTableQuery
21822205
Row startRow = new Row();
21832206
Row endRow = new Row();
21842207
// ensure the format of column names and values if the current table is a table with partition
2185-
if (tableEntry.isPartitionTable()
2186-
&& tableEntry.getPartitionInfo().getLevel() != ObPartitionLevel.LEVEL_ZERO) {
2208+
if (tableEntry.isPartitionTable()) {
21872209
if ((scanRangeColumns == null || scanRangeColumns.isEmpty()) && start.length == 1
21882210
&& start[0] instanceof ObObj && ((ObObj) start[0]).isMinObj() && end.length == 1
21892211
&& end[0] instanceof ObObj && ((ObObj) end[0]).isMaxObj()) {
@@ -3599,11 +3621,21 @@ public ObPayload execute(final ObTableAbstractOperationRequest request) throws E
35993621
Object[] start = new Object[startKeySize];
36003622
Object[] end = new Object[endKeySize];
36013623
for (int i = 0; i < startKeySize; i++) {
3602-
start[i] = startKey.getObj(i).getValue();
3624+
ObObj curStart = startKey.getObj(i);
3625+
if (curStart.isMinObj()) {
3626+
start[i] = curStart;
3627+
} else {
3628+
start[i] = curStart.getValue();
3629+
}
36033630
}
36043631

36053632
for (int i = 0; i < endKeySize; i++) {
3606-
end[i] = endKey.getObj(i).getValue();
3633+
ObObj curEnd = endKey.getObj(i);
3634+
if (curEnd.isMaxObj()) {
3635+
end[i] = curEnd;
3636+
} else {
3637+
end[i] = curEnd.getValue();
3638+
}
36073639
}
36083640
ObBorderFlag borderFlag = rang.getBorderFlag();
36093641
List<ObPair<Long, ObTableParam>> pairList = getTables(request.getTableName(),

0 commit comments

Comments
 (0)