Slim3 Datastore

Slim3 Datastore is a type-safe thin wrapper of Datastore Low level API. Low level API is faster and easier to learn than JDO/JPA, because it is specialized for Bigtable.

A type-safe query of Slim3 is as follows:
EmployeeMeta e = EmployeeMeta.get();
List<Employee> list = Datastore.query(e)
    .filter(e.salary.greaterThan(5000), e.job.equal("ANALYST"))
    .sort(e.salary.asc)
    .asList();
A meta data of model like EmployeeMeta is created by Annotation Processing Tool automatically.

An equivalent JDO query is as follows:
List<Employee> list = null;
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
    Query query = pm.newQuery(Employee.class);
    query.setFilter("salary > :salary && job == :job");
    query.setOrdering("salary asc");
    list = (List<Employee>) query.execute(5000, "ANALYST");
} finally {
    pm.close();
}
return list;

If you use a query based on string, a compiler can not report an error when refactoring the property name.
If you use a type-safe query, when you rename "salary" property, a compiler will tell you "salary" no longer exists, because the meta data of the model is recreated by Annotation Processing Tool when refactoring.

Slim3 Datastore creates mapping logics between a entity and a model as the source code in the meta data of the model when compiling. The following code is a part of BarMeta:
@Override
public Bar entityToModel(Entity entity) {
    Bar model = new Bar();
    model.setKey(entity.getKey());
    model.setSortValue((String) entity.getProperty("sortValue"));
    return model;
}

@Override
public Entity modelToEntity(Object model) {
    Bar m = (Bar) model;
    Entity entity = null;
    if (m.getKey() != null) {
        entity = new Entity(m.getKey());
    } else {
        entity = new Entity("Bar");
    }
    entity.setProperty("sortValue", m.getSortValue());
    return entity;
}

Slim3 Datastore does not need runtime reflection for mapping between a entity and a model, so Slim3 Datastore is faster than JDO.
To retrieve 10,000 simple entities, Slim3 takes around 4,000 millis, JDO takes around 12,000 millis.
See online demonstration.

This reference describes the Slim3 Datastore API. It has the following sections: