@@ -1966,24 +1966,23 @@ private ObTableQuery buildObTableQuery(final Get get, Collection<byte[]> columnQ
1966
1966
public static ObTableBatchOperation buildObTableBatchOperation (List <Mutation > rowList ,
1967
1967
List <byte []> qualifiers ) {
1968
1968
ObTableBatchOperation batch = new ObTableBatchOperation ();
1969
- OHOpType opType ;
1969
+ ObTableOperationType opType ;
1970
1970
Map <String , Integer > indexMap = new HashMap <>();
1971
1971
for (Mutation row : rowList ) {
1972
1972
if (row instanceof Put ) {
1973
- opType = OHOpType . Put ;
1973
+ opType = INSERT_OR_UPDATE ;
1974
1974
} else if (row instanceof Delete ) {
1975
- opType = OHOpType . Delete ;
1975
+ opType = DEL ;
1976
1976
} else if (row instanceof Increment ) {
1977
- opType = OHOpType . Increment ;
1977
+ opType = INCREMENT ;
1978
1978
} else if (row instanceof Append ) {
1979
- opType = OHOpType . Append ;
1979
+ opType = APPEND ;
1980
1980
} else {
1981
1981
throw new FeatureNotSupportedException ("not supported other type" );
1982
1982
}
1983
1983
Set <Map .Entry <byte [], List <KeyValue >>> familyCellMap = row .getFamilyMap ().entrySet ();
1984
-
1985
1984
for (Map .Entry <byte [], List <KeyValue >> familyWithCells : familyCellMap ) {
1986
- if (opType == OHOpType . Increment || opType == OHOpType . Append ) {
1985
+ if (opType == INCREMENT || opType == APPEND ) {
1987
1986
indexMap .clear ();
1988
1987
for (int i = 0 ; i < familyWithCells .getValue ().size (); i ++) {
1989
1988
Cell cell = familyWithCells .getValue ().get (i );
@@ -1992,15 +1991,17 @@ public static ObTableBatchOperation buildObTableBatchOperation(List<Mutation> ro
1992
1991
}
1993
1992
for (Map .Entry <String , Integer > entry : indexMap .entrySet ()) {
1994
1993
qualifiers .add (entry .getKey ().getBytes ());
1995
- batch .addTableOperation (buildObTableOperation (familyWithCells .getValue ().get (entry .getValue ()), opType , row .getTTL ()));
1994
+ batch .addTableOperation (buildObTableOperation (
1995
+ familyWithCells .getValue ().get (entry .getValue ()), opType ,
1996
+ row .getTTL ()));
1996
1997
}
1997
1998
} else {
1998
1999
for (KeyValue cell : familyWithCells .getValue ()) {
1999
- batch .addTableOperation (buildObTableOperation (cell , opType , row .getTTL ()));
2000
+ batch .addTableOperation (
2001
+ buildObTableOperation (cell , opType , row .getTTL ()));
2000
2002
}
2001
2003
}
2002
2004
}
2003
-
2004
2005
}
2005
2006
batch .setSamePropertiesNames (true );
2006
2007
return batch ;
@@ -2010,10 +2011,8 @@ private com.alipay.oceanbase.rpc.mutation.Mutation buildMutation(KeyValue kv,
2010
2011
ObTableOperationType operationType ,
2011
2012
boolean isTableGroup , Long TTL ) {
2012
2013
KeyValue .Type kvType = KeyValue .Type .codeToType (kv .getType ());
2013
- switch (operationType ) {
2014
- case INSERT_OR_UPDATE :
2015
- case APPEND :
2016
- case INCREMENT :
2014
+ switch (kvType ) {
2015
+ case Put :
2017
2016
String [] property_columns = V_COLUMNS ;
2018
2017
Object [] property = new Object [] { CellUtil .cloneValue (kv ) };
2019
2018
if (TTL != Long .MAX_VALUE ) {
@@ -2024,36 +2023,29 @@ private com.alipay.oceanbase.rpc.mutation.Mutation buildMutation(KeyValue kv,
2024
2023
ROW_KEY_COLUMNS ,
2025
2024
new Object [] { kv .getRow (), kv .getQualifier (), kv .getTimestamp () },
2026
2025
property_columns , property );
2027
- case DEL :
2028
- switch (kvType ) {
2029
- case Delete :
2030
- return com .alipay .oceanbase .rpc .mutation .Mutation .getInstance (DEL ,
2031
- ROW_KEY_COLUMNS ,
2032
- new Object [] { kv .getRow (), kv .getQualifier (), kv .getTimestamp () },
2033
- null , null );
2034
- case Maximum :
2035
- return com .alipay .oceanbase .rpc .mutation .Mutation .getInstance (DEL ,
2036
- ROW_KEY_COLUMNS ,
2037
- new Object [] { kv .getRow (), null , -kv .getTimestamp () }, null , null );
2038
- case DeleteColumn :
2039
- return com .alipay .oceanbase .rpc .mutation .Mutation .getInstance (DEL ,
2040
- ROW_KEY_COLUMNS ,
2041
- new Object [] { kv .getRow (), kv .getQualifier (), -kv .getTimestamp () },
2042
- null , null );
2043
- case DeleteFamily :
2044
- return com .alipay .oceanbase .rpc .mutation .Mutation .getInstance (DEL ,
2045
- ROW_KEY_COLUMNS ,
2046
- new Object [] { kv .getRow (), isTableGroup ? kv .getQualifier () : null ,
2047
- -kv .getTimestamp () }, null , null );
2048
- case DeleteFamilyVersion :
2049
- return com .alipay .oceanbase .rpc .mutation .Mutation .getInstance (
2050
- DEL ,
2051
- ROW_KEY_COLUMNS ,
2052
- new Object [] { kv .getRow (), isTableGroup ? kv .getQualifier () : null ,
2053
- kv .getTimestamp () }, null , null );
2054
- default :
2055
- throw new IllegalArgumentException ("illegal mutation type " + kvType );
2056
- }
2026
+ case Delete :
2027
+ return com .alipay .oceanbase .rpc .mutation .Mutation .getInstance (DEL , ROW_KEY_COLUMNS ,
2028
+ new Object [] { kv .getRow (), kv .getQualifier (), kv .getTimestamp () }, null , null );
2029
+ case Maximum :
2030
+ return com .alipay .oceanbase .rpc .mutation .Mutation .getInstance (DEL , ROW_KEY_COLUMNS ,
2031
+ new Object [] { kv .getRow (), null , -kv .getTimestamp () }, null , null );
2032
+ case DeleteColumn :
2033
+ return com .alipay .oceanbase .rpc .mutation .Mutation
2034
+ .getInstance (DEL , ROW_KEY_COLUMNS ,
2035
+ new Object [] { kv .getRow (), kv .getQualifier (), -kv .getTimestamp () }, null ,
2036
+ null );
2037
+ case DeleteFamily :
2038
+ return com .alipay .oceanbase .rpc .mutation .Mutation .getInstance (
2039
+ DEL ,
2040
+ ROW_KEY_COLUMNS ,
2041
+ new Object [] { kv .getRow (), isTableGroup ? kv .getQualifier () : null ,
2042
+ -kv .getTimestamp () }, null , null );
2043
+ case DeleteFamilyVersion :
2044
+ return com .alipay .oceanbase .rpc .mutation .Mutation .getInstance (
2045
+ DEL ,
2046
+ ROW_KEY_COLUMNS ,
2047
+ new Object [] { kv .getRow (), isTableGroup ? kv .getQualifier () : null ,
2048
+ kv .getTimestamp () }, null , null );
2057
2049
default :
2058
2050
throw new IllegalArgumentException ("illegal mutation type " + operationType );
2059
2051
}
@@ -2178,48 +2170,35 @@ private BatchOperation buildBatchOperation(String tableName, List<? extends Row>
2178
2170
return batch ;
2179
2171
}
2180
2172
2181
- public static ObTableOperation buildObTableOperation (KeyValue kv , OHOpType operationType ,
2173
+ public static ObTableOperation buildObTableOperation (KeyValue kv ,
2174
+ ObTableOperationType operationType ,
2182
2175
Long TTL ) {
2176
+ KeyValue .Type kvType = KeyValue .Type .codeToType (kv .getType ());
2183
2177
String [] property_columns = V_COLUMNS ;
2184
2178
Object [] property = new Object [] { CellUtil .cloneValue (kv ) };
2185
2179
if (TTL != Long .MAX_VALUE ) {
2186
2180
property_columns = PROPERTY_COLUMNS ;
2187
2181
property = new Object [] { CellUtil .cloneValue (kv ), TTL };
2188
2182
}
2189
- switch (operationType ) {
2183
+ switch (kvType ) {
2190
2184
case Put :
2191
- case Increment :
2192
- case Append :
2193
- ObTableOperationType type ;
2194
- if (operationType == OHOpType .Put ) {
2195
- type = INSERT_OR_UPDATE ;
2196
- } else if (operationType == OHOpType .Increment ) {
2197
- type = INCREMENT ;
2198
- } else {
2199
- type = APPEND ;
2200
- }
2201
2185
return getInstance (
2202
- type ,
2186
+ operationType ,
2203
2187
new Object [] { CellUtil .cloneRow (kv ), CellUtil .cloneQualifier (kv ),
2204
2188
kv .getTimestamp () }, property_columns , property );
2205
2189
case Delete :
2206
- KeyValue .Type delType = KeyValue .Type .codeToType (kv .getTypeByte ());
2207
- if (delType == KeyValue .Type .Delete ) {
2208
- return getInstance (
2209
- DEL ,
2210
- new Object [] { CellUtil .cloneRow (kv ), CellUtil .cloneQualifier (kv ),
2211
- kv .getTimestamp () }, null , null );
2212
- } else if (delType == KeyValue .Type .DeleteColumn ) {
2213
- return getInstance (
2214
- DEL ,
2215
- new Object [] { CellUtil .cloneRow (kv ), CellUtil .cloneQualifier (kv ),
2216
- -kv .getTimestamp () }, null , null );
2217
- } else if (delType == KeyValue .Type .DeleteFamily ) {
2218
- return getInstance (DEL , new Object [] { kv .getRow (), null , -kv .getTimestamp () },
2219
- null , null );
2220
- } else {
2221
- throw new IllegalArgumentException ("illegal delete type " + operationType );
2222
- }
2190
+ return getInstance (
2191
+ DEL ,
2192
+ new Object [] { CellUtil .cloneRow (kv ), CellUtil .cloneQualifier (kv ),
2193
+ kv .getTimestamp () }, null , null );
2194
+ case DeleteColumn :
2195
+ return getInstance (
2196
+ DEL ,
2197
+ new Object [] { CellUtil .cloneRow (kv ), CellUtil .cloneQualifier (kv ),
2198
+ -kv .getTimestamp () }, null , null );
2199
+ case DeleteFamily :
2200
+ return getInstance (DEL , new Object [] { kv .getRow (), null , -kv .getTimestamp () },
2201
+ null , null );
2223
2202
default :
2224
2203
throw new IllegalArgumentException ("illegal mutation type " + operationType );
2225
2204
}
@@ -2331,8 +2310,4 @@ public byte[][] getEndKeys() throws IOException {
2331
2310
public Pair <byte [][], byte [][]> getStartEndKeys () throws IOException {
2332
2311
return new Pair <>(getStartKeys (), getEndKeys ());
2333
2312
}
2334
-
2335
- public enum OHOpType {
2336
- Put , Append , Delete , Increment
2337
- }
2338
2313
}
0 commit comments