Skip to content

Commit e3120f7

Browse files
committed
Optimize obkv_params method
1 parent cb92eca commit e3120f7

File tree

4 files changed

+11
-16
lines changed

4 files changed

+11
-16
lines changed

src/main/java/com/alipay/oceanbase/rpc/protocol/payload/impl/execute/query/ObTableQuery.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -491,13 +491,12 @@ public void setScanRangeColumns(List<String> scanRangeColumns) {
491491
this.scanRangeColumns = scanRangeColumns;
492492
}
493493

494-
// This interface is just for OBKV-Hbase
495-
public void setObKVParams(ObKVParams obKVParams) {
496-
if (!(obKVParams.getObParamsBase() instanceof ObHBaseParams)) {
497-
throw new FeatureNotSupportedException("only ObHBaseParams support currently");
494+
public void setHBaseParams(ObHBaseParams obHBaseParams) {
495+
if (obKVParams == null) {
496+
this.obKVParams = new ObKVParams();
498497
}
498+
this.obKVParams.setObParamsBase(obHBaseParams);
499499
this.isHbaseQuery = true;
500-
this.obKVParams = obKVParams;
501500
}
502501

503502
public ObKVParams getObKVParams() {

src/main/java/com/alipay/oceanbase/rpc/table/ObHBaseParams.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public class ObHBaseParams extends ObKVParamsBase {
3333
private static final int FLAG_IS_CACHE_BLOCK = 1 << 1;
3434
private static final int FLAG_CHECK_EXISTENCE_ONLY = 1 << 2;
3535

36+
private static final int FLAG_BYTE_LENGTH = 1;
37+
private static final int BOOLEAN_BYTE_LENGTH = 1; // all boolean to one byte
38+
3639
public ObHBaseParams() {
3740
pType = paramType.HBase;
3841
}
@@ -61,11 +64,6 @@ public void setCheckExistenceOnly(boolean checkExistenceOnly) {
6164
this.checkExistenceOnly = checkExistenceOnly;
6265
}
6366

64-
private int getContentSize() {
65-
return 4 + Serialization.getNeedBytes(caching) + Serialization.getNeedBytes(callTimeout)
66-
+ 1;
67-
}
68-
6967
public int getCaching() {
7068
return caching;
7169
}
@@ -134,8 +132,9 @@ public Object decode(ByteBuf buf) {
134132
}
135133

136134
public long getPayloadContentSize() {
137-
return 1 + Serialization.getNeedBytes(caching) + Serialization.getNeedBytes(callTimeout)
138-
+ 1; // all boolean to one byte
135+
return FLAG_BYTE_LENGTH
136+
+ Serialization.getNeedBytes(caching) + Serialization.getNeedBytes(callTimeout)
137+
+ BOOLEAN_BYTE_LENGTH;
139138
}
140139

141140
public String toString() {

src/main/java/com/alipay/oceanbase/rpc/table/ObKVParamsBase.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public byte getValue() {
3333
}
3434
}
3535

36-
public int byteSize;
3736
public paramType pType;
3837

3938
public paramType getType() {

src/test/java/com/alipay/oceanbase/rpc/hbase/ObHTableOperationRequest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ public void setOperationType(ObTableOperationType operationType) {
116116

117117
public void setObKVParams(ObTableQuery query) {
118118
ObHBaseParams params = new ObHBaseParams();
119-
ObKVParams obKVParams = new ObKVParams();
120-
obKVParams.setObParamsBase(params);
121-
query.setObKVParams(obKVParams);
119+
query.setHBaseParams(params);
122120
}
123121

124122
public ObTableAbstractOperationRequest obTableOperationRequest() {

0 commit comments

Comments
 (0)