Introduction

HFactory Tools is the set of tools that we developed at Ubeeko to ease the development of HBase applications, from backend to frontend. We use it everyday in our projects and it does make modeling of project domains and development much easier.

Concept

While extremely powerful, HBase is a low-level system that only knows byte arrays, requires distributed engineering and NoSQL data modeling expertise.

HFactory solves that problem by offering:

  • HTalk, a developer-friendly HBase DSL able to handle strongly-typed data
  • HFactory Mapper, a macro-based ORM built on top of that DSL delivering entity-oriented modeling and automatic generation of the backend code required to persist these entities
  • HFactory Server, a server that exposes an automatically generated REST API for these entities

The tools

HTalk

At the lowest level, HFactory Tools offers a DSL delivering a high-level, expressive interface to HBase CRUD operations. Contrast HTalk’s strongly-typed single line expression

"user".put("ProjectX", "number", 10).execute

vs raw HBase’s

Table table = connection.getTable(TableName.valueOf("user"));
Put p = new Put(Bytes.toBytes("ProjectX"));
p.add(Bytes.toBytes("d"), Bytes.toBytes("number"),
    Bytes.toBytes(10));
                

HFactory Mapper

Building on HTalk, HFactory Mapper relies on metaprogramming techniques using Scala macros to enable the strongly-typed, high-level modeling of business objects and their manipulation.

All the code required for the serialization a high level entity in an HBase table (column families, fields, byte array conversions) is automatically generated by the HFactory macros.

HFactory Server

Going one step further, HFactory Server leverages the HFactory macro system to generate a REST API that exposes entities in JSON format. From an application developer perspective, this makes developping on HBase as simple as working with MongoDB while retaining the scalability of HBase. The strongly-typed entities can also be used to perform analytics in Spark.

Overall, HFactory Tools delivers full-stacj coverage, on the backend with the Scala DSL and ORM, and on the frontend with JSON entities in a REST API directly usable by web apps.