HBASE-16014 Get and Put constructor argument lists are divergent
Signed-off-by: CHIA-PING TSAI <chia7712@gmail.com>
This commit is contained in:
parent
a41b1852da
commit
9c8f02e4ef
|
@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.client;
|
|||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -130,6 +131,27 @@ public class Get extends Query
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Get operation for the specified row.
|
||||
* @param row
|
||||
* @param rowOffset
|
||||
* @param rowLength
|
||||
*/
|
||||
public Get(byte[] row, int rowOffset, int rowLength) {
|
||||
Mutation.checkRow(row, rowOffset, rowLength);
|
||||
this.row = Bytes.copy(row, rowOffset, rowLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Get operation for the specified row.
|
||||
* @param row
|
||||
*/
|
||||
public Get(ByteBuffer row) {
|
||||
Mutation.checkRow(row);
|
||||
this.row = new byte[row.remaining()];
|
||||
row.get(this.row);
|
||||
}
|
||||
|
||||
public boolean isCheckExistenceOnly() {
|
||||
return checkExistenceOnly;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import static org.junit.Assert.fail;
|
|||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -241,4 +242,15 @@ public class TestGet {
|
|||
assertEquals("my.MockFilter", filters.get(1).getClass().getName());
|
||||
assertTrue(filters.get(2) instanceof KeyOnlyFilter);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRowConstructor() {
|
||||
byte[] row1 = Bytes.toBytes("testRow");
|
||||
byte[] row2 = Bytes.toBytes("testtestRow");
|
||||
ByteBuffer rowBuffer = ByteBuffer.allocate(16);
|
||||
rowBuffer = ByteBuffer.wrap(row1);
|
||||
Get get1 = new Get(rowBuffer);
|
||||
Get get2 = new Get(row2, 4, 7);
|
||||
Assert.assertArrayEquals(get1.getRow(), get2.getRow());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue