From 0a840d4c7a4aa8e2674f1201e49b6ce990e57d6d Mon Sep 17 00:00:00 2001 From: miyuan-ljr <884244693@qq.com> Date: Thu, 21 Nov 2024 15:44:30 +0800 Subject: [PATCH] param (#222) --- .../oceanbase/rpc/table/ObHBaseParams.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) 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 5777c948..62915168 100644 --- a/src/main/java/com/alipay/oceanbase/rpc/table/ObHBaseParams.java +++ b/src/main/java/com/alipay/oceanbase/rpc/table/ObHBaseParams.java @@ -28,6 +28,7 @@ public class ObHBaseParams extends ObKVParamsBase { boolean allowPartialResults = true; // whether allow partial row return or not boolean isCacheBlock = false; // whether enable server block cache and row cache or not boolean checkExistenceOnly = false; // check the existence only + String hbaseVersion = "1.3.6"; private static final int FLAG_ALLOW_PARTIAL_RESULTS = 1 << 0; private static final int FLAG_IS_CACHE_BLOCK = 1 << 1; @@ -61,6 +62,10 @@ public void setCheckExistenceOnly(boolean checkExistenceOnly) { this.checkExistenceOnly = checkExistenceOnly; } + public void setHbaseVersion(String version) { + this.hbaseVersion = version; + } + public int getCaching() { return caching; } @@ -81,6 +86,10 @@ public boolean isCheckExistenceOnly() { return checkExistenceOnly; } + public String getHbaseVersion() { + return hbaseVersion; + } + // encode all boolean type to one byte public byte[] booleansToByteArray() { byte[] bytes = new byte[1]; // 1 byte for 4 booleans @@ -110,6 +119,9 @@ public byte[] encode() { idx += Serialization.getNeedBytes(callTimeout); System.arraycopy(booleansToByteArray(), 0, bytes, idx, 1); idx += 1; + System.arraycopy(Serialization.encodeVString(hbaseVersion), 0, bytes, idx, + Serialization.getNeedBytes(hbaseVersion)); + idx += Serialization.getNeedBytes(hbaseVersion); return bytes; } @@ -125,19 +137,21 @@ public Object decode(ByteBuf buf) { caching = Serialization.decodeVi32(buf); callTimeout = Serialization.decodeVi32(buf); byteArrayToBooleans(buf); + hbaseVersion = Serialization.decodeVString(buf); return this; } public long getPayloadContentSize() { return 1 + Serialization.getNeedBytes(caching) + Serialization.getNeedBytes(callTimeout) - + 1; // all boolean to one byte + + Serialization.getNeedBytes(hbaseVersion) + 1; // all boolean to one byte } public String toString() { return "ObParams: {\n pType = " + pType + ", \n caching = " + caching + ", \n callTimeout = " + callTimeout + ", \n allowPartialResult = " + allowPartialResults + ", \n isCacheBlock = " + isCacheBlock - + ", \n checkExistenceOnly = " + checkExistenceOnly + "\n}\n"; + + ", \n checkExistenceOnly = " + checkExistenceOnly + + ", \n hbaseVersion = " + hbaseVersion + "\n}\n"; } }