diff --git a/src/main/java/com/alipay/oceanbase/rpc/protocol/payload/impl/execute/query/ObTableQuery.java b/src/main/java/com/alipay/oceanbase/rpc/protocol/payload/impl/execute/query/ObTableQuery.java index 56bdd2d6..5bac4a26 100644 --- a/src/main/java/com/alipay/oceanbase/rpc/protocol/payload/impl/execute/query/ObTableQuery.java +++ b/src/main/java/com/alipay/oceanbase/rpc/protocol/payload/impl/execute/query/ObTableQuery.java @@ -491,13 +491,12 @@ public void setScanRangeColumns(List scanRangeColumns) { this.scanRangeColumns = scanRangeColumns; } - // This interface is just for OBKV-Hbase - public void setObKVParams(ObKVParams obKVParams) { - if (!(obKVParams.getObParamsBase() instanceof ObHBaseParams)) { - throw new FeatureNotSupportedException("only ObHBaseParams support currently"); + public void setHBaseParams(ObHBaseParams obHBaseParams) { + if (obKVParams == null) { + this.obKVParams = new ObKVParams(); } + this.obKVParams.setObParamsBase(obHBaseParams); this.isHbaseQuery = true; - this.obKVParams = obKVParams; } public ObKVParams getObKVParams() { diff --git a/src/main/java/com/alipay/oceanbase/rpc/table/ObHBaseParams.java b/src/main/java/com/alipay/oceanbase/rpc/table/ObHBaseParams.java index 3bb8b1d6..75fb84f3 100644 --- a/src/main/java/com/alipay/oceanbase/rpc/table/ObHBaseParams.java +++ b/src/main/java/com/alipay/oceanbase/rpc/table/ObHBaseParams.java @@ -33,6 +33,9 @@ public class ObHBaseParams extends ObKVParamsBase { private static final int FLAG_IS_CACHE_BLOCK = 1 << 1; private static final int FLAG_CHECK_EXISTENCE_ONLY = 1 << 2; + private static final int FLAG_BYTE_LENGTH = 1; + private static final int BOOLEAN_BYTE_LENGTH = 1; // all boolean to one byte + public ObHBaseParams() { pType = paramType.HBase; } @@ -61,11 +64,6 @@ public void setCheckExistenceOnly(boolean checkExistenceOnly) { this.checkExistenceOnly = checkExistenceOnly; } - private int getContentSize() { - return 4 + Serialization.getNeedBytes(caching) + Serialization.getNeedBytes(callTimeout) - + 1; - } - public int getCaching() { return caching; } @@ -134,8 +132,9 @@ public Object decode(ByteBuf buf) { } public long getPayloadContentSize() { - return 1 + Serialization.getNeedBytes(caching) + Serialization.getNeedBytes(callTimeout) - + 1; // all boolean to one byte + return FLAG_BYTE_LENGTH + + Serialization.getNeedBytes(caching) + Serialization.getNeedBytes(callTimeout) + + BOOLEAN_BYTE_LENGTH; } public String toString() { diff --git a/src/main/java/com/alipay/oceanbase/rpc/table/ObKVParamsBase.java b/src/main/java/com/alipay/oceanbase/rpc/table/ObKVParamsBase.java index 796e4cf9..9bd1e1b1 100644 --- a/src/main/java/com/alipay/oceanbase/rpc/table/ObKVParamsBase.java +++ b/src/main/java/com/alipay/oceanbase/rpc/table/ObKVParamsBase.java @@ -33,7 +33,6 @@ public byte getValue() { } } - public int byteSize; public paramType pType; public paramType getType() { diff --git a/src/test/java/com/alipay/oceanbase/rpc/hbase/ObHTableOperationRequest.java b/src/test/java/com/alipay/oceanbase/rpc/hbase/ObHTableOperationRequest.java index eb55a8c8..d3297340 100644 --- a/src/test/java/com/alipay/oceanbase/rpc/hbase/ObHTableOperationRequest.java +++ b/src/test/java/com/alipay/oceanbase/rpc/hbase/ObHTableOperationRequest.java @@ -116,9 +116,7 @@ public void setOperationType(ObTableOperationType operationType) { public void setObKVParams(ObTableQuery query) { ObHBaseParams params = new ObHBaseParams(); - ObKVParams obKVParams = new ObKVParams(); - obKVParams.setObParamsBase(params); - query.setObKVParams(obKVParams); + query.setHBaseParams(params); } public ObTableAbstractOperationRequest obTableOperationRequest() { diff --git a/src/test/java/com/alipay/oceanbase/rpc/protocol/payload/impl/execute/query/ObTableQueryPayloadTest.java b/src/test/java/com/alipay/oceanbase/rpc/protocol/payload/impl/execute/query/ObTableQueryPayloadTest.java index 0f7d9e39..c88da692 100644 --- a/src/test/java/com/alipay/oceanbase/rpc/protocol/payload/impl/execute/query/ObTableQueryPayloadTest.java +++ b/src/test/java/com/alipay/oceanbase/rpc/protocol/payload/impl/execute/query/ObTableQueryPayloadTest.java @@ -82,9 +82,7 @@ public void test_ObTableQueryWithHbaseQuery() { ObTableQuery obTableQuery = getObTableQuery(); obTableQuery.sethTableFilter(getObHTableFilter()); ObHBaseParams hBaseParams = new ObHBaseParams(); - ObKVParams kv_prams = new ObKVParams(); - kv_prams.setObParamsBase(hBaseParams); - obTableQuery.setObKVParams(kv_prams); + obTableQuery.setHBaseParams(hBaseParams); byte[] bytes = obTableQuery.encode(); ByteBuf buf = PooledByteBufAllocator.DEFAULT.buffer();