org.apache.hadoop.hbase.client.Table.get()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(240)

本文整理了Java中org.apache.hadoop.hbase.client.Table.get()方法的一些代码示例,展示了Table.get()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Table.get()方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Table
类名称:Table
方法名:get

Table.get介绍

[英]Extracts certain cells from the given rows, in batch.
[中]分批从给定行中提取特定单元格。

代码示例

代码示例来源:origin: apache/hbase

  1. public static RSGroupInfo getRSGroupInfo(Connection connection, byte[] rsGroupName)
  2. throws IOException {
  3. try (Table rsGroupTable = connection.getTable(RSGROUP_TABLE_NAME)){
  4. Result result = rsGroupTable.get(new Get(rsGroupName));
  5. return getRSGroupInfo(result);
  6. }
  7. }
  8. }

代码示例来源:origin: apache/hbase

  1. /**
  2. * Tests that a get on a table throws {@link SocketTimeoutException} when the operation takes
  3. * longer than 'hbase.client.operation.timeout'.
  4. */
  5. @Test(expected = SocketTimeoutException.class)
  6. public void testGetTimeout() throws Exception {
  7. DELAY_GET = 600;
  8. table.get(new Get(ROW));
  9. }

代码示例来源:origin: apache/hbase

  1. private long doGets(int maxOps, final Table... tables) throws Exception {
  2. int count = 0;
  3. try {
  4. while (count < maxOps) {
  5. Get get = new Get(Bytes.toBytes("row-" + count));
  6. for (final Table table: tables) {
  7. table.get(get);
  8. }
  9. count += tables.length;
  10. }
  11. } catch (RpcThrottlingException e) {
  12. LOG.error("get failed after nRetries=" + count, e);
  13. }
  14. return count;
  15. }

代码示例来源:origin: apache/hbase

  1. /**
  2. * For HADOOP-2579
  3. * @throws IOException
  4. */
  5. @Test (expected=TableNotFoundException.class)
  6. public void testTableNotFoundExceptionWithoutAnyTables() throws IOException {
  7. TableName tableName = TableName
  8. .valueOf("testTableNotFoundExceptionWithoutAnyTables");
  9. Table ht = TEST_UTIL.getConnection().getTable(tableName);
  10. ht.get(new Get(Bytes.toBytes("e")));
  11. }

代码示例来源:origin: apache/hbase

  1. @Test
  2. public void testTimeRange() throws IOException {
  3. try (Table t = createTable()) {
  4. t.put(new Put(ROW).addColumn(FAMILY, col1, 1000001, value));
  5. t.put(new Put(ROW).addColumn(FAMILY, col1, 1000002, value));
  6. t.put(new Put(ROW).addColumn(FAMILY, col1, 1000003, value));
  7. t.put(new Put(ROW).addColumn(FAMILY, col1, 1000004, value));
  8. t.put(new Put(ROW).addColumn(FAMILY, col1, 1000005, value));
  9. t.put(new Put(ROW).addColumn(FAMILY, col1, 1000006, value));
  10. t.put(new Put(ROW).addColumn(FAMILY, col1, 1000007, value));
  11. t.put(new Put(ROW).addColumn(FAMILY, col1, 1000008, value));
  12. Result r = t.get(new Get(ROW).setMaxVersions(3).setTimeRange(0, 1000005));
  13. assertEquals(0, r.size());
  14. TEST_UTIL.getAdmin().flush(t.getName());
  15. r = t.get(new Get(ROW).setMaxVersions(3).setTimeRange(0, 1000005));
  16. assertEquals(0, r.size());
  17. }
  18. }

代码示例来源:origin: apache/hbase

  1. @Override
  2. public Void run() throws Exception {
  3. Get g = new Get(row1);
  4. g.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL));
  5. try (Connection connection = ConnectionFactory.createConnection(conf);
  6. Table t = connection.getTable(table.getName())) {
  7. Result result = t.get(g);
  8. assertTrue(result.isEmpty());
  9. }
  10. return null;
  11. }
  12. };

代码示例来源:origin: apache/hbase

  1. void verifyEdit(int familyNum, int putNum, Table table) throws IOException {
  2. Result r = table.get(createGet(familyNum, putNum));
  3. byte[] family = FAMILIES[familyNum - 1];
  4. byte[] qf = Bytes.toBytes("q" + familyNum);
  5. byte[] val = Bytes.toBytes("val" + familyNum + "-" + putNum);
  6. assertNotNull(("Missing Put#" + putNum + " for CF# " + familyNum), r.getFamilyMap(family));
  7. assertNotNull(("Missing Put#" + putNum + " for CF# " + familyNum),
  8. r.getFamilyMap(family).get(qf));
  9. assertTrue(("Incorrect value for Put#" + putNum + " for CF# " + familyNum),
  10. Arrays.equals(r.getFamilyMap(family).get(qf), val));
  11. }

代码示例来源:origin: apache/hbase

  1. @Test(expected = RetriesExhaustedException.class)
  2. public void testGetWithIOException() throws Exception {
  3. tableRetry.get(new Get(Bytes.toBytes("row")).addColumn(CF, CQ));
  4. }

代码示例来源:origin: apache/hbase

  1. @Test
  2. public void testPutAndDeleteVersions() throws IOException {
  3. try (Table t = createTable()) {
  4. t.put(new Put(ROW).addColumn(FAMILY, col1, 1000001, value));
  5. t.put(new Put(ROW).addColumn(FAMILY, col1, 1000002, value));
  6. t.put(new Put(ROW).addColumn(FAMILY, col1, 1000003, value));
  7. t.put(new Put(ROW).addColumn(FAMILY, col1, 1000004, value));
  8. t.delete(new Delete(ROW).addColumns(FAMILY, col1, 2000000));
  9. t.put(new Put(ROW).addColumn(FAMILY, col1, 1000000, value));
  10. TEST_UTIL.getAdmin().flush(t.getName());
  11. Result r = t.get(new Get(ROW).setMaxVersions(3));
  12. assertEquals(1, r.size());
  13. assertEquals(1000000, r.rawCells()[0].getTimestamp());
  14. }
  15. }

代码示例来源:origin: apache/hbase

  1. @Test
  2. public void testGetNoResultNoStaleRegionWithReplica() throws Exception {
  3. byte[] b1 = "testGetNoResultNoStaleRegionWithReplica".getBytes();
  4. openRegion(hriSecondary);
  5. try {
  6. // A get works and is not stale
  7. Get g = new Get(b1);
  8. Result r = table.get(g);
  9. Assert.assertFalse(r.isStale());
  10. } finally {
  11. closeRegion(hriSecondary);
  12. }
  13. }

代码示例来源:origin: apache/hbase

  1. public boolean isMergeInProgress() throws IOException {
  2. Get get = new Get(MERGE_OP_ROW);
  3. try (Table table = connection.getTable(tableName)) {
  4. Result res = table.get(get);
  5. return (!res.isEmpty());
  6. }
  7. }

代码示例来源:origin: apache/hbase

  1. private void getOneRowAndAssertAllExist(final Table table) throws IOException {
  2. Get get = new Get(ROWKEY);
  3. Result result = table.get(get);
  4. assertTrue("Column A value should be a",
  5. Bytes.toString(result.getValue(FAMILY, Bytes.toBytes("A"))).equals("a"));
  6. assertTrue("Column B value should be b",
  7. Bytes.toString(result.getValue(FAMILY, Bytes.toBytes("B"))).equals("b"));
  8. assertTrue("Column C value should be c",
  9. Bytes.toString(result.getValue(FAMILY, Bytes.toBytes("C"))).equals("c"));
  10. }

代码示例来源:origin: apache/hbase

  1. @Override
  2. public Void run() throws Exception {
  3. Get g = new Get(row1);
  4. g.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL));
  5. try (Connection connection = ConnectionFactory.createConnection(conf);
  6. Table t = connection.getTable(table.getName())) {
  7. Result result = t.get(g);
  8. assertTrue(!result.isEmpty());
  9. }
  10. return null;
  11. }
  12. };

代码示例来源:origin: apache/hbase

  1. void verifyEdit(int familyNum, int putNum, Table table) throws IOException {
  2. Result r = table.get(createGet(familyNum, putNum));
  3. byte[] family = FAMILIES[familyNum - 1];
  4. byte[] qf = Bytes.toBytes("q" + familyNum);
  5. byte[] val = Bytes.toBytes("val" + familyNum + "-" + putNum);
  6. assertNotNull(("Missing Put#" + putNum + " for CF# " + familyNum), r.getFamilyMap(family));
  7. assertNotNull(("Missing Put#" + putNum + " for CF# " + familyNum),
  8. r.getFamilyMap(family).get(qf));
  9. assertTrue(("Incorrect value for Put#" + putNum + " for CF# " + familyNum),
  10. Arrays.equals(r.getFamilyMap(family).get(qf), val));
  11. }

代码示例来源:origin: apache/hbase

  1. @Test(expected = DoNotRetryIOException.class)
  2. public void testGetWithDoNotRetryIOException() throws Exception {
  3. tableDoNotRetry.get(new Get(Bytes.toBytes("row")).addColumn(CF, CQ));
  4. }

代码示例来源:origin: apache/hbase

  1. @Test
  2. public void testExplicitColum() throws IOException {
  3. try (Table t = createTable()) {
  4. t.put(new Put(ROW).addColumn(FAMILY, col1, value));
  5. t.put(new Put(ROW).addColumn(FAMILY, col1, value));
  6. t.put(new Put(ROW).addColumn(FAMILY, col1, value));
  7. t.put(new Put(ROW).addColumn(FAMILY, col1, value));
  8. t.put(new Put(ROW).addColumn(FAMILY, col2, value));
  9. t.put(new Put(ROW).addColumn(FAMILY, col2, value));
  10. t.put(new Put(ROW).addColumn(FAMILY, col2, value));
  11. t.put(new Put(ROW).addColumn(FAMILY, col2, value));
  12. t.put(new Put(ROW).addColumn(FAMILY, col3, value));
  13. t.put(new Put(ROW).addColumn(FAMILY, col3, value));
  14. t.put(new Put(ROW).addColumn(FAMILY, col3, value));
  15. t.put(new Put(ROW).addColumn(FAMILY, col3, value));
  16. Result r = t.get(new Get(ROW).setMaxVersions(3).addColumn(FAMILY, col2));
  17. assertEquals(3, r.size());
  18. TEST_UTIL.getAdmin().flush(t.getName());
  19. r = t.get(new Get(ROW).setMaxVersions(3).addColumn(FAMILY, col2));
  20. assertEquals(3, r.size());
  21. TEST_UTIL.getAdmin().flush(t.getName());
  22. }
  23. }

代码示例来源:origin: apache/hbase

  1. @Test
  2. public void testUseRegionWithoutReplica() throws Exception {
  3. byte[] b1 = "testUseRegionWithoutReplica".getBytes();
  4. openRegion(hriSecondary);
  5. SlowMeCopro.getPrimaryCdl().set(new CountDownLatch(0));
  6. try {
  7. Get g = new Get(b1);
  8. Result r = table.get(g);
  9. Assert.assertFalse(r.isStale());
  10. } finally {
  11. closeRegion(hriSecondary);
  12. }
  13. }

代码示例来源:origin: apache/hbase

  1. @Override
  2. public Object run() throws Exception {
  3. try(Connection conn = ConnectionFactory.createConnection(conf);
  4. Table t = conn.getTable(TEST_TABLE)) {
  5. return t.get(new Get(TEST_ROW));
  6. }
  7. }
  8. };

代码示例来源:origin: apache/hbase

  1. private void getOneRowAndAssertAllButCExist(final Table table) throws IOException {
  2. Get get = new Get(ROWKEY);
  3. Result result = table.get(get);
  4. assertTrue("Column A value should be a",
  5. Bytes.toString(result.getValue(FAMILY, Bytes.toBytes("A"))).equals("a"));
  6. assertTrue("Column B value should be b",
  7. Bytes.toString(result.getValue(FAMILY, Bytes.toBytes("B"))).equals("b"));
  8. assertTrue("Column C should not exist",
  9. result.getValue(FAMILY, Bytes.toBytes("C")) == null);
  10. }

代码示例来源:origin: apache/hbase

  1. @Test
  2. public void testDisabledWAL() throws Exception {
  3. LOG.info("Writing data to table " + tableName);
  4. Put p = new Put(Bytes.toBytes("row"));
  5. p.addColumn(fam, Bytes.toBytes("qual"), Bytes.toBytes("val"));
  6. table.put(p);
  7. LOG.info("Flushing table " + tableName);
  8. TEST_UTIL.flush(tableName);
  9. LOG.info("Getting data from table " + tableName);
  10. Get get = new Get(Bytes.toBytes("row"));
  11. Result result = table.get(get);
  12. assertNotNull(result.getValue(fam, Bytes.toBytes("qual")));
  13. }
  14. }

相关文章