Get all values of all rows in Hbase using Java

eclipse, get, hbase, java

Solution

For getting all rows with all columns you dont need to make Get call again inside your for loop. Try something like this.

for (Result result = scanner.next(); (result != null); result = scanner.next()) {
    for(KeyValue keyValue : result.list()) {
        System.out.println("Qualifier : " + keyValue.getKeyString() + " : Value : " + Bytes.toString(keyValue.getValue()));
    }
}

Problem

I have the following code.I am trying to retrieve all the rows in the table given the column family. I was able to get all the rows but the output is not what i expected. I get an output which shows the key and time stamp but not the value. Why isn't the values of the rows getting displayed? Please help. The output is given below: ``` keyvalues={Justin/marks:total/1375104216267/Put/vlen=7/ts=0, Justin/marks:markPercentage/ 1375104186783/Put/vlen=4/ts=0} ``` //Code to get all rows from hbase ``` public class GetHbaseData { public static void getdata() throws IOException{ @SuppressWarnings("resource") HTable table = new HTable(HBaseConfiguration.create(), "Student"); Scan scan = new Scan(); scan.setCaching(20); scan.addFamily(Bytes.toBytes("marks")); ResultScanner scanner = table.getScanner(scan); for (Result result = scanner.next(); (result != null); result = scanner.next()) { Get get = new Get(result.getRow()); Result entireRow = table.get(get); System.out.println(entireRow); } } ```

Original source