Skip to content
Merged
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
421 changes: 216 additions & 205 deletions src/main/java/com/alipay/oceanbase/hbase/OHTable.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ private static void toParseableByteArray(ByteArrayOutputStream byteStream,

// SingleColumnValueExcludeFilter('cf1','col1',=,'binary:123',true,true)
private static void toParseableByteArray(ByteArrayOutputStream byteStream,
SingleColumnValueExcludeFilter filter) throws IOException {
SingleColumnValueExcludeFilter filter)
throws IOException {
byteStream.write(filter.getClass().getSimpleName().getBytes());
byteStream.write("('".getBytes());
writeBytesWithEscape(byteStream, filter.getFamily());
Expand Down Expand Up @@ -329,12 +330,13 @@ private static void toParseableByteArray(ByteArrayOutputStream byteStream, Times
}

// MultiRowRangeFilter('a',true,'b',false,'c',true,'d',false);
private static void toParseableByteArray(ByteArrayOutputStream byteStream, MultiRowRangeFilter filter) throws IOException {
private static void toParseableByteArray(ByteArrayOutputStream byteStream,
MultiRowRangeFilter filter) throws IOException {
byteStream.write(filter.getClass().getSimpleName().getBytes());
byteStream.write('(');

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

// InclusiveStopFilter('aaa');
private static void toParseableByteArray(ByteArrayOutputStream byteStream, InclusiveStopFilter filter) throws IOException {
private static void toParseableByteArray(ByteArrayOutputStream byteStream,
InclusiveStopFilter filter) throws IOException {
byteStream.write(filter.getClass().getSimpleName().getBytes());
byteStream.write('(');
byteStream.write('\'');
Expand All @@ -364,7 +367,8 @@ private static void toParseableByteArray(ByteArrayOutputStream byteStream, Inclu
}

// ColumnRangeFilter('a',true,'b',false);
private static void toParseableByteArray(ByteArrayOutputStream byteStream, ColumnRangeFilter filter) throws IOException {
private static void toParseableByteArray(ByteArrayOutputStream byteStream,
ColumnRangeFilter filter) throws IOException {
byteStream.write(filter.getClass().getSimpleName().getBytes());
byteStream.write('(');

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

// MultipleColumnPrefixFilter('a','b','d');
private static void toParseableByteArray(ByteArrayOutputStream byteStream, MultipleColumnPrefixFilter filter) throws IOException {
private static void toParseableByteArray(ByteArrayOutputStream byteStream,
MultipleColumnPrefixFilter filter) throws IOException {
byteStream.write(filter.getClass().getSimpleName().getBytes());
byteStream.write('(');

byte[][] ranges = filter.getPrefix();
for (int i = 0; i < ranges.length; i ++) {
for (int i = 0; i < ranges.length; i++) {
byte[] range = ranges[i];
byteStream.write("'".getBytes());
byteStream.write(range);
Expand Down
39 changes: 39 additions & 0 deletions src/main/java/com/alipay/oceanbase/hbase/util/BatchError.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.alipay.oceanbase.hbase.util;

import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException;
import org.apache.hadoop.hbase.client.Row;

import java.util.ArrayList;
import java.util.List;

public class BatchError {
private final List<Throwable> throwables = new ArrayList<Throwable>();
private final List<Row> actions = new ArrayList<Row>();
private final List<String> addresses = new ArrayList<String>();

public synchronized void add(Throwable ex, Row row, ServerName serverName) {
if (row == null) {
throw new IllegalArgumentException("row cannot be null. location=" + serverName);
}

throwables.add(ex);
actions.add(row);
addresses.add(serverName != null ? serverName.toString() : "null");
}

public boolean hasErrors() {
return !throwables.isEmpty();
}

public synchronized RetriesExhaustedWithDetailsException makeException() {
return new RetriesExhaustedWithDetailsException(new ArrayList<Throwable>(throwables),
new ArrayList<Row>(actions), new ArrayList<String>(addresses));
}

public synchronized void clear() {
throwables.clear();
actions.clear();
addresses.clear();
}
}
Loading