Skip to content

Commit

Permalink
param (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
miyuan-ljr authored Nov 21, 2024
1 parent 881aff2 commit 0a840d4
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/main/java/com/alipay/oceanbase/rpc/table/ObHBaseParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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
Expand Down Expand Up @@ -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;
}
Expand All @@ -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";
}

}

0 comments on commit 0a840d4

Please sign in to comment.