hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Liu <d...@gopivotal.com>
Subject Does anyone know how to read hbase hdfs file using java api?
Date Sun, 25 May 2014 06:23:57 GMT
Hi experts,

I create a table using this command: create 'test','cf1'.
then put some data there: put 'test','realRow','cf1','realvalue1'
now I am trying to read its data using hdfs java api instead of hbase api:

FileSystem fs = FileSystem.get(URI.create(uri), conf);

 Path path = new Path(


"hdfs://localhost:9000/apps/hbase/data/data/default/test/69c16a187661b1ea8dd904851b9e3bb0/cf1/111c243d1953442f93b4d653690abe20"
);

 FSDataInputStream in = fs.open(path);

 String filename = "111c243d1953442f93b4d653690abe20";

 BufferedOutputStream out = new BufferedOutputStream(

  new FileOutputStream(new File(filename)));

 byte[] b = new byte[1024];

 int numBytes = 0;

 while ((numBytes = in.read(b)) > 0) {

 out.write(b, 0, numBytes);

 System.out.println(Bytes.toString(b));

 }

But data come like this:

[image: Inline image 1]

Is there something wrong with my decoding code?


Thanks

Mime
  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message