Skip to content

Commit a473887

Browse files
committed
add time range map
1 parent 1381fa5 commit a473887

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

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

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@
1717

1818
package com.alipay.oceanbase.rpc.table;
1919

20+
import com.alipay.oceanbase.rpc.util.ObBytesString;
2021
import com.alipay.oceanbase.rpc.util.Serialization;
2122
import io.netty.buffer.ByteBuf;
23+
import jdk.internal.net.http.common.Pair;
24+
25+
import java.util.ArrayList;
26+
import java.util.List;
2227

2328
import static com.alipay.oceanbase.rpc.util.Serialization.encodeObUniVersionHeader;
2429

@@ -32,6 +37,8 @@ public class ObHBaseParams extends ObKVParamsBase {
3237
private static final int FLAG_ALLOW_PARTIAL_RESULTS = 1 << 0;
3338
private static final int FLAG_IS_CACHE_BLOCK = 1 << 1;
3439
private static final int FLAG_CHECK_EXISTENCE_ONLY = 1 << 2;
40+
List<Pair<ObBytesString, Pair<Long, Long>>> timeRangeMap = new ArrayList<>();
41+
3542

3643
public ObHBaseParams() {
3744
pType = paramType.HBase;
@@ -111,6 +118,21 @@ public byte[] encode() {
111118
System.arraycopy(booleansToByteArray(), 0, bytes, idx, 1);
112119
idx += 1;
113120

121+
int len = Serialization.getNeedBytes(timeRangeMap.size());
122+
System.arraycopy(Serialization.encodeVi64(timeRangeMap.size()), 0, bytes, idx, len);
123+
idx += len;
124+
for (Pair<ObBytesString, Pair<Long, Long>> timeRange : timeRangeMap) {
125+
len = Serialization.getNeedBytes(timeRange.first);
126+
System.arraycopy(Serialization.encodeBytesString(timeRange.first), 0, bytes, idx, len);
127+
idx += len;
128+
len = Serialization.getNeedBytes(timeRange.second.first);
129+
System.arraycopy(Serialization.encodeVi64(timeRange.second.first), 0, bytes, idx, len);
130+
idx += len;
131+
len = Serialization.getNeedBytes(timeRange.second.second);
132+
System.arraycopy(Serialization.encodeVi64(timeRange.second.second), 0, bytes, idx, len);
133+
idx += len;
134+
}
135+
114136
return bytes;
115137
}
116138

@@ -125,6 +147,11 @@ public Object decode(ByteBuf buf) {
125147
caching = Serialization.decodeVi32(buf);
126148
callTimeout = Serialization.decodeVi32(buf);
127149
byteArrayToBooleans(buf);
150+
long size = Serialization.decodeVi64(buf);
151+
this.timeRangeMap = new ArrayList<>((int) size);
152+
for (int i = 0; i < size; i++) {
153+
this.timeRangeMap.add(new Pair<>(Serialization.decodeBytesString(buf), new Pair<>(Serialization.decodeVi64(buf), Serialization.decodeVi64(buf))));
154+
}
128155
return this;
129156
}
130157

@@ -137,7 +164,7 @@ public String toString() {
137164
return "ObParams: {\n pType = " + pType + ", \n caching = " + caching
138165
+ ", \n callTimeout = " + callTimeout + ", \n allowPartialResult = "
139166
+ allowPartialResults + ", \n isCacheBlock = " + isCacheBlock
140-
+ ", \n checkExistenceOnly = " + checkExistenceOnly + "\n}\n";
167+
+ ", \n checkExistenceOnly = " + checkExistenceOnly + ", \n timeRangeMap = " + timeRangeMap + "\n}\n";
141168
}
142169

143170
}

0 commit comments

Comments
 (0)