Database Reference
In-Depth Information
The REST Java client
The Java client API for the REST server is located in the org.apache.hadoop.hbase.
rest.client package. The following is the sample Java client for REST:
package com.ch6;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.rest.client.Client;
import org.apache.hadoop.hbase.rest.client.Cluster;
import org.apache.hadoop.hbase.rest.client.RemoteHTable;
import org.apache.hadoop.hbase.util.Bytes;
public class HBaseRESTCLient {
private static RemoteHTable table;
public static void main(String[] args) throws Exception {
Cluster hbaseCluster = new Cluster();
hbaseCluster.add("localhost", 9999);
// Create Rest client instance and get the connection
Client restClient = new Client(hbaseCluster);
table = new RemoteHTable(restClient, "tab1");
Get get = new Get(Bytes.toBytes("row-3"));
get.addColumn(Bytes.toBytes("cf1"), Bytes.toBytes("greet"));
Result result1 = table.get(get);
System.out.println("Get Results - " + result1);
Scan scan = new Scan();
scan.setStartRow(Bytes.toBytes("row-10"));
scan.setStopRow(Bytes.toBytes("row-15"));
scan.addColumn(Bytes.toBytes("cf1"), Bytes.toBytes("pie"));
 
Search WWH ::




Custom Search