Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize obkv_params method #185

Open
wants to merge 1 commit into
base: obkv_params
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -491,13 +491,12 @@ public void setScanRangeColumns(List<String> 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() {
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/com/alipay/oceanbase/rpc/table/ObHBaseParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public byte getValue() {
}
}

public int byteSize;
public paramType pType;

public paramType getType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading