@@ -68,6 +68,9 @@ public class OHBufferedMutatorImpl implements BufferedMutator {
68
68
private int rpcTimeout ;
69
69
private int operationTimeout ;
70
70
private static final long OB_VERSION_4_3_5_0 = calcVersion (4 , (short ) 3 , (byte ) 5 , (byte ) 0 );
71
+ private static final long OB_VERSION_4_3_0_0 = calcVersion (4 , (short ) 3 , (byte ) 0 , (byte ) 0 );
72
+ private static final long OB_VERSION_4_2_5_1 = calcVersion (4 , (short ) 2 , (byte ) 5 , (byte ) 1 );
73
+ private static final long OB_VERSION_4_3_4_0 = calcVersion (4 , (short ) 3 , (byte ) 4 , (byte ) 0 );
71
74
72
75
public OHBufferedMutatorImpl (OHConnectionImpl ohConnection , BufferedMutatorParams params ,
73
76
OHTable ohTable ) throws IOException {
@@ -144,16 +147,8 @@ public void mutate(List<? extends Mutation> mutations) throws IOException {
144
147
validateOperation (m );
145
148
toAddSize += m .heapSize ();
146
149
}
147
-
148
- currentAsyncBufferSize .addAndGet (toAddSize );
149
- asyncWriteBuffer .addAll (mutations );
150
-
151
- if (currentAsyncBufferSize .get () > writeBufferSize ) {
152
- batchExecute (false );
153
- }
154
150
} else {
155
- // check if every mutation's family is the same
156
- // check if mutations are the same type
151
+ // version below 4_3_5 need the same type in one bufferedMutator
157
152
for (Mutation m : mutations ) {
158
153
validateOperation (m );
159
154
Class <?> curType = m .getClass ();
@@ -164,11 +159,14 @@ public void mutate(List<? extends Mutation> mutations) throws IOException {
164
159
}
165
160
toAddSize += m .heapSize ();
166
161
}
162
+ }
163
+ currentAsyncBufferSize .addAndGet (toAddSize );
164
+ asyncWriteBuffer .addAll (mutations );
167
165
168
- currentAsyncBufferSize .addAndGet ( toAddSize );
169
- asyncWriteBuffer . addAll ( mutations );
170
-
171
- if ( currentAsyncBufferSize . get () > writeBufferSize ) {
166
+ if ( currentAsyncBufferSize .get () > writeBufferSize ) {
167
+ if ( isBatchSupport ()) {
168
+ batchExecute ( false );
169
+ } else {
172
170
normalExecute (false );
173
171
}
174
172
}
@@ -188,9 +186,17 @@ private void validateOperation(Mutation mt) throws IllegalArgumentException {
188
186
if (mt instanceof Put ) {
189
187
// family empty check is in validatePut
190
188
OHTable .validatePut ((Put ) mt , maxKeyValueSize );
191
- OHTable .checkFamilyViolation (mt .getFamilyMap ().keySet (), true );
189
+ if (isMultiFamilySupport ()) {
190
+ OHTable .checkFamilyViolation (mt .getFamilyMap ().keySet (), true );
191
+ } else {
192
+ OHTable .checkFamilyViolationForOneFamily (mt .getFamilyMap ().keySet ());
193
+ }
192
194
} else {
193
- OHTable .checkFamilyViolation (mt .getFamilyMap ().keySet (), false );
195
+ if (isMultiFamilySupport ()) {
196
+ OHTable .checkFamilyViolation (mt .getFamilyMap ().keySet (), false );
197
+ } else {
198
+ OHTable .checkFamilyViolationForOneFamily (mt .getFamilyMap ().keySet ());
199
+ }
194
200
}
195
201
}
196
202
@@ -394,6 +400,14 @@ boolean isBatchSupport() {
394
400
return OB_VERSION >= OB_VERSION_4_3_5_0 ;
395
401
}
396
402
403
+ /**
404
+ * Only 4_2_5 BP1 - 4_3_0 and after 4_3_4 support multi-cf
405
+ * */
406
+ boolean isMultiFamilySupport () {
407
+ return (OB_VERSION >= OB_VERSION_4_2_5_1 && OB_VERSION < OB_VERSION_4_3_0_0 )
408
+ || (OB_VERSION >= OB_VERSION_4_3_4_0 );
409
+ }
410
+
397
411
/**
398
412
* Force to commit all operations
399
413
* do not care whether the pool is shut down or this BufferedMutator is closed
0 commit comments