Skip to content

Commit 10ecc2e

Browse files
miyuan-ljrstuBirdFlyJackShi148
authored
Cherry-pick from branch-1.3 (#89)
* hbase support batch (#84) * fix test * Add DeleteFamilyVersion function and corresponding test cases (#85) * add DepentdentFilter and SingleColumnValueExcludeFilter * add singleColumnValueExcludeFilter and DependentColumnFilter; add test cases and optimize bufferedMutator test cases * add single cf timerange setting in Get * single cf setColumnFamilyTimeRange in Get and Scan * optimize code * add DeleteFamilyVersion and test cases * add DeleteFamilyVersion; optimize test cases * add DeleteFamilyVersion test case and pass * format code * delete useless self-defined table * hbase support batchCallBack (#86) * fix test * fix test --------- Co-authored-by: stuBirdFly <84010733+stuBirdFly@users.noreply.github.com> Co-authored-by: Ziyu Shi <57038180+JackShi148@users.noreply.github.com>
1 parent 5fedabf commit 10ecc2e

File tree

8 files changed

+914
-345
lines changed

8 files changed

+914
-345
lines changed

src/main/java/com/alipay/oceanbase/hbase/OHTable.java

Lines changed: 216 additions & 205 deletions
Large diffs are not rendered by default.

src/main/java/com/alipay/oceanbase/hbase/filter/HBaseFilterUtils.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ private static void toParseableByteArray(ByteArrayOutputStream byteStream,
169169

170170
// SingleColumnValueExcludeFilter('cf1','col1',=,'binary:123',true,true)
171171
private static void toParseableByteArray(ByteArrayOutputStream byteStream,
172-
SingleColumnValueExcludeFilter filter) throws IOException {
172+
SingleColumnValueExcludeFilter filter)
173+
throws IOException {
173174
byteStream.write(filter.getClass().getSimpleName().getBytes());
174175
byteStream.write("('".getBytes());
175176
writeBytesWithEscape(byteStream, filter.getFamily());
@@ -329,12 +330,13 @@ private static void toParseableByteArray(ByteArrayOutputStream byteStream, Times
329330
}
330331

331332
// MultiRowRangeFilter('a',true,'b',false,'c',true,'d',false);
332-
private static void toParseableByteArray(ByteArrayOutputStream byteStream, MultiRowRangeFilter filter) throws IOException {
333+
private static void toParseableByteArray(ByteArrayOutputStream byteStream,
334+
MultiRowRangeFilter filter) throws IOException {
333335
byteStream.write(filter.getClass().getSimpleName().getBytes());
334336
byteStream.write('(');
335337

336338
List<MultiRowRangeFilter.RowRange> ranges = filter.getRowRanges();
337-
for (int i = 0; i < ranges.size(); i ++) {
339+
for (int i = 0; i < ranges.size(); i++) {
338340
MultiRowRangeFilter.RowRange range = ranges.get(i);
339341
byteStream.write("'".getBytes());
340342
byteStream.write(range.getStartRow());
@@ -354,7 +356,8 @@ private static void toParseableByteArray(ByteArrayOutputStream byteStream, Multi
354356
}
355357

356358
// InclusiveStopFilter('aaa');
357-
private static void toParseableByteArray(ByteArrayOutputStream byteStream, InclusiveStopFilter filter) throws IOException {
359+
private static void toParseableByteArray(ByteArrayOutputStream byteStream,
360+
InclusiveStopFilter filter) throws IOException {
358361
byteStream.write(filter.getClass().getSimpleName().getBytes());
359362
byteStream.write('(');
360363
byteStream.write('\'');
@@ -364,7 +367,8 @@ private static void toParseableByteArray(ByteArrayOutputStream byteStream, Inclu
364367
}
365368

366369
// ColumnRangeFilter('a',true,'b',false);
367-
private static void toParseableByteArray(ByteArrayOutputStream byteStream, ColumnRangeFilter filter) throws IOException {
370+
private static void toParseableByteArray(ByteArrayOutputStream byteStream,
371+
ColumnRangeFilter filter) throws IOException {
368372
byteStream.write(filter.getClass().getSimpleName().getBytes());
369373
byteStream.write('(');
370374

@@ -382,12 +386,13 @@ private static void toParseableByteArray(ByteArrayOutputStream byteStream, Colum
382386
}
383387

384388
// MultipleColumnPrefixFilter('a','b','d');
385-
private static void toParseableByteArray(ByteArrayOutputStream byteStream, MultipleColumnPrefixFilter filter) throws IOException {
389+
private static void toParseableByteArray(ByteArrayOutputStream byteStream,
390+
MultipleColumnPrefixFilter filter) throws IOException {
386391
byteStream.write(filter.getClass().getSimpleName().getBytes());
387392
byteStream.write('(');
388393

389394
byte[][] ranges = filter.getPrefix();
390-
for (int i = 0; i < ranges.length; i ++) {
395+
for (int i = 0; i < ranges.length; i++) {
391396
byte[] range = ranges[i];
392397
byteStream.write("'".getBytes());
393398
byteStream.write(range);
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.alipay.oceanbase.hbase.util;
2+
3+
import org.apache.hadoop.hbase.ServerName;
4+
import org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException;
5+
import org.apache.hadoop.hbase.client.Row;
6+
7+
import java.util.ArrayList;
8+
import java.util.List;
9+
10+
public class BatchError {
11+
private final List<Throwable> throwables = new ArrayList<Throwable>();
12+
private final List<Row> actions = new ArrayList<Row>();
13+
private final List<String> addresses = new ArrayList<String>();
14+
15+
public synchronized void add(Throwable ex, Row row, ServerName serverName) {
16+
if (row == null) {
17+
throw new IllegalArgumentException("row cannot be null. location=" + serverName);
18+
}
19+
20+
throwables.add(ex);
21+
actions.add(row);
22+
addresses.add(serverName != null ? serverName.toString() : "null");
23+
}
24+
25+
public boolean hasErrors() {
26+
return !throwables.isEmpty();
27+
}
28+
29+
public synchronized RetriesExhaustedWithDetailsException makeException() {
30+
return new RetriesExhaustedWithDetailsException(new ArrayList<Throwable>(throwables),
31+
new ArrayList<Row>(actions), new ArrayList<String>(addresses));
32+
}
33+
34+
public synchronized void clear() {
35+
throwables.clear();
36+
actions.clear();
37+
addresses.clear();
38+
}
39+
}

0 commit comments

Comments
 (0)