package client;
// cc GetCloneExample Example application retrieving data from HBase
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.util.Bytes;
import util.HBaseHelper;
public class GetCloneExample {
public static void main(String[] args) throws IOException {
Configuration conf = HBaseConfiguration.create();
HBaseHelper helper = HBaseHelper.getHelper(conf);
if (!helper.existsTable("testtable")) {
helper.createTable("testtable", "colfam1");
}
Connection connection = ConnectionFactory.createConnection(conf);
Table table = connection.getTable(TableName.valueOf("testtable"));
// vv GetCloneExample
Get get1 = new Get(Bytes.toBytes("row1"));
get1.addColumn(Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"));
Get get2 = new Get(get1);
Result result = table.get(get2);
System.out.println("Result : " + result);
// ^^ GetCloneExample
table.close();
connection.close();
helper.close();
}
}