Skip to content
hildrum edited this page May 21, 2014 · 6 revisions

The goal of this toolkit is to interact with HBASE from Streams, but we want to ensure that other programs can interact with the HBASE data (via a java program, or via HIVE, or BigSQL, etc) and get predictable ways.

The types supported by HBASE itself are byte[]. In this page, we describe how we convert Streams types to byte arrays, and how we populate streams types from byte[]. We support only a limited set of streams types to ensure we can make these conversions in an understandable way.

Streams to HBASE

Streams type HBASE Type Java snippet note
int64 long n/a Only for the increment operator
int64 byte[] ByteBuffer.allocate(8).putLong(l).toArray
ustring in tuple byte[] myString.getBytes(charset) charset can be supplied as an operator parameter, and defaults to "UTF-8"
ustring, rstring in parameter byte[] myString.getBytes(charset) charset can be supplied as an operator parameter, and defaults to "UTF-8"
rstring in tuple byte[] myString.getBytes("UTF-8")
blob byte[] myBlob.getInputStream().read(toReturn,0,(int)myBlob.getLength());
streams attribute name byte[] attrName.getBytes(charset) See PutRecord sample for this use.

HBASE to Streams

HBASE type Streams type java snippet note
byte[] int64 ByteBuffer.wrap(value).getLong()
byte[] blob ValueFactory.newBlob(value)
byte[] rstring new RString(value)
byte[] ustring new String(value, charset) charset is a character set. It may be passed as an operator parameter
Clone this wiki locally