Skip to content

Commit f8f49ad

Browse files
committed
Revert "opt for ObObj encodeSize and ObTableObjType"
This reverts commit b4df900.
1 parent 416fee2 commit f8f49ad

File tree

2 files changed

+14
-47
lines changed

2 files changed

+14
-47
lines changed

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

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,13 @@
2121
import com.alipay.oceanbase.rpc.util.ObByteBuf;
2222
import com.alipay.oceanbase.rpc.util.ObVString;
2323
import io.netty.buffer.ByteBuf;
24-
import static com.alipay.oceanbase.rpc.protocol.payload.impl.ObTableObjType.ObTableInvalidType;
2524

2625
public class ObObj implements ObSimplePayload {
2726

2827
private static ObObj MAX_OBJECT;
2928
private static ObObj MIN_OBJECT;
3029
private static long MAX_OBJECT_VALUE = -2L;
3130
private static long MIN_OBJECT_VALUE = -3L;
32-
private int encodeSizeCache = -1; // use for cache encodeSize to avoid calculate repeatedly
33-
private ObTableObjType tableObjTypeCache = ObTableInvalidType;
3431

3532
static {
3633
MAX_OBJECT = new ObObj(ObObjType.ObExtendType.getDefaultObjMeta(), MAX_OBJECT_VALUE);
@@ -53,23 +50,6 @@ public ObObj(ObObjMeta meta, Object value) {
5350
setValue(value);
5451
}
5552

56-
public int getEncodeSizeCache() {
57-
return encodeSizeCache;
58-
}
59-
60-
public void setEncodeSizeCache(int encodeSizeCache) {
61-
this.encodeSizeCache = encodeSizeCache;
62-
}
63-
64-
public ObTableObjType getTableObjType() {
65-
return tableObjTypeCache;
66-
}
67-
68-
public void setTableObjType(ObTableObjType tableObjType) {
69-
this.tableObjTypeCache = tableObjType;
70-
}
71-
72-
7353
// 1. 序列化 meta
7454
private ObObjMeta meta;
7555
// 2. 序列化 valueLength 还是 nmb_desc_?

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

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -236,25 +236,19 @@ public void decode(ByteBuf buf, ObObj obj) {
236236
}
237237

238238
public static ObTableObjType getTableObjType(ObObj obj) {
239-
ObTableObjType tableObjType = null;
240-
if (obj.getTableObjType() == ObTableInvalidType) {
241-
ObObjType objType = obj.getMeta().getType();
242-
ObCollationType objCsType = obj.getMeta().getCsType();
243-
tableObjType = objTableTypeMap.get(objType);
244-
if (objType == ObObjType.ObVarcharType && objCsType == ObCollationType.CS_TYPE_BINARY) {
245-
tableObjType = ObTableObjType.ObTableVarbinaryType;
246-
} else if (objType == ObObjType.ObExtendType) {
247-
if (obj.isMinObj()) {
248-
tableObjType = ObTableObjType.ObTableMinType;
249-
} else if (obj.isMaxObj()) {
250-
tableObjType = ObTableObjType.ObTableMaxType;
251-
}
252-
} else if (tableObjType == null) {
253-
throw new IllegalArgumentException("Cannot get ObTableObjType, invalid ob obj type: " + objType);
239+
ObObjType objType = obj.getMeta().getType();
240+
ObCollationType objCsType = obj.getMeta().getCsType();
241+
ObTableObjType tableObjType = objTableTypeMap.get(objType);
242+
if (objType == ObObjType.ObVarcharType && objCsType == ObCollationType.CS_TYPE_BINARY) {
243+
tableObjType = ObTableObjType.ObTableVarbinaryType;
244+
} else if (objType == ObObjType.ObExtendType) {
245+
if (obj.isMinObj()) {
246+
tableObjType = ObTableObjType.ObTableMinType;
247+
} else if (obj.isMaxObj()) {
248+
tableObjType = ObTableObjType.ObTableMaxType;
254249
}
255-
obj.setTableObjType(tableObjType);
256-
} else {
257-
tableObjType = obj.getTableObjType();
250+
} else if (tableObjType == null) {
251+
throw new IllegalArgumentException("Cannot get ObTableObjType, invalid ob obj type: " + objType);
258252
}
259253

260254
return tableObjType;
@@ -337,15 +331,8 @@ public void decode(ByteBuf buf, ObObj obj) {
337331
}
338332

339333
public int getEncodedSize(ObObj obj) {
340-
int encodeSize = 0;
341-
if (obj.getEncodeSizeCache() == -1) {
342-
ObObjType objType = obj.getMeta().getType();
343-
encodeSize = DEFAULT_TABLE_OBJ_TYPE_SIZE + objType.getEncodedSize(obj.getValue());
344-
obj.setEncodeSizeCache(encodeSize);
345-
} else {
346-
encodeSize = obj.getEncodeSizeCache();
347-
}
348-
return encodeSize;
334+
ObObjType objType = obj.getMeta().getType();
335+
return DEFAULT_TABLE_OBJ_TYPE_SIZE + objType.getEncodedSize(obj.getValue());
349336
}
350337

351338
public byte[] encodeWithMeta(ObObj obj) {

0 commit comments

Comments
 (0)