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

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

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

Table.existsAll介绍

[英]Test for the existence of columns in the table, as specified by the Gets.

This will return an array of booleans. Each value will be true if the related Get matches one or more keys, false if not.

This is a server-side call so it prevents any data from being transferred to the client.
[中]测试表中是否存在Gets指定的列。
这将返回一系列布尔值。如果相关Get匹配一个或多个键,则每个值都将为true,否则为false。
这是一个服务器端调用,因此它可以防止任何数据传输到客户端。

代码示例

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

  1. @Override
  2. public List<Boolean> existsAll(ByteBuffer table, List<TGet> gets) throws TIOError, TException {
  3. Table htable = getTable(table);
  4. try {
  5. boolean[] exists = htable.existsAll(getsFromThrift(gets));
  6. List<Boolean> result = new ArrayList<>(exists.length);
  7. for (boolean exist : exists) {
  8. result.add(exist);
  9. }
  10. return result;
  11. } catch (IOException e) {
  12. throw getTIOError(e);
  13. } finally {
  14. closeTable(htable);
  15. }
  16. }

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

  1. boolean[] results = table.existsAll(gets);
  2. assertFalse(results[0]);
  3. assertFalse(results[1]);
  4. gets.add(new Get(new byte[] { 0x00 }));
  5. gets.add(new Get(new byte[] { 0x00, 0x00 }));
  6. results = table.existsAll(gets);
  7. assertTrue(results[0]);
  8. assertFalse(results[1]);
  9. gets.add(new Get(new byte[] { (byte) 0xff, (byte) 0xff }));
  10. gets.add(new Get(new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff }));
  11. results = table.existsAll(gets);
  12. assertFalse(results[0]);
  13. assertTrue(results[1]);

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

  1. @Override
  2. public boolean[] exists(List<Get> gets) throws IOException {
  3. return delegate.existsAll(gets);
  4. }

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

  1. @Override
  2. public boolean[] existsAll(List<Get> gets) throws IOException {
  3. return delegate.existsAll(gets);
  4. }

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

  1. @Test
  2. public void testHTableExistsAllBeforeGet() throws Exception {
  3. final byte[] ROW2 = Bytes.add(ROW, Bytes.toBytes("2"));
  4. Table table = TEST_UTIL.createTable(
  5. TableName.valueOf(name.getMethodName()), new byte[][] { FAMILY });
  6. try {
  7. Put put = new Put(ROW);
  8. put.addColumn(FAMILY, QUALIFIER, VALUE);
  9. table.put(put);
  10. put = new Put(ROW2);
  11. put.addColumn(FAMILY, QUALIFIER, VALUE);
  12. table.put(put);
  13. Get get = new Get(ROW);
  14. Get get2 = new Get(ROW2);
  15. ArrayList<Get> getList = new ArrayList(2);
  16. getList.add(get);
  17. getList.add(get2);
  18. boolean[] exists = table.existsAll(getList);
  19. assertEquals(true, exists[0]);
  20. assertEquals(true, exists[1]);
  21. Result[] result = table.get(getList);
  22. assertEquals(false, result[0].isEmpty());
  23. assertTrue(Bytes.equals(VALUE, result[0].getValue(FAMILY, QUALIFIER)));
  24. assertEquals(false, result[1].isEmpty());
  25. assertTrue(Bytes.equals(VALUE, result[1].getValue(FAMILY, QUALIFIER)));
  26. } finally {
  27. table.close();
  28. }
  29. }

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

  1. public void testCheckAndDelete(Connection connection, String tableName) throws IOException {
  2. createTable(thriftAdmin, tableName);
  3. try (Table table = connection.getTable(TableName.valueOf(tableName))){
  4. Get get = new Get(ROW_1);
  5. Result result = table.get(get);
  6. byte[] value1 = result.getValue(FAMILYA, QUALIFIER_1);
  7. byte[] value2 = result.getValue(FAMILYB, QUALIFIER_2);
  8. assertNotNull(value1);
  9. assertTrue(Bytes.equals(VALUE_1, value1));
  10. assertNull(value2);
  11. assertTrue(table.exists(get));
  12. assertEquals(1, table.existsAll(Collections.singletonList(get)).length);
  13. Delete delete = new Delete(ROW_1);
  14. table.checkAndMutate(ROW_1, FAMILYA).qualifier(QUALIFIER_1)
  15. .ifEquals(VALUE_1).thenDelete(delete);
  16. assertFalse(table.exists(get));
  17. Put put = new Put(ROW_1);
  18. put.addColumn(FAMILYA, QUALIFIER_1, VALUE_1);
  19. table.put(put);
  20. assertTrue(table.checkAndMutate(ROW_1, FAMILYA).qualifier(QUALIFIER_1)
  21. .ifEquals(VALUE_1).thenPut(put));
  22. assertFalse(table.checkAndMutate(ROW_1, FAMILYA).qualifier(QUALIFIER_1)
  23. .ifEquals(VALUE_2).thenPut(put));
  24. }
  25. }

代码示例来源:origin: org.apache.phoenix/phoenix-core

  1. @Override
  2. public boolean[] exists(List<Get> gets) throws IOException {
  3. return delegate.existsAll(gets);
  4. }

代码示例来源:origin: org.apache.phoenix/phoenix-core

  1. @Override
  2. public boolean[] existsAll(List<Get> gets) throws IOException {
  3. return delegate.existsAll(gets);
  4. }

代码示例来源:origin: com.aliyun.phoenix/ali-phoenix-core

  1. @Override
  2. public boolean[] existsAll(List<Get> gets) throws IOException {
  3. return delegate.existsAll(gets);
  4. }

代码示例来源:origin: com.aliyun.phoenix/ali-phoenix-core

  1. @Override
  2. public boolean[] exists(List<Get> gets) throws IOException {
  3. return delegate.existsAll(gets);
  4. }

代码示例来源:origin: org.apache.tephra/tephra-hbase-compat-1.1

  1. @Override
  2. public boolean[] existsAll(List<Get> gets) throws IOException {
  3. if (tx == null) {
  4. throw new IOException("Transaction not started");
  5. }
  6. List<Get> transactionalizedGets = new ArrayList<>(gets.size());
  7. for (Get get : gets) {
  8. transactionalizedGets.add(transactionalizeAction(get));
  9. }
  10. return hTable.existsAll(transactionalizedGets);
  11. }

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

  1. public boolean[] existsAll(List<Get> list) throws IOException {
  2. return getTable().existsAll(list);
  3. }

代码示例来源:origin: org.apache.hbase/hbase-thrift

  1. @Override
  2. public List<Boolean> existsAll(ByteBuffer table, List<TGet> gets) throws TIOError, TException {
  3. Table htable = getTable(table);
  4. try {
  5. boolean[] exists = htable.existsAll(getsFromThrift(gets));
  6. List<Boolean> result = new ArrayList<>(exists.length);
  7. for (boolean exist : exists) {
  8. result.add(exist);
  9. }
  10. return result;
  11. } catch (IOException e) {
  12. throw getTIOError(e);
  13. } finally {
  14. closeTable(htable);
  15. }
  16. }

代码示例来源:origin: com.aliyun.hbase/alihbase-thrift

  1. @Override
  2. public List<Boolean> existsAll(ByteBuffer table, List<TGet> gets) throws TIOError, TException {
  3. Table htable = getTable(table);
  4. try {
  5. boolean[] exists = htable.existsAll(getsFromThrift(gets));
  6. List<Boolean> result = new ArrayList<>(exists.length);
  7. for (boolean exist : exists) {
  8. result.add(exist);
  9. }
  10. return result;
  11. } catch (IOException e) {
  12. throw getTIOError(e);
  13. } finally {
  14. closeTable(htable);
  15. }
  16. }

代码示例来源:origin: org.apache.hbase/hbase-server

  1. boolean[] results = table.existsAll(gets);
  2. assertFalse(results[0]);
  3. assertFalse(results[1]);
  4. gets.add(new Get(new byte[] { 0x00 }));
  5. gets.add(new Get(new byte[] { 0x00, 0x00 }));
  6. results = table.existsAll(gets);
  7. assertTrue(results[0]);
  8. assertFalse(results[1]);
  9. gets.add(new Get(new byte[] { (byte) 0xff, (byte) 0xff }));
  10. gets.add(new Get(new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff }));
  11. results = table.existsAll(gets);
  12. assertFalse(results[0]);
  13. assertTrue(results[1]);

代码示例来源:origin: GoogleCloudPlatform/cloud-bigtable-client

  1. boolean[] checks = table.existsAll(gets);
  2. for (Boolean check : checks) {
  3. Assert.assertFalse(check);

代码示例来源:origin: org.apache.hbase/hbase-server

  1. @Test
  2. public void testHTableExistsAllBeforeGet() throws Exception {
  3. final byte[] ROW2 = Bytes.add(ROW, Bytes.toBytes("2"));
  4. Table table = TEST_UTIL.createTable(
  5. TableName.valueOf(name.getMethodName()), new byte[][] { FAMILY });
  6. try {
  7. Put put = new Put(ROW);
  8. put.addColumn(FAMILY, QUALIFIER, VALUE);
  9. table.put(put);
  10. put = new Put(ROW2);
  11. put.addColumn(FAMILY, QUALIFIER, VALUE);
  12. table.put(put);
  13. Get get = new Get(ROW);
  14. Get get2 = new Get(ROW2);
  15. ArrayList<Get> getList = new ArrayList(2);
  16. getList.add(get);
  17. getList.add(get2);
  18. boolean[] exists = table.existsAll(getList);
  19. assertEquals(true, exists[0]);
  20. assertEquals(true, exists[1]);
  21. Result[] result = table.get(getList);
  22. assertEquals(false, result[0].isEmpty());
  23. assertTrue(Bytes.equals(VALUE, result[0].getValue(FAMILY, QUALIFIER)));
  24. assertEquals(false, result[1].isEmpty());
  25. assertTrue(Bytes.equals(VALUE, result[1].getValue(FAMILY, QUALIFIER)));
  26. } finally {
  27. table.close();
  28. }
  29. }

相关文章