Skip to content

Commit 56dab83

Browse files
committed
revert batch atomic change
1 parent 47e46a3 commit 56dab83

File tree

4 files changed

+11
-19
lines changed

4 files changed

+11
-19
lines changed

src/main/java/com/alipay/oceanbase/rpc/protocol/payload/impl/execute/ObTableBatchOperationRequest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
public class ObTableBatchOperationRequest extends ObTableAbstractOperationRequest {
4343

4444
private ObTableBatchOperation batchOperation;
45-
private boolean batchOperationAsAtomic = true;
45+
private boolean batchOperationAsAtomic = false;
4646

4747
/*
4848
* Get pcode.
@@ -155,6 +155,13 @@ public boolean isBatchOperationAsAtomic() {
155155
return batchOperationAsAtomic;
156156
}
157157

158+
/*
159+
* Set BatchOperation As Atomic.
160+
*/
161+
public void setBatchOperationAsAtomic(boolean batchOperationAsAtomic) {
162+
this.batchOperationAsAtomic = batchOperationAsAtomic;
163+
}
164+
158165
public void setBatchOpReturnOneResult(boolean returnOneResult) {
159166
if (returnOneResult == true) {
160167
this.option_flag.setReturnOneResult(true);

src/main/java/com/alipay/oceanbase/rpc/table/ObTableBatchOpsImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ public void addObTableOperation(ObTableOperationType type, Object[] rowkeys, Str
139139
*/
140140
public List<Object> execute() throws RemotingException, InterruptedException {
141141

142+
request.setBatchOperationAsAtomic(isAtomicOperation());
142143
request.setBatchOpReturnOneResult(isReturnOneResult());
143144
Object result = obTable.execute(request);
144145
checkObTableOperationResult(result);
@@ -172,6 +173,7 @@ public List<Object> execute() throws RemotingException, InterruptedException {
172173
*/
173174
public List<Object> executeWithResult() throws Exception {
174175

176+
request.setBatchOperationAsAtomic(isAtomicOperation());
175177
request.setBatchOpReturnOneResult(isReturnOneResult());
176178
Object result = obTable.execute(request);
177179
checkObTableOperationResult(result);

src/main/java/com/alipay/oceanbase/rpc/table/ObTableClientBatchOpsImpl.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ public Map<Long, ObPair<ObTableParam, List<ObPair<Integer, ObTableOperation>>>>
222222
List<ObTableOperation> operations = batchOperation.getTableOperations();
223223
Map<Long, ObPair<ObTableParam, List<ObPair<Integer, ObTableOperation>>>> partitionOperationsMap = new HashMap<Long, ObPair<ObTableParam, List<ObPair<Integer, ObTableOperation>>>>();
224224

225-
Long firstPartId = null;
226225
for (int i = 0; i < operations.size(); i++) {
227226
ObTableOperation operation = operations.get(i);
228227
ObRowKey rowKeyObject = operation.getEntity().getRowKey();
@@ -238,14 +237,6 @@ public Map<Long, ObPair<ObTableParam, List<ObPair<Integer, ObTableOperation>>>>
238237
} else {
239238
tableObPair = obTableClient.getODPTableWithRowKeyValue(tableName, rowKey, false);
240239
}
241-
if (firstPartId == null) {
242-
firstPartId = tableObPair.getLeft();
243-
} else if (atomicOperation) {
244-
if (!firstPartId.equals(tableObPair.getLeft())) {
245-
throw new IllegalStateException(
246-
"The operations should be atomic but query from different partitions");
247-
}
248-
}
249240
ObPair<ObTableParam, List<ObPair<Integer, ObTableOperation>>> obTableOperations = partitionOperationsMap
250241
.get(tableObPair.getLeft());
251242
if (obTableOperations == null) {
@@ -293,6 +284,7 @@ public void partitionExecute(ObTableOperationResult[] results,
293284
subRequest.setConsistencyLevel(obTableClient.getReadConsistency()
294285
.toObTableConsistencyLevel());
295286
}
287+
subRequest.setBatchOperationAsAtomic(isAtomicOperation());
296288
subRequest.setBatchOpReturnOneResult(isReturnOneResult());
297289
ObTableBatchOperationResult subObTableBatchOperationResult;
298290

src/main/java/com/alipay/oceanbase/rpc/table/ObTableClientLSBatchOpsImpl.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,6 @@ public Map<Long, Map<Long, ObPair<ObTableParam, List<ObPair<Integer, ObTableSing
316316
Map<Long, Map<Long, ObPair<ObTableParam, List<ObPair<Integer, ObTableSingleOp>>>>> lsOperationsMap =
317317
new HashMap();
318318

319-
Long firstPartId = null;
320319
for (int i = 0; i < operations.size(); i++) {
321320
ObTableSingleOp operation = operations.get(i);
322321
List<ObObj> rowkeyObjs = operation.getRowkeyObjs();
@@ -332,14 +331,6 @@ public Map<Long, Map<Long, ObPair<ObTableParam, List<ObPair<Integer, ObTableSing
332331
} else {
333332
tableObPair = obTableClient.getODPTableWithRowKeyValue(tableName, rowKey, false);
334333
}
335-
if(firstPartId == null) {
336-
firstPartId = tableObPair.getLeft();
337-
}
338-
else if(atomicOperation) {
339-
if(!firstPartId.equals(tableObPair.getLeft())) {
340-
throw new IllegalStateException("The operations should be atomic but query from different partitions");
341-
}
342-
}
343334
long lsId = tableObPair.getRight().getLsId();
344335

345336
Map<Long, ObPair<ObTableParam, List<ObPair<Integer, ObTableSingleOp>>>> tabletOperations

0 commit comments

Comments
 (0)