Details
Description
By design, a value in HBase is an opaque and atomic byte array. In theory, any arbitrary type can potentially be represented in terms of such unstructured yet indivisible units. However, as the complexity of the type increases, so does the need to access it in parts rather than in whole. That way, one can update parts of a value without reading the whole first. This calls for transparency in the type of data being accessed.
To that end, we introduce here a simple object model where each part maps to a HTable column and value thereof. Specifically, we define a ColumnObject interface that denotes an arbitrary type comprising properties, where each property is a <name, value> tuple of byte arrays. In essence, each property maps to a distinct HBase KeyValue. In particular, the property's name maps to a column, prefixed by the qualifier and the object's identifier (assumed to be unique within a column family), and the property's value maps to the KeyValue#getValue() of the corresponding column. Furthermore, the ColumnObject is marked as a RandomAccess type to underscore the fact that its properties can be accessed in and of themselves.
For starters, we provide three concrete objects - a ColumnMap, ColumnList and ColumnSet that implement the Map, List and Set interfaces respectively. The ColumnMap treats each Map.Entry as an object property, the ColumnList stores each element against its ordinal position, and the ColumnSet considers each element as the property name (as well as its value). For the sake of convenience, we also define extensions to the Get, Put, Delete and Result classes that are aware of and know how to deal with such ColumnObject types.