Skip to content

Commit 6f3cda7

Browse files
authored
feat: add flag field serialization support for ObTableSingleOpQuery (#431)
1 parent 8318cb7 commit 6f3cda7

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ public byte[] encode() {
106106
idx += len;
107107
}
108108
}
109+
110+
// 5. encode flag
111+
len = Serialization.getNeedBytes(flag.getValue());
112+
System.arraycopy(Serialization.encodeVi64(flag.getValue()), 0, bytes, idx, len);
113+
idx += len;
114+
109115
return bytes;
110116
}
111117

@@ -151,6 +157,9 @@ public void encode(ObByteBuf buf) {
151157
buf.writeBytes(HTABLE_DUMMY_BYTES);
152158
}
153159
}
160+
161+
// encode flag
162+
Serialization.encodeVi64(buf, flag.getValue());
154163
}
155164

156165
/*
@@ -233,6 +242,10 @@ public long getPayloadContentSize() {
233242
payloadContentSize += HTABLE_DUMMY_BYTES.length;
234243
}
235244
}
245+
246+
// calculate flag size
247+
payloadContentSize += Serialization.getNeedBytes(flag.getValue());
248+
236249
this.payLoadContentSize = payloadContentSize;
237250
}
238251

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ public void addOperation(TableQuery query) throws Exception {
223223
obTableQuery.getSelectColumns(), obTableQuery.getScanOrder(),
224224
obTableQuery.isHbaseQuery(), obTableQuery.gethTableFilter(),
225225
obTableQuery.getObKVParams(), obTableQuery.getFilterString());
226+
singleOpQuery.setFlag(obTableQuery.getFlag());
226227
singleOp.setQuery(singleOpQuery);
227228
singleOp.setSingleOpType(ObTableOperationType.SCAN);
228229
} else {
@@ -243,6 +244,7 @@ public void addOperation(QueryAndMutate queryAndMutate) {
243244
obTableQuery.getSelectColumns(), obTableQuery.getScanOrder(),
244245
obTableQuery.isHbaseQuery(), obTableQuery.gethTableFilter(),
245246
obTableQuery.getObKVParams(), obTableQuery.getFilterString());
247+
singleOpQuery.setFlag(obTableQuery.getFlag());
246248
singleOp.setQuery(singleOpQuery);
247249
singleOp.setQuery(singleOpQuery);
248250
singleOp.setSingleOpType(ObTableOperationType.QUERY_AND_MUTATE);
@@ -859,14 +861,15 @@ private void executeWithRetries(ObTableSingleOpResult[] results,
859861
long costMillis = System.currentTimeMillis() - startExecute;
860862
if (costMillis > runTimeMaxWait) {
861863
errMsg = tableName + " failed to execute operation after retrying " + retryCount
862-
+ " times and it has waited " + costMillis + " ms"
863-
+ " which exceeds runtime max wait timeout " + runTimeMaxWait
864-
+ " ms. Last error Msg:" + "[errCode=" + errCode + "] " + errMsg;
864+
+ " times and it has waited " + costMillis + " ms"
865+
+ " which exceeds runtime max wait timeout " + runTimeMaxWait
866+
+ " ms. Last error Msg:" + "[errCode=" + errCode + "] " + errMsg;
865867
throw new ObTableUnexpectedException(errMsg);
866868
}
867869
boolean allPartitionsSuccess = true;
868870

869-
Iterator<Map.Entry<Long, TabletOperationsMap>> iterator = currentPartitions.entrySet().iterator();
871+
Iterator<Map.Entry<Long, TabletOperationsMap>> iterator = currentPartitions.entrySet()
872+
.iterator();
870873
while (iterator.hasNext()) {
871874
Map.Entry<Long, TabletOperationsMap> currentEntry = iterator.next();
872875
try {
@@ -876,7 +879,8 @@ private void executeWithRetries(ObTableSingleOpResult[] results,
876879
retryCount++;
877880
errCode = ((ObTableNeedFetchMetaException) e).getErrorCode();
878881
errMsg = e.getMessage();
879-
BatchIdxOperationPairList failedOperations = extractOperations(currentEntry, iterator); // reschedule failed and sequent operations
882+
BatchIdxOperationPairList failedOperations = extractOperations(
883+
currentEntry, iterator); // reschedule failed and sequent operations
880884
currentPartitions = prepareOperations(failedOperations);
881885
allPartitionsSuccess = false;
882886
break;

0 commit comments

Comments
 (0)