@@ -620,8 +620,8 @@ private BatchOperation compatOldServerDel(final List<? extends Row> actions, fin
620
620
} else if (delete .getFamilyCellMap ().size () > 1 ) {
621
621
boolean has_delete_family = delete .getFamilyCellMap ().entrySet ().stream ()
622
622
.flatMap (entry -> entry .getValue ().stream ()).anyMatch (
623
- kv -> kv .getType (). getCode () == KeyValue .Type .DeleteFamily .getCode () ||
624
- kv .getType (). getCode () == KeyValue .Type .DeleteFamilyVersion .getCode ());
623
+ kv -> kv .getTypeByte () == KeyValue .Type .DeleteFamily .getCode () ||
624
+ kv .getTypeByte () == KeyValue .Type .DeleteFamilyVersion .getCode ());
625
625
if (!has_delete_family ) {
626
626
return buildBatchOperation (tableNameString ,
627
627
Collections .singletonList (delete ), true ,
@@ -1402,8 +1402,8 @@ public boolean checkAndMutate(byte[] row, byte[] family, byte[] qualifier, Compa
1402
1402
}
1403
1403
1404
1404
@ Override
1405
- public CheckAndMutateBuilder checkAndMutate ( byte [] row , byte [] family ) {
1406
- return new ObCheckAndMutateBuilderImpl ( row , family );
1405
+ public long getRpcTimeout ( TimeUnit unit ) {
1406
+ return getRpcTimeout ( );
1407
1407
}
1408
1408
1409
1409
private boolean checkAndMutation (byte [] row , byte [] family , byte [] qualifier ,
@@ -1723,6 +1723,11 @@ public int getOperationTimeout() {
1723
1723
return operationTimeout ;
1724
1724
}
1725
1725
1726
+ @ Override
1727
+ public long getOperationTimeout (TimeUnit unit ) {
1728
+ return getOperationTimeout ();
1729
+ }
1730
+
1726
1731
//todo
1727
1732
@ Override
1728
1733
public void setRpcTimeout (int rpcTimeout ) {
@@ -1741,11 +1746,31 @@ public int getReadRpcTimeout() {
1741
1746
return this .readRpcTimeout ;
1742
1747
}
1743
1748
1749
+ @ Override
1750
+ public void setReadRpcTimeout (int readRpcTimeout ) {
1751
+ this .readRpcTimeout = readRpcTimeout ;
1752
+ }
1753
+ @ Override
1754
+ public long getReadRpcTimeout (TimeUnit unit ) {
1755
+ return getReadRpcTimeout ();
1756
+ }
1757
+
1758
+ @ Override
1759
+ public long getWriteRpcTimeout (TimeUnit unit ) {
1760
+ return this .readRpcTimeout ;
1761
+ }
1762
+
1744
1763
@ Override
1745
1764
public int getWriteRpcTimeout () {
1746
1765
return this .writeRpcTimeout ;
1747
1766
}
1748
1767
1768
+ @ Override
1769
+ public void setWriteRpcTimeout (int writeRpcTimeout ) {
1770
+ this .writeRpcTimeout = writeRpcTimeout ;
1771
+ }
1772
+
1773
+
1749
1774
public void setRuntimeBatchExecutor (ExecutorService runtimeBatchExecutor ) {
1750
1775
this .obTableClient .setRuntimeBatchExecutor (runtimeBatchExecutor );
1751
1776
}
@@ -2016,7 +2041,7 @@ public static ObTableBatchOperation buildObTableBatchOperation(List<Mutation> ro
2016
2041
private QueryAndMutate buildDeleteQueryAndMutate (KeyValue kv ,
2017
2042
ObTableOperationType operationType ,
2018
2043
boolean isTableGroup , byte [] family , Long TTL ) {
2019
- KeyValue .Type kvType = KeyValue .Type .codeToType (kv .getType (). getCode ());
2044
+ KeyValue .Type kvType = KeyValue .Type .codeToType (kv .getTypeByte ());
2020
2045
com .alipay .oceanbase .rpc .mutation .Mutation tableMutation = buildMutation (kv , operationType ,
2021
2046
isTableGroup , family , TTL );
2022
2047
if (isTableGroup ) {
@@ -2136,7 +2161,7 @@ private com.alipay.oceanbase.rpc.mutation.Mutation buildMutation(Cell kv,
2136
2161
System .arraycopy (oldQualifier , 0 , newQualifier , family .length + 1 , oldQualifier .length );
2137
2162
newCell = modifyQualifier (kv , newQualifier );
2138
2163
}
2139
- Cell .Type kvType = kv .getType ( );
2164
+ KeyValue .Type kvType = KeyValue . Type . codeToType ( kv .getTypeByte () );
2140
2165
switch (kvType ) {
2141
2166
case Put :
2142
2167
String [] propertyColumns = V_COLUMNS ;
@@ -2182,7 +2207,7 @@ private KeyValue modifyQualifier(Cell original, byte[] newQualifier) {
2182
2207
byte [] family = CellUtil .cloneFamily (original );
2183
2208
byte [] value = CellUtil .cloneValue (original );
2184
2209
long timestamp = original .getTimestamp ();
2185
- KeyValue .Type type = KeyValue .Type .codeToType (original .getType (). getCode ());
2210
+ KeyValue .Type type = KeyValue .Type .codeToType (original .getTypeByte ());
2186
2211
// Create a new KeyValue with the modified qualifier
2187
2212
return new KeyValue (row , family , newQualifier , timestamp , type , value );
2188
2213
}
@@ -2312,7 +2337,7 @@ private BatchOperation buildBatchOperation(String tableName, List<? extends Row>
2312
2337
public static ObTableOperation buildObTableOperation (Cell kv ,
2313
2338
ObTableOperationType operationType ,
2314
2339
Long TTL ) {
2315
- Cell .Type kvType = kv .getType ( );
2340
+ KeyValue .Type kvType = KeyValue . Type . codeToType ( kv .getTypeByte () );
2316
2341
String [] propertyColumns = V_COLUMNS ;
2317
2342
Object [] property = new Object [] { CellUtil .cloneValue (kv ) };
2318
2343
if (TTL != Long .MAX_VALUE ) {
@@ -2449,7 +2474,7 @@ public Pair<byte[][], byte[][]> getStartEndKeys() throws IOException {
2449
2474
return new Pair <>(getStartKeys (), getEndKeys ());
2450
2475
}
2451
2476
2452
- private CompareFilter .CompareOp getCompareOp (CompareOperator cmpOp ) {
2477
+ public static CompareFilter .CompareOp getCompareOp (CompareOperator cmpOp ) {
2453
2478
switch (cmpOp ) {
2454
2479
case LESS :
2455
2480
return CompareFilter .CompareOp .LESS ;
@@ -2467,96 +2492,4 @@ private CompareFilter.CompareOp getCompareOp(CompareOperator cmpOp) {
2467
2492
return CompareFilter .CompareOp .NO_OP ;
2468
2493
}
2469
2494
}
2470
-
2471
- private class ObCheckAndMutateBuilderImpl implements CheckAndMutateBuilder {
2472
- private final byte [] row ;
2473
- private final byte [] family ;
2474
- private byte [] qualifier ;
2475
- private byte [] value ;
2476
- private TimeRange timeRange ;
2477
- private CompareOperator cmpOp ;
2478
-
2479
- ObCheckAndMutateBuilderImpl (byte [] row , byte [] family ) {
2480
- this .row = checkNotNull (row , "The provided row is null." );
2481
- this .family = checkNotNull (family , "The provided family is null." );
2482
- }
2483
-
2484
- @ Override
2485
- public CheckAndMutateBuilder qualifier (byte [] qualifier ) {
2486
- this .qualifier = checkNotNull (
2487
- qualifier ,
2488
- "The provided qualifier is null. You could"
2489
- + " use an empty byte array, or do not call this method if you want a null qualifier." );
2490
- return this ;
2491
- }
2492
-
2493
- @ Override
2494
- public CheckAndMutateBuilder timeRange (TimeRange timeRange ) {
2495
- this .timeRange = timeRange ;
2496
- return this ;
2497
- }
2498
-
2499
- @ Override
2500
- public CheckAndMutateBuilder ifNotExists () {
2501
- this .cmpOp = CompareOperator .EQUAL ;
2502
- this .value = null ;
2503
- return this ;
2504
- }
2505
-
2506
- @ Override
2507
- public CheckAndMutateBuilder ifMatches (CompareOperator cmpOp , byte [] value ) {
2508
- this .cmpOp = checkNotNull (cmpOp , "The provided cmpOp is null." );
2509
- this .value = checkNotNull (value , "The provided value is null." );
2510
- return this ;
2511
- }
2512
-
2513
- @ Override
2514
- public boolean thenPut (Put put ) throws IOException {
2515
- checkCmpOp ();
2516
- RowMutations rowMutations = new RowMutations (row );
2517
- rowMutations .add (put );
2518
- try {
2519
- return checkAndMutation (row , family , qualifier , getCompareOp (cmpOp ), value ,
2520
- timeRange , rowMutations );
2521
- } catch (Exception e ) {
2522
- logger .error (LCD .convert ("01-00005" ), rowMutations , tableNameString , e );
2523
- throw new IOException ("checkAndMutate type table: " + tableNameString + " e.msg: "
2524
- + e .getMessage () + " error." , e );
2525
- }
2526
- }
2527
-
2528
- @ Override
2529
- public boolean thenDelete (Delete delete ) throws IOException {
2530
- checkCmpOp ();
2531
- RowMutations rowMutations = new RowMutations (row );
2532
- rowMutations .add (delete );
2533
- try {
2534
- return checkAndMutation (row , family , qualifier , getCompareOp (cmpOp ), value ,
2535
- timeRange , rowMutations );
2536
- } catch (Exception e ) {
2537
- logger .error (LCD .convert ("01-00005" ), rowMutations , tableNameString , e );
2538
- throw new IOException ("checkAndMutate type table: " + tableNameString + " e.msg: "
2539
- + e .getMessage () + " error." , e );
2540
- }
2541
- }
2542
-
2543
- @ Override
2544
- public boolean thenMutate (RowMutations mutation ) throws IOException {
2545
- checkCmpOp ();
2546
- try {
2547
- return checkAndMutation (row , family , qualifier , getCompareOp (cmpOp ), value ,
2548
- timeRange , mutation );
2549
- } catch (Exception e ) {
2550
- logger .error (LCD .convert ("01-00005" ), mutation , tableNameString , e );
2551
- throw new IOException ("checkAndMutate type table: " + tableNameString + " e.msg: "
2552
- + e .getMessage () + " error." , e );
2553
- }
2554
- }
2555
-
2556
- private void checkCmpOp () {
2557
- checkNotNull (this .cmpOp ,
2558
- "The compare condition is null. Please use"
2559
- + " ifNotExists/ifEquals/ifMatches before executing the request" );
2560
- }
2561
- }
2562
- }
2495
+ }
0 commit comments