-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathObClusterTableQuery.java
More file actions
298 lines (261 loc) · 8.28 KB
/
ObClusterTableQuery.java
File metadata and controls
298 lines (261 loc) · 8.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
/*-
* #%L
* OBKV Table Client Framework
* %%
* Copyright (C) 2021 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/
package com.alipay.oceanbase.rpc;
import com.alipay.oceanbase.rpc.location.model.partition.Partition;
import com.alipay.oceanbase.rpc.mutation.Row;
import com.alipay.oceanbase.rpc.protocol.payload.impl.ObObj;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.ObReadConsistency;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.ObTableEntityType;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.aggregation.ObTableAggregationType;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.query.ObHTableFilter;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.query.ObTableQuery;
import com.alipay.oceanbase.rpc.stream.ObTableClientQueryAsyncStreamResult;
import com.alipay.oceanbase.rpc.stream.ObTableClientQueryStreamResult;
import com.alipay.oceanbase.rpc.stream.QueryResultSet;
import com.alipay.oceanbase.rpc.table.AbstractTableQuery;
import com.alipay.oceanbase.rpc.table.ObTableClientQueryImpl;
import com.alipay.oceanbase.rpc.table.api.TableQuery;
import java.util.List;
public class ObClusterTableQuery extends AbstractTableQuery {
private final ObTableClientQueryImpl tableClientQuery;
public ObClusterTableQuery(ObTableClientQueryImpl tableQuery) {
this.tableClientQuery = tableQuery;
}
/*
* Add aggregation.
*/
public void addAggregation(ObTableAggregationType aggType, String aggColumn) {
this.tableClientQuery.addAggregation(aggType, aggColumn);
}
/*
* Get table name.
*/
@Override
public String getTableName() {
return tableClientQuery.getTableName();
}
/*
* Get ob table query.
*/
@Override
public ObTableQuery getObTableQuery() {
return tableClientQuery.getObTableQuery();
}
/*
* Get select columns (used by BatchOperation)
*/
public List<String> getSelectColumns() {
return tableClientQuery.getSelectColumns();
}
/*
* Get row key (used by BatchOperation)
*/
public Row getRowKey() {
return tableClientQuery.getRowKey();
}
/*
* Execute.
*/
@Override
public QueryResultSet execute() throws Exception {
return tableClientQuery.execute();
}
/*
* Execute.
*/
@Override
public QueryResultSet asyncExecute() throws Exception {
return tableClientQuery.asyncExecute();
}
/*
* Execute internal.
*/
public ObTableClientQueryStreamResult executeInternal() throws Exception {
return tableClientQuery.executeInternal();
}
/*
* Async execute internal.
*/
public ObTableClientQueryAsyncStreamResult asyncExecuteInternal() throws Exception {
return tableClientQuery.asyncExecuteInternal();
}
/*
* Select.
*/
@Override
public TableQuery select(String... columns) {
tableClientQuery.select(columns);
return this;
}
/*
* 只有 limit query 需要,其他不需要
* @param keys
* @return
*/
@Override
public TableQuery setKeys(String... keys) {
throw new IllegalArgumentException("Not needed");
}
/*
* set row key into query (only used bt BatchOperation)
*/
public TableQuery setRowKey(Row row) throws Exception {
tableClientQuery.setRowKey(row);
return this;
}
/*
* Limit.
*/
@Override
public TableQuery limit(int offset, int limit) {
tableClientQuery.limit(offset, limit);
return this;
}
/**
* Add scan range.
*/
@Override
public TableQuery addScanRange(Object[] start, boolean startEquals, Object[] end,
boolean endEquals) {
tableClientQuery.addScanRange(start, startEquals, end, endEquals);
return this;
}
@Override
public TableQuery addScanRange(Object start, Object end) {
if (start instanceof Partition) {
Long startPartitionId = ((Partition) start).getPartitionId();
Long endPartitionId = ((Partition) end).getPartitionId();
if (!startPartitionId.equals(endPartitionId)) {
throw new IllegalArgumentException(
"The partition id must be the same for start and end partition in scan range");
}
Long startPartId = ((Partition) start).getPartId();
Long endPartId = ((Partition) end).getPartId();
if (!startPartId.equals(endPartId)) {
throw new IllegalArgumentException(
"The logic part id must be the same for start and end partition in scan range");
}
tableClientQuery.setPartId(startPartId);
start = ObObj.getMin();
end = ObObj.getMax();
}
return addScanRange(new Object[] { start }, true, new Object[] { end }, true);
}
/**
* Add scan range starts with.
*/
@Override
public TableQuery addScanRangeStartsWith(Object[] start, boolean startEquals) {
tableClientQuery.addScanRangeStartsWith(start, startEquals);
return this;
}
/**
* Add scan range ends with.
*/
@Override
public TableQuery addScanRangeEndsWith(Object[] end, boolean endEquals) {
tableClientQuery.addScanRangeEndsWith(end, endEquals);
return this;
}
/**
* Scan order.
*/
@Override
public TableQuery scanOrder(boolean forward) {
tableClientQuery.scanOrder(forward);
return this;
}
/**
* Index name.
*/
@Override
public TableQuery indexName(String indexName) {
tableClientQuery.indexName(indexName);
return this;
}
/**
* Filter string.
*/
@Override
public TableQuery filterString(String filterString) {
tableClientQuery.filterString(filterString);
return this;
}
/**
* Set h table filter.
*/
@Override
public TableQuery setHTableFilter(ObHTableFilter obHTableFilter) {
return tableClientQuery.setHTableFilter(obHTableFilter);
}
/**
* Set batch size.
*/
@Override
public TableQuery setBatchSize(int batchSize) {
return tableClientQuery.setBatchSize(batchSize);
}
@Override
public TableQuery setMaxResultSize(long maxResultSize) {
return tableClientQuery.setMaxResultSize(maxResultSize);
}
@Override
public TableQuery setOperationTimeout(long operationTimeout) {
tableClientQuery.setOperationTimeout(operationTimeout);
return this;
}
/**
* Clear.
*/
@Override
public void clear() {
tableClientQuery.clear();
}
/**
* Set entity type.
*/
@Override
public void setEntityType(ObTableEntityType entityType) {
super.setEntityType(entityType);
tableClientQuery.setEntityType(entityType);
}
@Override
public TableQuery setSearchText(String searchText) {
tableClientQuery.setSearchText(searchText);
return this;
}
@Override
public TableQuery setReadConsistency(ObReadConsistency readConsistency) {
// 同时设置父类和内部 tableClientQuery 的 readConsistency
super.setReadConsistency(readConsistency);
tableClientQuery.setReadConsistency(readConsistency);
return this;
}
@Override
public ObReadConsistency getReadConsistency() {
// 返回内部 tableClientQuery 的 readConsistency
return tableClientQuery.getReadConsistency();
}
@Override
public TableQuery setScanRangeColumns(String... columns) {
tableClientQuery.setScanRangeColumns(columns);
return this;
}
public void setAllowDistributeScan(boolean allowDistributeScan) {
tableClientQuery.setAllowDistributeScan(allowDistributeScan);
}
}