@@ -1966,24 +1966,23 @@ private ObTableQuery buildObTableQuery(final Get get, Collection<byte[]> columnQ
19661966 public static ObTableBatchOperation buildObTableBatchOperation (List <Mutation > rowList ,
19671967 List <byte []> qualifiers ) {
19681968 ObTableBatchOperation batch = new ObTableBatchOperation ();
1969- OHOpType opType ;
1969+ ObTableOperationType opType ;
19701970 Map <String , Integer > indexMap = new HashMap <>();
19711971 for (Mutation row : rowList ) {
19721972 if (row instanceof Put ) {
1973- opType = OHOpType . Put ;
1973+ opType = INSERT_OR_UPDATE ;
19741974 } else if (row instanceof Delete ) {
1975- opType = OHOpType . Delete ;
1975+ opType = DEL ;
19761976 } else if (row instanceof Increment ) {
1977- opType = OHOpType . Increment ;
1977+ opType = INCREMENT ;
19781978 } else if (row instanceof Append ) {
1979- opType = OHOpType . Append ;
1979+ opType = APPEND ;
19801980 } else {
19811981 throw new FeatureNotSupportedException ("not supported other type" );
19821982 }
19831983 Set <Map .Entry <byte [], List <KeyValue >>> familyCellMap = row .getFamilyMap ().entrySet ();
1984-
19851984 for (Map .Entry <byte [], List <KeyValue >> familyWithCells : familyCellMap ) {
1986- if (opType == OHOpType . Increment || opType == OHOpType . Append ) {
1985+ if (opType == INCREMENT || opType == APPEND ) {
19871986 indexMap .clear ();
19881987 for (int i = 0 ; i < familyWithCells .getValue ().size (); i ++) {
19891988 Cell cell = familyWithCells .getValue ().get (i );
@@ -1992,15 +1991,17 @@ public static ObTableBatchOperation buildObTableBatchOperation(List<Mutation> ro
19921991 }
19931992 for (Map .Entry <String , Integer > entry : indexMap .entrySet ()) {
19941993 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 ()));
19961997 }
19971998 } else {
19981999 for (KeyValue cell : familyWithCells .getValue ()) {
1999- batch .addTableOperation (buildObTableOperation (cell , opType , row .getTTL ()));
2000+ batch .addTableOperation (
2001+ buildObTableOperation (cell , opType , row .getTTL ()));
20002002 }
20012003 }
20022004 }
2003-
20042005 }
20052006 batch .setSamePropertiesNames (true );
20062007 return batch ;
@@ -2010,10 +2011,8 @@ private com.alipay.oceanbase.rpc.mutation.Mutation buildMutation(KeyValue kv,
20102011 ObTableOperationType operationType ,
20112012 boolean isTableGroup , Long TTL ) {
20122013 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 :
20172016 String [] property_columns = V_COLUMNS ;
20182017 Object [] property = new Object [] { CellUtil .cloneValue (kv ) };
20192018 if (TTL != Long .MAX_VALUE ) {
@@ -2024,36 +2023,29 @@ private com.alipay.oceanbase.rpc.mutation.Mutation buildMutation(KeyValue kv,
20242023 ROW_KEY_COLUMNS ,
20252024 new Object [] { kv .getRow (), kv .getQualifier (), kv .getTimestamp () },
20262025 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 );
20572049 default :
20582050 throw new IllegalArgumentException ("illegal mutation type " + operationType );
20592051 }
@@ -2178,48 +2170,35 @@ private BatchOperation buildBatchOperation(String tableName, List<? extends Row>
21782170 return batch ;
21792171 }
21802172
2181- public static ObTableOperation buildObTableOperation (KeyValue kv , OHOpType operationType ,
2173+ public static ObTableOperation buildObTableOperation (KeyValue kv ,
2174+ ObTableOperationType operationType ,
21822175 Long TTL ) {
2176+ KeyValue .Type kvType = KeyValue .Type .codeToType (kv .getType ());
21832177 String [] property_columns = V_COLUMNS ;
21842178 Object [] property = new Object [] { CellUtil .cloneValue (kv ) };
21852179 if (TTL != Long .MAX_VALUE ) {
21862180 property_columns = PROPERTY_COLUMNS ;
21872181 property = new Object [] { CellUtil .cloneValue (kv ), TTL };
21882182 }
2189- switch (operationType ) {
2183+ switch (kvType ) {
21902184 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- }
22012185 return getInstance (
2202- type ,
2186+ operationType ,
22032187 new Object [] { CellUtil .cloneRow (kv ), CellUtil .cloneQualifier (kv ),
22042188 kv .getTimestamp () }, property_columns , property );
22052189 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 );
22232202 default :
22242203 throw new IllegalArgumentException ("illegal mutation type " + operationType );
22252204 }
@@ -2331,8 +2310,4 @@ public byte[][] getEndKeys() throws IOException {
23312310 public Pair <byte [][], byte [][]> getStartEndKeys () throws IOException {
23322311 return new Pair <>(getStartKeys (), getEndKeys ());
23332312 }
2334-
2335- public enum OHOpType {
2336- Put , Append , Delete , Increment
2337- }
23382313}
0 commit comments