本文整理了Java中org.apache.hadoop.hbase.client.Table.get()
方法的一些代码示例,展示了Table.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Table.get()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Table
类名称:Table
方法名:get
[英]Extracts certain cells from the given rows, in batch.
[中]分批从给定行中提取特定单元格。
代码示例来源:origin: apache/hbase
public static RSGroupInfo getRSGroupInfo(Connection connection, byte[] rsGroupName)
throws IOException {
try (Table rsGroupTable = connection.getTable(RSGROUP_TABLE_NAME)){
Result result = rsGroupTable.get(new Get(rsGroupName));
return getRSGroupInfo(result);
}
}
}
代码示例来源:origin: apache/hbase
/**
* Tests that a get on a table throws {@link SocketTimeoutException} when the operation takes
* longer than 'hbase.client.operation.timeout'.
*/
@Test(expected = SocketTimeoutException.class)
public void testGetTimeout() throws Exception {
DELAY_GET = 600;
table.get(new Get(ROW));
}
代码示例来源:origin: apache/hbase
private long doGets(int maxOps, final Table... tables) throws Exception {
int count = 0;
try {
while (count < maxOps) {
Get get = new Get(Bytes.toBytes("row-" + count));
for (final Table table: tables) {
table.get(get);
}
count += tables.length;
}
} catch (RpcThrottlingException e) {
LOG.error("get failed after nRetries=" + count, e);
}
return count;
}
代码示例来源:origin: apache/hbase
/**
* For HADOOP-2579
* @throws IOException
*/
@Test (expected=TableNotFoundException.class)
public void testTableNotFoundExceptionWithoutAnyTables() throws IOException {
TableName tableName = TableName
.valueOf("testTableNotFoundExceptionWithoutAnyTables");
Table ht = TEST_UTIL.getConnection().getTable(tableName);
ht.get(new Get(Bytes.toBytes("e")));
}
代码示例来源:origin: apache/hbase
@Test
public void testTimeRange() throws IOException {
try (Table t = createTable()) {
t.put(new Put(ROW).addColumn(FAMILY, col1, 1000001, value));
t.put(new Put(ROW).addColumn(FAMILY, col1, 1000002, value));
t.put(new Put(ROW).addColumn(FAMILY, col1, 1000003, value));
t.put(new Put(ROW).addColumn(FAMILY, col1, 1000004, value));
t.put(new Put(ROW).addColumn(FAMILY, col1, 1000005, value));
t.put(new Put(ROW).addColumn(FAMILY, col1, 1000006, value));
t.put(new Put(ROW).addColumn(FAMILY, col1, 1000007, value));
t.put(new Put(ROW).addColumn(FAMILY, col1, 1000008, value));
Result r = t.get(new Get(ROW).setMaxVersions(3).setTimeRange(0, 1000005));
assertEquals(0, r.size());
TEST_UTIL.getAdmin().flush(t.getName());
r = t.get(new Get(ROW).setMaxVersions(3).setTimeRange(0, 1000005));
assertEquals(0, r.size());
}
}
代码示例来源:origin: apache/hbase
@Override
public Void run() throws Exception {
Get g = new Get(row1);
g.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL));
try (Connection connection = ConnectionFactory.createConnection(conf);
Table t = connection.getTable(table.getName())) {
Result result = t.get(g);
assertTrue(result.isEmpty());
}
return null;
}
};
代码示例来源:origin: apache/hbase
void verifyEdit(int familyNum, int putNum, Table table) throws IOException {
Result r = table.get(createGet(familyNum, putNum));
byte[] family = FAMILIES[familyNum - 1];
byte[] qf = Bytes.toBytes("q" + familyNum);
byte[] val = Bytes.toBytes("val" + familyNum + "-" + putNum);
assertNotNull(("Missing Put#" + putNum + " for CF# " + familyNum), r.getFamilyMap(family));
assertNotNull(("Missing Put#" + putNum + " for CF# " + familyNum),
r.getFamilyMap(family).get(qf));
assertTrue(("Incorrect value for Put#" + putNum + " for CF# " + familyNum),
Arrays.equals(r.getFamilyMap(family).get(qf), val));
}
代码示例来源:origin: apache/hbase
@Test(expected = RetriesExhaustedException.class)
public void testGetWithIOException() throws Exception {
tableRetry.get(new Get(Bytes.toBytes("row")).addColumn(CF, CQ));
}
代码示例来源:origin: apache/hbase
@Test
public void testPutAndDeleteVersions() throws IOException {
try (Table t = createTable()) {
t.put(new Put(ROW).addColumn(FAMILY, col1, 1000001, value));
t.put(new Put(ROW).addColumn(FAMILY, col1, 1000002, value));
t.put(new Put(ROW).addColumn(FAMILY, col1, 1000003, value));
t.put(new Put(ROW).addColumn(FAMILY, col1, 1000004, value));
t.delete(new Delete(ROW).addColumns(FAMILY, col1, 2000000));
t.put(new Put(ROW).addColumn(FAMILY, col1, 1000000, value));
TEST_UTIL.getAdmin().flush(t.getName());
Result r = t.get(new Get(ROW).setMaxVersions(3));
assertEquals(1, r.size());
assertEquals(1000000, r.rawCells()[0].getTimestamp());
}
}
代码示例来源:origin: apache/hbase
@Test
public void testGetNoResultNoStaleRegionWithReplica() throws Exception {
byte[] b1 = "testGetNoResultNoStaleRegionWithReplica".getBytes();
openRegion(hriSecondary);
try {
// A get works and is not stale
Get g = new Get(b1);
Result r = table.get(g);
Assert.assertFalse(r.isStale());
} finally {
closeRegion(hriSecondary);
}
}
代码示例来源:origin: apache/hbase
public boolean isMergeInProgress() throws IOException {
Get get = new Get(MERGE_OP_ROW);
try (Table table = connection.getTable(tableName)) {
Result res = table.get(get);
return (!res.isEmpty());
}
}
代码示例来源:origin: apache/hbase
private void getOneRowAndAssertAllExist(final Table table) throws IOException {
Get get = new Get(ROWKEY);
Result result = table.get(get);
assertTrue("Column A value should be a",
Bytes.toString(result.getValue(FAMILY, Bytes.toBytes("A"))).equals("a"));
assertTrue("Column B value should be b",
Bytes.toString(result.getValue(FAMILY, Bytes.toBytes("B"))).equals("b"));
assertTrue("Column C value should be c",
Bytes.toString(result.getValue(FAMILY, Bytes.toBytes("C"))).equals("c"));
}
代码示例来源:origin: apache/hbase
@Override
public Void run() throws Exception {
Get g = new Get(row1);
g.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL));
try (Connection connection = ConnectionFactory.createConnection(conf);
Table t = connection.getTable(table.getName())) {
Result result = t.get(g);
assertTrue(!result.isEmpty());
}
return null;
}
};
代码示例来源:origin: apache/hbase
void verifyEdit(int familyNum, int putNum, Table table) throws IOException {
Result r = table.get(createGet(familyNum, putNum));
byte[] family = FAMILIES[familyNum - 1];
byte[] qf = Bytes.toBytes("q" + familyNum);
byte[] val = Bytes.toBytes("val" + familyNum + "-" + putNum);
assertNotNull(("Missing Put#" + putNum + " for CF# " + familyNum), r.getFamilyMap(family));
assertNotNull(("Missing Put#" + putNum + " for CF# " + familyNum),
r.getFamilyMap(family).get(qf));
assertTrue(("Incorrect value for Put#" + putNum + " for CF# " + familyNum),
Arrays.equals(r.getFamilyMap(family).get(qf), val));
}
代码示例来源:origin: apache/hbase
@Test(expected = DoNotRetryIOException.class)
public void testGetWithDoNotRetryIOException() throws Exception {
tableDoNotRetry.get(new Get(Bytes.toBytes("row")).addColumn(CF, CQ));
}
代码示例来源:origin: apache/hbase
@Test
public void testExplicitColum() throws IOException {
try (Table t = createTable()) {
t.put(new Put(ROW).addColumn(FAMILY, col1, value));
t.put(new Put(ROW).addColumn(FAMILY, col1, value));
t.put(new Put(ROW).addColumn(FAMILY, col1, value));
t.put(new Put(ROW).addColumn(FAMILY, col1, value));
t.put(new Put(ROW).addColumn(FAMILY, col2, value));
t.put(new Put(ROW).addColumn(FAMILY, col2, value));
t.put(new Put(ROW).addColumn(FAMILY, col2, value));
t.put(new Put(ROW).addColumn(FAMILY, col2, value));
t.put(new Put(ROW).addColumn(FAMILY, col3, value));
t.put(new Put(ROW).addColumn(FAMILY, col3, value));
t.put(new Put(ROW).addColumn(FAMILY, col3, value));
t.put(new Put(ROW).addColumn(FAMILY, col3, value));
Result r = t.get(new Get(ROW).setMaxVersions(3).addColumn(FAMILY, col2));
assertEquals(3, r.size());
TEST_UTIL.getAdmin().flush(t.getName());
r = t.get(new Get(ROW).setMaxVersions(3).addColumn(FAMILY, col2));
assertEquals(3, r.size());
TEST_UTIL.getAdmin().flush(t.getName());
}
}
代码示例来源:origin: apache/hbase
@Test
public void testUseRegionWithoutReplica() throws Exception {
byte[] b1 = "testUseRegionWithoutReplica".getBytes();
openRegion(hriSecondary);
SlowMeCopro.getPrimaryCdl().set(new CountDownLatch(0));
try {
Get g = new Get(b1);
Result r = table.get(g);
Assert.assertFalse(r.isStale());
} finally {
closeRegion(hriSecondary);
}
}
代码示例来源:origin: apache/hbase
@Override
public Object run() throws Exception {
try(Connection conn = ConnectionFactory.createConnection(conf);
Table t = conn.getTable(TEST_TABLE)) {
return t.get(new Get(TEST_ROW));
}
}
};
代码示例来源:origin: apache/hbase
private void getOneRowAndAssertAllButCExist(final Table table) throws IOException {
Get get = new Get(ROWKEY);
Result result = table.get(get);
assertTrue("Column A value should be a",
Bytes.toString(result.getValue(FAMILY, Bytes.toBytes("A"))).equals("a"));
assertTrue("Column B value should be b",
Bytes.toString(result.getValue(FAMILY, Bytes.toBytes("B"))).equals("b"));
assertTrue("Column C should not exist",
result.getValue(FAMILY, Bytes.toBytes("C")) == null);
}
代码示例来源:origin: apache/hbase
@Test
public void testDisabledWAL() throws Exception {
LOG.info("Writing data to table " + tableName);
Put p = new Put(Bytes.toBytes("row"));
p.addColumn(fam, Bytes.toBytes("qual"), Bytes.toBytes("val"));
table.put(p);
LOG.info("Flushing table " + tableName);
TEST_UTIL.flush(tableName);
LOG.info("Getting data from table " + tableName);
Get get = new Get(Bytes.toBytes("row"));
Result result = table.get(get);
assertNotNull(result.getValue(fam, Bytes.toBytes("qual")));
}
}
内容来源于网络,如有侵权,请联系作者删除!