diff --git a/pom.xml b/pom.xml
index 2a29f087..5787cce8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -54,7 +54,7 @@
${project.encoding}
UTF-8
1.7.21
-
2.4.0
+ 2.4.1-SNAPSHOT
diff --git a/src/main/java/com/alipay/oceanbase/hbase/OHTable.java b/src/main/java/com/alipay/oceanbase/hbase/OHTable.java
index c4d25fc5..d286eeb2 100644
--- a/src/main/java/com/alipay/oceanbase/hbase/OHTable.java
+++ b/src/main/java/com/alipay/oceanbase/hbase/OHTable.java
@@ -24,9 +24,11 @@
import com.alipay.oceanbase.hbase.metrics.MetricsImporter;
import com.alipay.oceanbase.hbase.metrics.OHMetrics;
import com.alipay.oceanbase.hbase.result.ClientStreamScanner;
+import com.alipay.oceanbase.hbase.result.OHBaseResultCell;
import com.alipay.oceanbase.hbase.util.*;
import com.alipay.oceanbase.rpc.ObGlobal;
import com.alipay.oceanbase.rpc.ObTableClient;
+import com.alipay.oceanbase.rpc.util.ObBytesString;
import com.alipay.oceanbase.rpc.exception.ObTableException;
import com.alipay.oceanbase.rpc.exception.ObTableUnexpectedException;
import com.alipay.oceanbase.rpc.location.model.partition.ObPair;
@@ -594,7 +596,7 @@ public boolean[] existsAll(List gets) throws IOException {
@Override
boolean[] execute() throws IOException {
boolean[] ret = new boolean[gets.size()];
- List newGets = new ArrayList<>();
+ List newGets = new ArrayList<>(gets.size());
// if just checkExistOnly, batch get will not return any result or row count
// therefore we have to set checkExistOnly as false and so the result can be returned
for (Get get : gets) {
@@ -791,16 +793,20 @@ private void innerBatchImpl(final List extends Row> actions, final Object[] re
throw new AssertionError("results.length");
}
}
- BatchError batchError = new BatchError();
obTableClient.setRuntimeBatchExecutor(executePool);
- List resultMapSingleOp = new LinkedList<>();
if (!ObGlobal.isHBaseBatchSupport()) {
+ BatchError batchError = new BatchError();
try {
compatOldServerBatch(actions, results, batchError);
} catch (Exception e) {
throw new IOException(tableNameString + " table occurred unexpected error." , e);
}
- } else if (OHBaseFuncUtils.isAllPut(opType, actions) && OHBaseFuncUtils.isHBasePutPefSupport(obTableClient, enablePutOptimization)) {
+ if (batchError.hasErrors()) {
+ throw batchError.makeException();
+ }
+ return;
+ }
+ if (OHBaseFuncUtils.isAllPut(opType, actions) && OHBaseFuncUtils.isHBasePutPefSupport(obTableClient, enablePutOptimization)) {
// only support Put now
ObHbaseRequest request = buildHbaseRequest(actions, opType);
try {
@@ -813,80 +819,147 @@ private void innerBatchImpl(final List extends Row> actions, final Object[] re
} catch (Exception e) {
throw new IOException(tableNameString + " table occurred unexpected error." , e);
}
- } else {
- String realTableName = getTargetTableName(actions);
- BatchOperation batch = buildBatchOperation(realTableName, actions,
- tableNameString.equals(realTableName), resultMapSingleOp);
- batch.setHbaseOpType(opType);
- BatchOperationResult tmpResults;
- try {
- tmpResults = batch.execute();
- } catch (Exception e) {
- throw new IOException(tableNameString + " table occurred unexpected error.", e);
+ return;
+ }
+ BatchError batchError = new BatchError();
+ boolean pureGetBatch = true;
+ for (Row action : actions) {
+ if (!(action instanceof Get)) {
+ pureGetBatch = false;
+ break;
}
- int index = 0;
- for (int i = 0; i != actions.size(); ++i) {
- if (tmpResults.getResults().get(index) instanceof ObTableException) {
- if (results != null) {
- results[i] = tmpResults.getResults().get(index);
- }
- batchError.add((ObTableException) tmpResults.getResults().get(index), actions.get(i), null);
- } else if (actions.get(i) instanceof Get) {
- if (results != null) {
- // get results have been wrapped in MutationResult, need to fetch it
- if (tmpResults.getResults().get(index) instanceof MutationResult) {
- MutationResult mutationResult = (MutationResult) tmpResults.getResults().get(index);
- ObPayload innerResult = mutationResult.getResult();
- if (innerResult instanceof ObTableSingleOpResult) {
- ObTableSingleOpResult singleOpResult = (ObTableSingleOpResult) innerResult;
- List cells = generateGetResult(singleOpResult);
- results[i] = Result.create(cells);
- } else {
- throw new ObTableUnexpectedException("Unexpected type of result in MutationResult");
- }
+ }
+ List resultMapSingleOp = pureGetBatch ? null
+ : new ArrayList<>(actions.size());
+ String realTableName = getTargetTableName(actions);
+ BatchOperation batch = buildBatchOperation(realTableName, actions,
+ tableNameString.equals(realTableName), resultMapSingleOp);
+ batch.setHbaseOpType(opType);
+ BatchOperationResult tmpResults;
+ try {
+ tmpResults = batch.execute();
+ } catch (Exception e) {
+ throw new IOException(tableNameString + " table occurred unexpected error.", e);
+ }
+ List |