java - 如何使用Java API从hbase中的表中选择特定列

标签 java hadoop hbase

如何使用hbase Java API实现以下命令。

扫描“表名”,{COLUMNS =>'columnFamily:columnQualifier}

最佳答案

docs:

// Sometimes, you won't know the row you're looking for. In this case, you
// use a Scanner. This will give you cursor-like interface to the contents
// of the table.  To set up a Scanner, do like you did above making a Put
// and a Get, create a Scan.  Adorn it with column names, etc.
Scan s = new Scan();
s.addColumn(Bytes.toBytes("myLittleFamily"), Bytes.toBytes("someQualifier"));
ResultScanner scanner = table.getScanner(s);
try {
  // Scanners return Result instances.
  // Now, for the actual iteration. One way is to use a while loop like so:
  for (Result rr = scanner.next(); rr != null; rr = scanner.next()) {
    // print out the row we found and the columns we were looking for
    System.out.println("Found row: " + rr);
  }

  // The other approach is to use a foreach loop. Scanners are iterable!
  // for (Result rr : scanner) {
  //   System.out.println("Found row: " + rr);
  // }
} finally {
  // Make sure you close your scanners when you are done!
  // Thats why we have it inside a try/finally clause
  scanner.close();
}

关于java - 如何使用Java API从hbase中的表中选择特定列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48666910/

相关文章:

java - 使用 Windows 操作系统、Java、Selenium、Jenkins 从 Dockerfile 构建 docker 容器

java - 以编程方式恢复出厂设置的 Android 设备代码

hadoop - java.io.IOException : Type mismatch in value from map: expected org. apache.hadoop.io.IntWritable,收到 org.apache.hadoop.io.Text

hadoop - 查找Hbase中具有空值的行数

java - Gretty/Jetty 无法使用 java 11、Jetty 9.4.14、gretty 加载 WebAppContext

java - 使用 Java 和 Google 的 Firestore 运行查询时没有输出

hadoop - 图像的 Avro 文件类型?

hadoop - hive -为什么删除数据库也会删除外部表的数据

scala - 使用 HBase 的 Spark 作业失败

hadoop - HBase局部扫描怎么办?