First page Back Continue Last page Image

Hbase Code Example

https://www.guru99.com/hbase-shell-general-commands.html

Configuration config = HbaseConfiguration.create();

config.set(“hbase.zookeeper.quorum”, myserver);

config.set(“hbase.zookeeper.property.clientport”, “2181”);

HbaseAdmin.checkHbaseAvailable(config);

Connection connection = ConnectionFactory.createConnection(config);

Table myTable = connection.getTable(TableName.valueOf(“ourfriends”));

byte[ ] myRowKey = Bytes.toBytes(“guy”);

byte[ ] myColFamily = Bytes.toBytes(“info”);

byte[ ] myColName = Bytes.toBytes(“email”);

Get myGet = new Get(myRowKey);

Result myResult = myTable.get(myGet);

byte[ ] myBytes = myResult.getValue(myColFamily, myColName);

String email = Bytes.toString(myBytes);

System.out.println(“Email address=”+email);

Configure a Connection to Data

Configure the data structure of the data to be extracted

Extract Data

Convert Data for Output