Search in sources :

Example 1 with RethinkDBResult

use of org.apache.gora.rethinkdb.query.RethinkDBResult in project gora by apache.

the class RethinkDBStore method execute.

/**
 * {@inheritDoc}
 */
@Override
public Result<K, T> execute(Query<K, T> query) throws GoraException {
    String[] fields = getFieldsToQuery(query.getFields());
    RethinkDBQuery dataStoreQuery;
    if (query instanceof RethinkDBQuery) {
        dataStoreQuery = ((RethinkDBQuery) query);
    } else {
        dataStoreQuery = (RethinkDBQuery) ((PartitionQueryImpl<K, T>) query).getBaseQuery();
    }
    dataStoreQuery.populateRethinkDBQuery(rethinkDBMapping, rethinkDBStoreParameters, fields, getFields());
    try {
        ReqlExpr reqlExpr = dataStoreQuery.getRethinkDBDbQuery();
        com.rethinkdb.net.Result<MapObject> result = reqlExpr.run(connection, MapObject.class);
        return new RethinkDBResult<>(this, query, result);
    } catch (Exception e) {
        throw new GoraException(e);
    }
}
Also used : GoraException(org.apache.gora.util.GoraException) PartitionQueryImpl(org.apache.gora.query.impl.PartitionQueryImpl) RethinkDBQuery(org.apache.gora.rethinkdb.query.RethinkDBQuery) RethinkDBResult(org.apache.gora.rethinkdb.query.RethinkDBResult) MapObject(com.rethinkdb.model.MapObject) GoraException(org.apache.gora.util.GoraException) IOException(java.io.IOException) ReqlExpr(com.rethinkdb.gen.ast.ReqlExpr)

Aggregations

ReqlExpr (com.rethinkdb.gen.ast.ReqlExpr)1 MapObject (com.rethinkdb.model.MapObject)1 IOException (java.io.IOException)1 PartitionQueryImpl (org.apache.gora.query.impl.PartitionQueryImpl)1 RethinkDBQuery (org.apache.gora.rethinkdb.query.RethinkDBQuery)1 RethinkDBResult (org.apache.gora.rethinkdb.query.RethinkDBResult)1 GoraException (org.apache.gora.util.GoraException)1