@@ -217,19 +217,25 @@ public void decode(ByteBuf buf, ObObj obj) {
217217 }
218218
219219 public static ObTableObjType getTableObjType (ObObj obj ) {
220- ObObjType objType = obj .getMeta ().getType ();
221- ObCollationType objCsType = obj .getMeta ().getCsType ();
222- ObTableObjType tableObjType = objTableTypeMap .get (objType );
223- if (objType == ObObjType .ObVarcharType && objCsType == ObCollationType .CS_TYPE_BINARY ) {
224- tableObjType = ObTableObjType .ObTableVarbinaryType ;
225- } else if (objType == ObObjType .ObExtendType ) {
226- if (obj .isMinObj ()) {
227- tableObjType = ObTableObjType .ObTableMinType ;
228- } else if (obj .isMaxObj ()) {
229- tableObjType = ObTableObjType .ObTableMaxType ;
220+ ObTableObjType tableObjType = null ;
221+ if (obj .getTableObjType () == ObTableInvalidType ) {
222+ ObObjType objType = obj .getMeta ().getType ();
223+ ObCollationType objCsType = obj .getMeta ().getCsType ();
224+ tableObjType = objTableTypeMap .get (objType );
225+ if (objType == ObObjType .ObVarcharType && objCsType == ObCollationType .CS_TYPE_BINARY ) {
226+ tableObjType = ObTableObjType .ObTableVarbinaryType ;
227+ } else if (objType == ObObjType .ObExtendType ) {
228+ if (obj .isMinObj ()) {
229+ tableObjType = ObTableObjType .ObTableMinType ;
230+ } else if (obj .isMaxObj ()) {
231+ tableObjType = ObTableObjType .ObTableMaxType ;
232+ }
233+ } else if (tableObjType == null ) {
234+ throw new IllegalArgumentException ("Cannot get ObTableObjType, invalid ob obj type: " + objType );
230235 }
231- } else if (tableObjType == null ) {
232- throw new IllegalArgumentException ("Cannot get ObTableObjType, invalid ob obj type: " + objType );
236+ obj .setTableObjType (tableObjType );
237+ } else {
238+ tableObjType = obj .getTableObjType ();
233239 }
234240
235241 return tableObjType ;
@@ -305,8 +311,15 @@ public void decode(ByteBuf buf, ObObj obj) {
305311 }
306312
307313 public int getEncodedSize (ObObj obj ) {
308- ObObjType objType = obj .getMeta ().getType ();
309- return DEFAULT_TABLE_OBJ_TYPE_SIZE + objType .getEncodedSize (obj .getValue ());
314+ int encodeSize = 0 ;
315+ if (obj .getEncodeSizeCache () == -1 ) {
316+ ObObjType objType = obj .getMeta ().getType ();
317+ encodeSize = DEFAULT_TABLE_OBJ_TYPE_SIZE + objType .getEncodedSize (obj .getValue ());
318+ obj .setEncodeSizeCache (encodeSize );
319+ } else {
320+ encodeSize = obj .getEncodeSizeCache ();
321+ }
322+ return encodeSize ;
310323 }
311324
312325 public byte [] encodeWithMeta (ObObj obj ) {
0 commit comments