Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A multi-purpose AbstractType that supports many sub types, ordering, and null
Java Shell
Branch: master


Why do we need this library? Several reasons.

    ColumnParent cp = new ColumnParent("cf");
    Column column = new Column();
    column.setName("".getBytes());//InvalidRequestException(why:column name must not be empty)
    column.setValue((byte[])null); //InvalidRequestException(why:Column value is required)

    client.insert(ByteBuffer.wrap("".getBytes()), cp, column, ConsistencyLevel.ONE);
    //InvalidRequestException(why:Key may not be empty)

This is very limiting. We have no method to implement empty strings or null.

It could be said that NotFoundException is the same as null

key  column   value
1    a        4
(1   b       null) <- just dont insert this

Ok fine. Then how does one create a reverse inside to the effect of WHERE b is null?

null      b   ""

You can not have null keys.
You can not have empty keys.

So the only solutions are encoding/escaping nulls.

What about nulls in Integer Long columns? Magic numbers? This gets ugly.

So what is AnyType?

AnyType uses the first byte as type of column. Types are null/int/varint/string/vardecimal/gson
So each column holds it's type information. You could theoretically have different types in the same column across rows.

The Gson type is particularily cool. It serializes any Comparable java object into JSON via the google gson library. The cool thing about this object is it sorts by its java comparable, not its byte value.

There are two type of nulls. Type 0 is the null type. Also each type can have null in the value.


AnyType first sorts by the type. It then sorts by the value.

So this means that data will sort like this.

Integer 5
Integer 6
Long 5

It would have been nice to sort all numerical values together, but this would change the order when adding types.
Something went wrong with that request. Please try again.