i have table in hbase has following data in it:
row column+cell 1 column=brid:, timestamp=1470047093100, value=a1234 1 column=custid:, timestamp=1470046713207, value=811411 2 column=brid:, timestamp=1470047231583, value=a6789 2 column=custid:, timestamp=1470047156905, value=848727431
i trying read data spark , print data inside table console. code accomplishing follows:
val conf = new sparkconf().setappname("spark base").setmaster("local[*]") val sc = new sparkcontext(conf) val hbaseconf = hbaseconfiguration.create() hbaseconf.set("hbase.zookeeper.quorum", "127.0.0.1") hbaseconf.set("hbase.zookeeper.property.clientport", "5181") hbaseconf.set(tableinputformat.input_table, "/path/to/custid1") val hbasedata = sc.newapihadooprdd(hbaseconf, classof[tableinputformat], classof[immutablebyteswritable], classof[result]) hbasedata.map(row => bytes.tostring(row._2.getvalue("custid".getbytes(), "brid".getbytes()))).collect().foreach(println) println("number of records found : " + hbasedata.count()) sc.stop()
the output looks this:
null null number of records found : 2
the count correct there 2 records in hbase table. why displaying values null? and, how can print values inside table?
thanks.
row._2.getvalue("custid".getbytes(), "brid".getbytes())
takes parameters column family, qualifier (column name), in case have 2 column families , empty string qualifiers. since custid:bird
not valid column name null returned.
to print try: row._2.getvalue("bird".getbytes(), "".getbytes())
Comments
Post a Comment