Skip to content

Commit 66f1e7b

Browse files
committed
add ObBinlogRowImageType for QueryAndMutateRequest to skip the space of encode
1 parent 1bf4c65 commit 66f1e7b

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.alipay.oceanbase.rpc.protocol.payload.impl.execute;
2+
3+
import java.util.HashMap;
4+
import java.util.Map;
5+
6+
public enum ObBinlogRowImageType {
7+
MINIMAL(0), NOBLOB(1), FULL(2);
8+
private int value;
9+
private static Map<Integer, ObBinlogRowImageType> map = new HashMap<Integer, ObBinlogRowImageType>();
10+
ObBinlogRowImageType(int value) { this.value = value; }
11+
static {
12+
for (ObBinlogRowImageType type : ObBinlogRowImageType.values()) {
13+
map.put(type.value, type);
14+
}
15+
}
16+
17+
/*
18+
* Value of.
19+
*/
20+
public static ObBinlogRowImageType valueOf(int value) {
21+
return map.get(value);
22+
}
23+
24+
/*
25+
* Get value.
26+
*/
27+
public int getValue() {
28+
return value;
29+
}
30+
31+
/*
32+
* Get byte value.
33+
*/
34+
public byte getByteValue() {
35+
return (byte) value;
36+
}
37+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ public void setFlagServerCanRetry(boolean serverCanRetry) {
2121
}
2222

2323
public boolean getFlagServerCanRetry() {
24-
return (this.flags & FLAG_SERVER_CAN_RETRY) == 1;
24+
return (this.flags & FLAG_SERVER_CAN_RETRY) != 0;
2525
}
2626
}

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import com.alipay.oceanbase.rpc.ObGlobal;
2121
import com.alipay.oceanbase.rpc.protocol.payload.Pcodes;
22+
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.ObBinlogRowImageType;
2223
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.ObTableAbstractOperationRequest;
2324
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.ObTableEntityType;
2425
import com.alipay.oceanbase.rpc.util.Serialization;
@@ -32,11 +33,14 @@
3233
table_id_,
3334
partition_id_,
3435
entity_type_,
35-
query_and_mutate_);
36+
query_and_mutate_,
37+
binlog_row_image_type_,
38+
option_flag_);
3639
*
3740
*/
3841
public class ObTableQueryAndMutateRequest extends ObTableAbstractOperationRequest {
3942

43+
private ObBinlogRowImageType type = ObBinlogRowImageType.FULL; // no use for now
4044
private ObTableQueryAndMutate tableQueryAndMutate;
4145

4246
/*
@@ -68,8 +72,8 @@ public byte[] encode() {
6872

6973
// encode ObBinlogRowImageType::FULL (2)
7074
idx += len;
71-
len = Serialization.getNeedBytes(2);
72-
System.arraycopy(Serialization.encodeVi32(2), 0, bytes, idx, len);
75+
len = Serialization.getNeedBytes(type.getValue());
76+
System.arraycopy(Serialization.encodeVi32(type.getValue()), 0, bytes, idx, len);
7377

7478
idx += len;
7579
System.arraycopy(Serialization.encodeI8(option_flag.getByteValue()), 0, bytes, idx, 1);
@@ -107,7 +111,7 @@ public long getPayloadContentSize() {
107111
if (ObGlobal.obVsnMajor() >= 4)
108112
return Serialization.getNeedBytes(credential) + Serialization.getNeedBytes(tableName)
109113
+ Serialization.getNeedBytes(tableId) + 8 + 1
110-
+ tableQueryAndMutate.getPayloadSize() + 1;
114+
+ tableQueryAndMutate.getPayloadSize() + Serialization.getNeedBytes(type.getValue()) + 1;
111115
else
112116
return Serialization.getNeedBytes(credential) + Serialization.getNeedBytes(tableName)
113117
+ Serialization.getNeedBytes(tableId) + Serialization.getNeedBytes(partitionId)

0 commit comments

Comments
 (0)