@@ -1939,24 +1939,23 @@ private ObTableQuery buildObTableQuery(final Get get, Collection<byte[]> columnQ
1939
1939
public static ObTableBatchOperation buildObTableBatchOperation (List <Mutation > rowList ,
1940
1940
List <byte []> qualifiers ) {
1941
1941
ObTableBatchOperation batch = new ObTableBatchOperation ();
1942
- OHOpType opType ;
1942
+ ObTableOperationType opType ;
1943
1943
Map <String , Integer > indexMap = new HashMap <>();
1944
1944
for (Mutation row : rowList ) {
1945
1945
if (row instanceof Put ) {
1946
- opType = OHOpType . Put ;
1946
+ opType = INSERT_OR_UPDATE ;
1947
1947
} else if (row instanceof Delete ) {
1948
- opType = OHOpType . Delete ;
1948
+ opType = DEL ;
1949
1949
} else if (row instanceof Increment ) {
1950
- opType = OHOpType . Increment ;
1950
+ opType = INCREMENT ;
1951
1951
} else if (row instanceof Append ) {
1952
- opType = OHOpType . Append ;
1952
+ opType = APPEND ;
1953
1953
} else {
1954
1954
throw new FeatureNotSupportedException ("not supported other type" );
1955
1955
}
1956
1956
Set <Map .Entry <byte [], List <Cell >>> familyCellMap = row .getFamilyCellMap ().entrySet ();
1957
-
1958
1957
for (Map .Entry <byte [], List <Cell >> familyWithCells : familyCellMap ) {
1959
- if (opType == OHOpType . Increment || opType == OHOpType . Append ) {
1958
+ if (opType == INCREMENT || opType == APPEND ) {
1960
1959
indexMap .clear ();
1961
1960
for (int i = 0 ; i < familyWithCells .getValue ().size (); i ++) {
1962
1961
Cell cell = familyWithCells .getValue ().get (i );
@@ -1973,46 +1972,37 @@ public static ObTableBatchOperation buildObTableBatchOperation(List<Mutation> ro
1973
1972
}
1974
1973
}
1975
1974
}
1976
-
1977
1975
}
1978
1976
batch .setSamePropertiesNames (true );
1979
1977
return batch ;
1980
1978
}
1981
1979
1982
1980
private com .alipay .oceanbase .rpc .mutation .Mutation buildMutation (Cell kv ,
1983
- OHOpType operationType ,
1981
+ ObTableOperationType operationType ,
1984
1982
boolean isTableGroup ,
1985
1983
byte [] family , Long TTL ) {
1986
1984
Cell new_cell = kv ;
1987
1985
if (isTableGroup && family != null ) {
1988
1986
new_cell = modifyQualifier (kv , (Bytes .toString (family ) + "." + Bytes .toString (CellUtil
1989
1987
.cloneQualifier (kv ))).getBytes ());
1990
1988
}
1991
- String [] property_columns = V_COLUMNS ;
1992
- Object [] property = new Object [] { CellUtil .cloneValue (new_cell ) };
1993
- if (TTL != Long .MAX_VALUE ) {
1994
- property_columns = PROPERTY_COLUMNS ;
1995
- property = new Object [] { CellUtil .cloneValue (new_cell ), TTL };
1996
- }
1997
- switch (operationType ) {
1989
+ Cell .Type kvType = kv .getType ();
1990
+ switch (kvType ) {
1998
1991
case Put :
1999
- return com .alipay .oceanbase .rpc .mutation .Mutation .getInstance (INSERT_OR_UPDATE ,
2000
- ROW_KEY_COLUMNS ,
2001
- new Object [] { CellUtil .cloneRow (new_cell ), CellUtil .cloneQualifier (new_cell ),
2002
- new_cell .getTimestamp () }, property_columns , property );
2003
- case Append :
2004
- return com .alipay .oceanbase .rpc .mutation .Mutation .getInstance (APPEND ,
1992
+ String [] property_columns = V_COLUMNS ;
1993
+ Object [] property = new Object [] { CellUtil .cloneValue (new_cell ) };
1994
+ if (TTL != Long .MAX_VALUE ) {
1995
+ property_columns = PROPERTY_COLUMNS ;
1996
+ property = new Object [] { CellUtil .cloneValue (new_cell ), TTL };
1997
+ }
1998
+ return com .alipay .oceanbase .rpc .mutation .Mutation .getInstance (operationType ,
2005
1999
ROW_KEY_COLUMNS ,
2006
2000
new Object [] { CellUtil .cloneRow (new_cell ), CellUtil .cloneQualifier (new_cell ),
2007
2001
new_cell .getTimestamp () }, property_columns , property );
2008
2002
case Delete :
2009
2003
return com .alipay .oceanbase .rpc .mutation .Mutation .getInstance (DEL , ROW_KEY_COLUMNS ,
2010
2004
new Object [] { CellUtil .cloneRow (new_cell ), CellUtil .cloneQualifier (new_cell ),
2011
2005
new_cell .getTimestamp () }, null , null );
2012
- case DeleteAll :
2013
- return com .alipay .oceanbase .rpc .mutation .Mutation .getInstance (DEL , ROW_KEY_COLUMNS ,
2014
- new Object [] { CellUtil .cloneRow (new_cell ), null , -new_cell .getTimestamp () },
2015
- null , null );
2016
2006
case DeleteColumn :
2017
2007
return com .alipay .oceanbase .rpc .mutation .Mutation .getInstance (DEL , ROW_KEY_COLUMNS ,
2018
2008
new Object [] { CellUtil .cloneRow (new_cell ), CellUtil .cloneQualifier (new_cell ),
@@ -2109,7 +2099,7 @@ private BatchOperation buildBatchOperation(String tableName, List<? extends Row>
2109
2099
List <Cell > keyValueList = entry .getValue ();
2110
2100
for (Cell kv : keyValueList ) {
2111
2101
singleOpResultNum ++;
2112
- batch .addOperation (buildMutation (kv , OHOpType . Put ,
2102
+ batch .addOperation (buildMutation (kv , INSERT_OR_UPDATE ,
2113
2103
isTableGroup , family , put .getTTL ()));
2114
2104
}
2115
2105
}
@@ -2118,15 +2108,16 @@ private BatchOperation buildBatchOperation(String tableName, List<? extends Row>
2118
2108
if (delete .isEmpty ()) {
2119
2109
singleOpResultNum ++;
2120
2110
KeyValue kv = new KeyValue (delete .getRow (), delete .getTimeStamp ());
2121
- batch .addOperation (buildMutation (kv , OHOpType .DeleteAll , isTableGroup , null ,
2122
- delete .getTTL ()));
2111
+ batch .addOperation (com .alipay .oceanbase .rpc .mutation .Mutation .getInstance (DEL , ROW_KEY_COLUMNS ,
2112
+ new Object [] { CellUtil .cloneRow (kv ), null , -kv .getTimestamp () },
2113
+ null , null ));
2123
2114
} else {
2124
2115
for (Map .Entry <byte [], List <Cell >> entry : delete .getFamilyCellMap ().entrySet ()) {
2125
2116
byte [] family = entry .getKey ();
2126
2117
List <Cell > keyValueList = entry .getValue ();
2127
2118
for (Cell kv : keyValueList ) {
2128
2119
singleOpResultNum ++;
2129
- batch .addOperation (buildMutation (kv , getDeleteType ( kv . getType ()) ,
2120
+ batch .addOperation (buildMutation (kv , DEL ,
2130
2121
isTableGroup , family , delete .getTTL ()));
2131
2122
}
2132
2123
}
@@ -2141,48 +2132,35 @@ private BatchOperation buildBatchOperation(String tableName, List<? extends Row>
2141
2132
return batch ;
2142
2133
}
2143
2134
2144
- public static ObTableOperation buildObTableOperation (Cell kv , OHOpType operationType , Long TTL ) {
2135
+ public static ObTableOperation buildObTableOperation (Cell kv ,
2136
+ ObTableOperationType operationType ,
2137
+ Long TTL ) {
2138
+ Cell .Type kvType = kv .getType ();
2145
2139
String [] property_columns = V_COLUMNS ;
2146
2140
Object [] property = new Object [] { CellUtil .cloneValue (kv ) };
2147
2141
if (TTL != Long .MAX_VALUE ) {
2148
2142
property_columns = PROPERTY_COLUMNS ;
2149
2143
property = new Object [] { CellUtil .cloneValue (kv ), TTL };
2150
2144
}
2151
- switch (operationType ) {
2145
+ switch (kvType ) {
2152
2146
case Put :
2153
- case Increment :
2154
- case Append :
2155
- ObTableOperationType type ;
2156
- if (operationType == OHOpType .Put ) {
2157
- type = INSERT_OR_UPDATE ;
2158
- } else if (operationType == OHOpType .Increment ) {
2159
- type = INCREMENT ;
2160
- } else {
2161
- type = APPEND ;
2162
- }
2163
2147
return getInstance (
2164
- type ,
2148
+ operationType ,
2165
2149
new Object [] { CellUtil .cloneRow (kv ), CellUtil .cloneQualifier (kv ),
2166
2150
kv .getTimestamp () }, property_columns , property );
2167
2151
case Delete :
2168
- Cell .Type delType = kv .getType ();
2169
- if (delType == Cell .Type .Delete ) {
2170
- return getInstance (
2171
- DEL ,
2172
- new Object [] { CellUtil .cloneRow (kv ), CellUtil .cloneQualifier (kv ),
2173
- kv .getTimestamp () }, null , null );
2174
- } else if (delType == Cell .Type .DeleteColumn ) {
2175
- return getInstance (
2176
- DEL ,
2177
- new Object [] { CellUtil .cloneRow (kv ), CellUtil .cloneQualifier (kv ),
2178
- -kv .getTimestamp () }, null , null );
2179
- } else if (delType == Cell .Type .DeleteFamily ) {
2180
- return getInstance (DEL ,
2181
- new Object [] { CellUtil .cloneRow (kv ), null , -kv .getTimestamp () }, null ,
2182
- null );
2183
- } else {
2184
- throw new IllegalArgumentException ("illegal delete type " + operationType );
2185
- }
2152
+ return getInstance (
2153
+ DEL ,
2154
+ new Object [] { CellUtil .cloneRow (kv ), CellUtil .cloneQualifier (kv ),
2155
+ kv .getTimestamp () }, null , null );
2156
+ case DeleteColumn :
2157
+ return getInstance (
2158
+ DEL ,
2159
+ new Object [] { CellUtil .cloneRow (kv ), CellUtil .cloneQualifier (kv ),
2160
+ -kv .getTimestamp () }, null , null );
2161
+ case DeleteFamily :
2162
+ return getInstance (DEL ,
2163
+ new Object [] { CellUtil .cloneRow (kv ), null , -kv .getTimestamp () }, null , null );
2186
2164
default :
2187
2165
throw new IllegalArgumentException ("illegal mutation type " + operationType );
2188
2166
}
@@ -2295,25 +2273,6 @@ public Pair<byte[][], byte[][]> getStartEndKeys() throws IOException {
2295
2273
return new Pair <>(getStartKeys (), getEndKeys ());
2296
2274
}
2297
2275
2298
- public static enum OHOpType {
2299
- Put , Append , Delete , DeleteAll , DeleteColumn , DeleteFamily , DeleteFamilyVersion , Increment
2300
- }
2301
-
2302
- public static OHOpType getDeleteType (Cell .Type type ) {
2303
- switch (type ) {
2304
- case Delete :
2305
- return OHOpType .Delete ;
2306
- case DeleteColumn :
2307
- return OHOpType .DeleteColumn ;
2308
- case DeleteFamily :
2309
- return OHOpType .DeleteFamily ;
2310
- case DeleteFamilyVersion :
2311
- return OHOpType .DeleteFamilyVersion ;
2312
- default :
2313
- throw new IllegalArgumentException ("illegal mutation type " + type );
2314
- }
2315
- }
2316
-
2317
2276
private CompareFilter .CompareOp getCompareOp (CompareOperator cmpOp ) {
2318
2277
switch (cmpOp ) {
2319
2278
case LESS :
0 commit comments