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
23 changes: 17 additions & 6 deletions src/main/java/com/alipay/oceanbase/hbase/OHTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -526,15 +526,26 @@ public Object[] batch(List<? extends Row> actions) throws IOException {
@Override
public <R> void batchCallback(List<? extends Row> actions, Object[] results,
Batch.Callback<R> callback) throws IOException,
InterruptedException {
throw new FeatureNotSupportedException("not supported yet'");
InterruptedException {
try {
batch(actions, results);
} finally {
if (results != null) {
for (int i = 0; i < results.length; i++) {
if (!(results[i] instanceof ObTableException)) {
callback.update(null, actions.get(i).getRow(), (R) results[i]);
}
}
}
}
}

@Override
public <R> Object[] batchCallback(List<? extends Row> actions, Batch.Callback<R> callback)
throws IOException,
InterruptedException {
throw new FeatureNotSupportedException("not supported yet'");
public <R> Object[] batchCallback(
final List<? extends Row> actions, final Batch.Callback<R> callback) throws IOException, InterruptedException {
Object[] results = new Object[actions.size()];
batchCallback(actions, results, callback);
return results;
}

public static int compareByteArray(byte[] bt1, byte[] bt2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@

package com.alipay.oceanbase.hbase;

import com.alipay.oceanbase.rpc.mutation.result.MutationResult;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.client.*;
import org.apache.hadoop.hbase.client.coprocessor.Batch;
import org.apache.hadoop.hbase.filter.PrefixFilter;
import org.junit.*;
import org.junit.rules.ExpectedException;
Expand Down Expand Up @@ -146,6 +148,32 @@ public void testMultiColumnFamilyBatch() throws Exception {
result = hTable.get(get);
keyValues = result.raw();
assertEquals(6, keyValues.length);

batchLsit.clear();
final long[] updateCounter = new long[] { 0L };
delete = new Delete(toBytes("Key5"));
delete.deleteColumns(family1, family1_column2);
delete.deleteColumns(family2, family2_column1);
delete.deleteFamily(family3);
batchLsit.add(delete);
for (int i = 0; i < rows; ++i) {
Put put = new Put(toBytes("Key" + i));
put.add(family1, family1_column1, family1_value);
put.add(family1, family1_column2, family1_value);
put.add(family1, family1_column3, family1_value);
put.add(family2, family2_column1, family2_value);
put.add(family2, family2_column2, family2_value);
put.add(family3, family3_column1, family3_value);
batchLsit.add(put);
}
hTable.batchCallback(batchLsit, new Batch.Callback<MutationResult>() {
@Override
public void update(byte[] region, byte[] row, MutationResult result) {
updateCounter[0]++;
}
});
assertEquals(11, updateCounter[0]);

}

@Test
Expand Down