Spark RDD 全表扫描Hbase
val sc: SparkContext = Spark.SPARK_CONTEXT //自己构建SparkContext
val configuration: Configuration = HBaseConfiguration.create(sc.hadoopConfiguration)
configuration.set(TableInputFormat.INPUT_TABLE, "hbase://***:***") // **为表名
sc.newAPIHadoopRDD(configuration, classOf[TableInputFormat], classOf[ImmutableBytesWritable], classOf[Result])
.flatMap(res => res._2.rawCells().map(cell => {
val rowid = new String(cell.getRowArray, cell.getRowOffset, cell.getRowLength)
val family = new String(cell.getFamilyArray, cell.getFamilyOffset, cell.getFamilyLength)
val qulifier = new String(cell.getQualifierArray, cell.getQualifierOffset, cell.getQualifierLength)
val value = new String(cell.getValueArray, cell.getValueOffset, cell.getValueLength)
List(rowid, family, qulifier, value).mkString("#")
}))