Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -8021,7 +8021,7 @@ public Result append(Append mutate, long nonceGroup, long nonce) throws IOExcept
this.metricsRegion.updateAppend();
}
if (isFlushSize(this.addAndGetGlobalMemstoreSize(size))) requestFlush();
return mutate.isReturnResults() ? Result.create(allKVs) : null;
return mutate.isReturnResults() ? Result.create(allKVs) : Result.EMPTY_RESULT;
}

private void preWALAppend(WALKey walKey, WALEdit walEdits) throws IOException {
Expand Down Expand Up @@ -8261,7 +8261,7 @@ private Result doIncrement(Increment increment, long nonceGroup, long nonce) thr

// Request a cache flush. Do it outside update lock.
if (isFlushSize(this.addAndGetGlobalMemstoreSize(accumulatedResultSize))) requestFlush();
return increment.isReturnResults() ? Result.create(allKVs) : null;
return increment.isReturnResults() ? Result.create(allKVs) : Result.EMPTY_RESULT;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4763,6 +4763,30 @@ public void testRowMutation() throws Exception {
}
}

@Test
public void testBatchAppendWithReturnResultFalse() throws Exception {
LOG.info("Starting testBatchAppendWithReturnResultFalse");
final TableName TABLENAME = TableName.valueOf("testBatchAppend");
Table table = TEST_UTIL.createTable(TABLENAME, FAMILY);
Append append1 = new Append(Bytes.toBytes("row1"));
append1.setReturnResults(false);
append1.add(FAMILY, Bytes.toBytes("f1"), Bytes.toBytes("value1"));
Append append2 = new Append(Bytes.toBytes("row1"));
append2.setReturnResults(false);
append2.add(FAMILY, Bytes.toBytes("f1"), Bytes.toBytes("value2"));
List<Append> appends = new ArrayList<>();
appends.add(append1);
appends.add(append2);
Object[] results = new Object[2];
table.batch(appends, results);
assertTrue(results.length == 2);
for(Object r : results) {
Result result = (Result)r;
assertTrue(result.isEmpty());
}
table.close();
}

@Test
public void testAppend() throws Exception {
LOG.info("Starting testAppend");
Expand All @@ -4778,7 +4802,7 @@ public void testAppend() throws Exception {
a.add(FAMILY, QUALIFIERS[0], v1);
a.add(FAMILY, QUALIFIERS[1], v2);
a.setReturnResults(false);
assertNullResult(t.append(a));
assertEmptyResult(t.append(a));

a = new Append(ROW);
a.add(FAMILY, QUALIFIERS[0], v2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
Expand Down Expand Up @@ -187,6 +190,30 @@ public void testIncrementingInvalidValue() throws Exception {
}
}

@Test
public void testBatchIncrementsWithReturnResultFalse() throws Exception {
LOG.info("Starting testBatchIncrementsWithReturnResultFalse");
final TableName TABLENAME = TableName.valueOf("testBatchAppend");
Table table = TEST_UTIL.createTable(TABLENAME, FAMILY);
Increment inc1 = new Increment(Bytes.toBytes("row2"));
inc1.setReturnResults(false);
inc1.addColumn(FAMILY, Bytes.toBytes("f1"), 1);
Increment inc2 = new Increment(Bytes.toBytes("row2"));
inc2.setReturnResults(false);
inc2.addColumn(FAMILY, Bytes.toBytes("f1"), 1);
List<Increment> incs = new ArrayList<>();
incs.add(inc1);
incs.add(inc2);
Object[] results = new Object[2];
table.batch(incs, results);
assertTrue(results.length == 2);
for(Object r : results) {
Result result = (Result)r;
assertTrue(result.isEmpty());
}
table.close();
}

@Test
public void testIncrementInvalidArguments() throws Exception {
LOG.info("Starting " + this.name.getMethodName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import static org.apache.hadoop.hbase.HBaseTestingUtility.fam2;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

Expand Down Expand Up @@ -131,7 +130,7 @@ public void testAppend() throws IOException {
a.setReturnResults(false);
a.add(fam1, qual1, Bytes.toBytes(v1));
a.add(fam1, qual2, Bytes.toBytes(v2));
assertNull(region.append(a, HConstants.NO_NONCE, HConstants.NO_NONCE));
assertTrue(region.append(a, HConstants.NO_NONCE, HConstants.NO_NONCE).isEmpty());
a = new Append(row);
a.add(fam1, qual1, Bytes.toBytes(v2));
a.add(fam1, qual2, Bytes.toBytes(v1));
Expand All @@ -151,7 +150,7 @@ public void testAppendWithMultipleFamilies() throws IOException {
a.setReturnResults(false);
a.add(fam1, qual1, Bytes.toBytes(v1));
a.add(fam2, qual2, Bytes.toBytes(v2));
assertNull(region.append(a, HConstants.NO_NONCE, HConstants.NO_NONCE));
assertTrue(region.append(a, HConstants.NO_NONCE, HConstants.NO_NONCE).isEmpty());

a = new Append(row);
a.add(fam2, qual2, Bytes.toBytes(v1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package org.apache.hadoop.hbase.regionserver.wal;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import java.io.IOException;

Expand Down Expand Up @@ -220,7 +220,7 @@ public void testIncrementWithReturnResultsSetToFalse() throws Exception {
inc1.setReturnResults(false);
inc1.addColumn(FAMILY, col1, 1);
Result res = region.increment(inc1);
assertNull(res);
assertTrue(res.isEmpty());
}

private Put newPut(Durability durability) {
Expand Down