Skip to content

Commit 96a1e06

Browse files
support hot only (#341)
Co-authored-by: WeiXinChan <chenwx6728@163.com>
1 parent 21132fc commit 96a1e06

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ public class ObTableQuery extends AbstractPayload {
7979

8080
protected ObKVParams obKVParams = null;
8181

82+
protected ObTableQueryFlag flag = new ObTableQueryFlag(0);
83+
8284
public void adjustStartKey(List<ObObj> key) throws IllegalArgumentException {
8385
List<ObNewRange> keyRanges = getKeyRanges();
8486
for (ObNewRange range : keyRanges) {
@@ -239,6 +241,10 @@ public byte[] encode() {
239241
idx += len;
240242
}
241243

244+
len = Serialization.getNeedBytes(flag.getValue());
245+
System.arraycopy(Serialization.encodeVi64(flag.getValue()), 0, bytes, idx, len);
246+
idx += len;
247+
242248
return bytes;
243249
}
244250

@@ -304,6 +310,10 @@ public Object decode(ByteBuf buf) {
304310
obKVParams = new ObKVParams();
305311
this.obKVParams.decode(buf);
306312
}
313+
314+
long tmpFlag = Serialization.decodeVi64(buf);
315+
this.flag.setValue(tmpFlag);
316+
307317
return this;
308318
}
309319

@@ -349,6 +359,9 @@ public long getPayloadContentSize() {
349359
for (ObTableAggregationSingle obTableAggregationSingle : aggregations) {
350360
contentSize += obTableAggregationSingle.getPayloadSize();
351361
}
362+
363+
contentSize += Serialization.getNeedBytes(flag.getValue());
364+
352365
return contentSize;
353366
}
354367

@@ -579,4 +592,16 @@ public ObKVParams getObKVParams() {
579592
}
580593

581594
public boolean isFTSQuery() { return isFTSQuery; }
595+
596+
public ObTableQueryFlag getFlag() {
597+
return flag;
598+
}
599+
600+
public void setFlag(ObTableQueryFlag flag) {
601+
this.flag = flag;
602+
}
603+
604+
public void setHotOnly(boolean hotOnly) {
605+
this.flag.setHotOnly(hotOnly);
606+
}
582607
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*-
2+
* #%L
3+
* com.oceanbase:obkv-table-client
4+
* %%
5+
* Copyright (C) 2021 - 2025 OceanBase
6+
* %%
7+
* OBKV Table Client Framework is licensed under Mulan PSL v2.
8+
* You can use this software according to the terms and conditions of the Mulan PSL v2.
9+
* You may obtain a copy of Mulan PSL v2 at:
10+
* http://license.coscl.org.cn/MulanPSL2
11+
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
12+
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
13+
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
14+
* See the Mulan PSL v2 for more details.
15+
* #L%
16+
*/
17+
18+
package com.alipay.oceanbase.rpc.protocol.payload.impl.execute.query;
19+
20+
public class ObTableQueryFlag {
21+
private static final int HOT_ONLY = 1 << 0;
22+
23+
private long value = 0;
24+
25+
public ObTableQueryFlag(long value) {
26+
this.value = value;
27+
}
28+
29+
public long getValue() {
30+
return value;
31+
}
32+
33+
public void setValue(long value) {
34+
this.value = value;
35+
}
36+
37+
public boolean isHotOnly() {
38+
return (value & HOT_ONLY) != 0;
39+
}
40+
41+
public void setHotOnly(boolean hotOnly) {
42+
if (hotOnly) {
43+
value = value | HOT_ONLY;
44+
}
45+
}
46+
};

0 commit comments

Comments
 (0)