Skip to content

Commit e71320a

Browse files
committed
[Chore] format
1 parent 959f552 commit e71320a

File tree

7 files changed

+162
-136
lines changed

7 files changed

+162
-136
lines changed

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

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -910,8 +910,8 @@ public void syncRefreshMetadata() throws Exception {
910910
* @param scanRangeColumns columns that need to be scaned
911911
* @return the real table name
912912
*/
913-
public String getIndexTableName(final String dataTableName, final String indexName, List<String> scanRangeColumns)
914-
throws Exception {
913+
public String getIndexTableName(final String dataTableName, final String indexName,
914+
List<String> scanRangeColumns) throws Exception {
915915
String indexTableName = dataTableName;
916916
if (indexName != null && !indexName.isEmpty() && !indexName.equalsIgnoreCase("PRIMARY")) {
917917
String tmpTableName = constructIndexTableName(dataTableName, indexName);
@@ -925,27 +925,29 @@ public String getIndexTableName(final String dataTableName, final String indexNa
925925
if (indexInfo.getIndexType().isGlobalIndex()) {
926926
indexTableName = tmpTableName;
927927
if (scanRangeColumns.isEmpty()) {
928-
throw new ObTableException("query by global index need add all index keys in order");
928+
throw new ObTableException(
929+
"query by global index need add all index keys in order");
929930
} else {
930-
addRowKeyElement(indexTableName, scanRangeColumns.toArray(new String[scanRangeColumns.size()]));
931+
addRowKeyElement(indexTableName,
932+
scanRangeColumns.toArray(new String[scanRangeColumns.size()]));
931933
}
932934
}
933935
}
934936
return indexTableName;
935937
}
936938

937939
public String constructIndexTableName(final String dataTableName, final String indexName)
938-
throws Exception {
940+
throws Exception {
939941
// construct index table name
940942
TableEntry entry = tableLocations.get(dataTableName);
941943
Long dataTableId = null;
942944
try {
943945
if (entry == null) {
944946
ObServerAddr addr = serverRoster.getServer(serverAddressPriorityTimeout,
945-
serverAddressCachingTimeout);
947+
serverAddressCachingTimeout);
946948
dataTableId = LocationUtil.getTableIdFromRemote(addr, sysUA,
947-
tableEntryAcquireConnectTimeout, tableEntryAcquireSocketTimeout, tenantName,
948-
database, dataTableName);
949+
tableEntryAcquireConnectTimeout, tableEntryAcquireSocketTimeout, tenantName,
950+
database, dataTableName);
949951
} else {
950952
dataTableId = entry.getTableId();
951953
}
@@ -957,7 +959,7 @@ public String constructIndexTableName(final String dataTableName, final String i
957959
}
958960

959961
public ObIndexInfo getOrRefreshIndexInfo(final String indexName, final String indexTableName)
960-
throws Exception {
962+
throws Exception {
961963
ObIndexInfo indexInfo = indexinfos.get(indexName);
962964
if (indexInfo != null) {
963965
return indexInfo;
@@ -968,8 +970,8 @@ public ObIndexInfo getOrRefreshIndexInfo(final String indexName, final String in
968970
boolean acquired = lock.tryLock(tableEntryRefreshLockTimeout, TimeUnit.MILLISECONDS);
969971
if (!acquired) {
970972
String errMsg = "try to lock index infos refreshing timeout " + "dataSource:"
971-
+ dataSourceName + " ,indexName:" + indexName + " , timeout:"
972-
+ tableEntryRefreshLockTimeout + ".";
973+
+ dataSourceName + " ,indexName:" + indexName + " , timeout:"
974+
+ tableEntryRefreshLockTimeout + ".";
973975
RUNTIME.error(errMsg);
974976
throw new ObTableEntryRefreshException(errMsg);
975977
}
@@ -979,21 +981,21 @@ public ObIndexInfo getOrRefreshIndexInfo(final String indexName, final String in
979981
return indexInfo;
980982
} else {
981983
logger.info("index info is not exist, create new index info, indexName: {}",
982-
indexName);
984+
indexName);
983985
int serverSize = serverRoster.getMembers().size();
984986
int refreshTryTimes = tableEntryRefreshTryTimes > serverSize ? serverSize
985-
: tableEntryRefreshTryTimes;
987+
: tableEntryRefreshTryTimes;
986988
for (int i = 0; i < refreshTryTimes; i++) {
987989
ObServerAddr serverAddr = serverRoster.getServer(serverAddressPriorityTimeout,
988-
serverAddressCachingTimeout);
990+
serverAddressCachingTimeout);
989991
indexInfo = getIndexInfoFromRemote(serverAddr, sysUA,
990-
tableEntryAcquireConnectTimeout, tableEntryAcquireSocketTimeout,
991-
indexTableName);
992+
tableEntryAcquireConnectTimeout, tableEntryAcquireSocketTimeout,
993+
indexTableName);
992994
if (indexInfo != null) {
993995
indexinfos.put(indexName, indexInfo);
994996
} else {
995997
RUNTIME.error("get index info from remote is null, index name: {}",
996-
indexName);
998+
indexName);
997999
}
9981000
}
9991001
return indexInfo;

src/main/java/com/alipay/oceanbase/rpc/location/LocationUtil.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ public class LocationUtil {
6262

6363
private static final String OB_VERSION_SQL = "SELECT /*+READ_CONSISTENCY(WEAK)*/ OB_VERSION() AS CLUSTER_VERSION;";
6464

65-
private static final String PROXY_INDEX_INFO_SQL = "SELECT /*+READ_CONSISTENCY(WEAK)*/ data_table_id, table_id, index_type FROM oceanbase.__all_virtual_table " +
66-
"where table_name = ?";
65+
private static final String PROXY_INDEX_INFO_SQL = "SELECT /*+READ_CONSISTENCY(WEAK)*/ data_table_id, table_id, index_type FROM oceanbase.__all_virtual_table "
66+
+ "where table_name = ?";
6767

68-
private static final String PROXY_TABLE_ID_SQL = "SELECT /*+READ_CONSISTENCY(WEAK)*/ table_id from oceanbase.__all_virtual_proxy_schema " +
69-
"where tenant_name = ? and database_name = ? and table_name = ? limit 1";
68+
private static final String PROXY_TABLE_ID_SQL = "SELECT /*+READ_CONSISTENCY(WEAK)*/ table_id from oceanbase.__all_virtual_proxy_schema "
69+
+ "where tenant_name = ? and database_name = ? and table_name = ? limit 1";
7070

7171
private static final String OB_TENANT_EXIST_SQL = "SELECT /*+READ_CONSISTENCY(WEAK)*/ tenant_id from __all_tenant where tenant_name = ?;";
7272

@@ -688,8 +688,9 @@ public static TableEntry getTableEntryLocationFromRemote(Connection connection,
688688
}
689689

690690
public static Long getTableIdFromRemote(ObServerAddr obServerAddr, ObUserAuth sysUA,
691-
long connectTimeout, long socketTimeout, String tenantName,
692-
String databaseName, String tableName) throws ObTableEntryRefreshException {
691+
long connectTimeout, long socketTimeout,
692+
String tenantName, String databaseName, String tableName)
693+
throws ObTableEntryRefreshException {
693694
Long tableId = null;
694695
Connection connection = null;
695696
PreparedStatement ps = null;
@@ -706,11 +707,11 @@ public static Long getTableIdFromRemote(ObServerAddr obServerAddr, ObUserAuth sy
706707
tableId = rs.getLong("table_id");
707708
} else {
708709
throw new ObTableEntryRefreshException("fail to get " + tableName
709-
+ " table_id from remote");
710+
+ " table_id from remote");
710711
}
711712
} catch (Exception e) {
712713
throw new ObTableEntryRefreshException("fail to get " + tableName
713-
+ " table_id from remote", e);
714+
+ " table_id from remote", e);
714715
} finally {
715716
try {
716717
if (null != rs) {
@@ -729,7 +730,7 @@ public static Long getTableIdFromRemote(ObServerAddr obServerAddr, ObUserAuth sy
729730
public static ObIndexInfo getIndexInfoFromRemote(ObServerAddr obServerAddr, ObUserAuth sysUA,
730731
long connectTimeout, long socketTimeout,
731732
String indexTableName)
732-
throws ObTableEntryRefreshException {
733+
throws ObTableEntryRefreshException {
733734
ObIndexInfo indexInfo = null;
734735
Connection connection = null;
735736
PreparedStatement ps = null;
@@ -746,10 +747,12 @@ public static ObIndexInfo getIndexInfoFromRemote(ObServerAddr obServerAddr, ObUs
746747
indexInfo.setIndexTableId(rs.getLong("table_id"));
747748
indexInfo.setIndexType(ObIndexType.valueOf(rs.getInt("index_type")));
748749
} else {
749-
throw new ObTableEntryRefreshException("fail to get index info from remote, result set is empty");
750+
throw new ObTableEntryRefreshException(
751+
"fail to get index info from remote, result set is empty");
750752
}
751753
} catch (Exception e) {
752-
throw new ObTableEntryRefreshException(format("fail to get index info from remote, indexTableName: %s", indexTableName), e);
754+
throw new ObTableEntryRefreshException(format(
755+
"fail to get index info from remote, indexTableName: %s", indexTableName), e);
753756
} finally {
754757
try {
755758
if (null != rs) {

src/main/java/com/alipay/oceanbase/rpc/location/model/ObIndexInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,6 @@ public void setIndexType(ObIndexType indexType) {
6868
@Override
6969
public String toString() {
7070
return "ObIndexInfo{" + "dataTableId=" + dataTableId + ", indexTableId=" + indexTableId
71-
+ ", indexTableName=" + indexTableName + ", indexType=" + indexType + '}';
71+
+ ", indexTableName=" + indexTableName + ", indexType=" + indexType + '}';
7272
}
7373
}

src/main/java/com/alipay/oceanbase/rpc/protocol/payload/impl/execute/ObIndexType.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,16 @@
2121
import java.util.Map;
2222

2323
public enum ObIndexType {
24-
IndexTypeIsNot(0), IndexTypeNormalLocal(1), IndexTypeUniqueLocal(2), IndexTypeNormalGlobal(3),
25-
IndexTypeUniqueGlobal(4), IndexTypePrimary(5), IndexTypeDomainCtxcat(6), IndexTypeNormalGlobalLocalStorage(7),
26-
IndexTypeUniqueGlobalLocalStorage(8), IndexTypeSpatialLocal(10), IndexTypeSpatialGlobal(11),
27-
IndexTypeSpatialGlobalLocalStorage(12), IndexTypeMax(13);
24+
IndexTypeIsNot(0), IndexTypeNormalLocal(1), IndexTypeUniqueLocal(2), IndexTypeNormalGlobal(3), IndexTypeUniqueGlobal(
25+
4), IndexTypePrimary(
26+
5), IndexTypeDomainCtxcat(
27+
6), IndexTypeNormalGlobalLocalStorage(
28+
7), IndexTypeUniqueGlobalLocalStorage(
29+
8), IndexTypeSpatialLocal(
30+
10), IndexTypeSpatialGlobal(
31+
11), IndexTypeSpatialGlobalLocalStorage(
32+
12), IndexTypeMax(
33+
13);
2834

2935
private int value;
3036
private static Map<Integer, ObIndexType> map = new HashMap<Integer, ObIndexType>();
@@ -62,7 +68,7 @@ public byte getByteValue() {
6268

6369
public boolean isGlobalIndex() {
6470
return valueOf(value) == ObIndexType.IndexTypeNormalGlobal
65-
|| valueOf(value) == ObIndexType.IndexTypeUniqueGlobal
66-
|| valueOf(value) == ObIndexType.IndexTypeSpatialGlobal;
71+
|| valueOf(value) == ObIndexType.IndexTypeUniqueGlobal
72+
|| valueOf(value) == ObIndexType.IndexTypeSpatialGlobal;
6773
}
6874
}

src/main/java/com/alipay/oceanbase/rpc/table/ObTableClientQueryAsyncImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ public Map<Long, ObPair<Long, ObTableParam>> getPartitions() throws Exception {
153153
String indexName = tableQuery.getIndexName();
154154
String indexTableName = tableName;
155155
if (!this.obTableClient.isOdpMode()) {
156-
indexTableName = obTableClient.getIndexTableName(tableName, indexName, tableQuery.getScanRangeColumns());
156+
indexTableName = obTableClient.getIndexTableName(tableName, indexName,
157+
tableQuery.getScanRangeColumns());
157158
}
158159

159160
this.partitionObTables = new HashMap<Long, ObPair<Long, ObTableParam>>();

src/main/java/com/alipay/oceanbase/rpc/table/ObTableClientQueryImpl.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ public ObTableClientQueryStreamResult executeInternal() throws Exception {
143143
String indexName = tableQuery.getIndexName();
144144
String indexTableName = tableName;
145145
if (!this.obTableClient.isOdpMode()) {
146-
indexTableName = obTableClient.getIndexTableName(tableName, indexName, tableQuery.getScanRangeColumns());
146+
indexTableName = obTableClient.getIndexTableName(tableName, indexName,
147+
tableQuery.getScanRangeColumns());
147148
}
148149

149150
for (ObNewRange rang : tableQuery.getKeyRanges()) {
@@ -162,8 +163,8 @@ public ObTableClientQueryStreamResult executeInternal() throws Exception {
162163
}
163164
ObBorderFlag borderFlag = rang.getBorderFlag();
164165
List<ObPair<Long, ObTableParam>> pairs = obTableClient.getTables(indexTableName,
165-
start, borderFlag.isInclusiveStart(), end, borderFlag.isInclusiveEnd(), false,
166-
false, obTableClient.getReadRoute());
166+
start, borderFlag.isInclusiveStart(), end, borderFlag.isInclusiveEnd(), false,
167+
false, obTableClient.getReadRoute());
167168
for (ObPair<Long, ObTableParam> pair : pairs) {
168169
partitionObTables.put(pair.getLeft(), pair);
169170
}

0 commit comments

Comments
 (0)