Search in sources :

Example 1 with KuduResult

use of org.apache.gora.kudu.query.KuduResult in project gora by apache.

the class KuduStore method execute.

@Override
public Result<K, T> execute(Query<K, T> query) throws GoraException {
    String[] avFields = getFieldsToQuery(query.getFields());
    List<String> dbFields = new ArrayList<>();
    for (String af : avFields) {
        dbFields.add(kuduMapping.getFields().get(af).getName());
    }
    try {
        ColumnSchema column = table.getSchema().getColumn(kuduMapping.getPrimaryKey().get(0).getName());
        dbFields.add(kuduMapping.getPrimaryKey().get(0).getName());
        List<KuduPredicate> rangePredicates = KuduClientUtils.createRangePredicate(column, query.getStartKey(), query.getEndKey());
        rangePredicates.add(KuduPredicate.newIsNotNullPredicate(column));
        KuduScanner build = createScanner(rangePredicates, dbFields, query.getLimit());
        return new KuduResult<>(this, query, build);
    } catch (Exception e) {
        throw new GoraException(e);
    }
}
Also used : GoraException(org.apache.gora.util.GoraException) KuduResult(org.apache.gora.kudu.query.KuduResult) KuduScanner(org.apache.kudu.client.KuduScanner) ArrayList(java.util.ArrayList) ColumnSchema(org.apache.kudu.ColumnSchema) KuduPredicate(org.apache.kudu.client.KuduPredicate) KuduException(org.apache.kudu.client.KuduException) GoraException(org.apache.gora.util.GoraException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 KuduResult (org.apache.gora.kudu.query.KuduResult)1 GoraException (org.apache.gora.util.GoraException)1 ColumnSchema (org.apache.kudu.ColumnSchema)1 KuduException (org.apache.kudu.client.KuduException)1 KuduPredicate (org.apache.kudu.client.KuduPredicate)1 KuduScanner (org.apache.kudu.client.KuduScanner)1