Search in sources :

Example 1 with HBaseScannerResult

use of org.apache.gora.hbase.query.HBaseScannerResult in project gora by apache.

the class HBaseStore method execute.

@Override
public org.apache.gora.query.Result<K, T> execute(Query<K, T> query) throws GoraException {
    try {
        // check if query.fields is null
        query.setFields(getFieldsToQuery(query.getFields()));
        if (query.getStartKey() != null && query.getStartKey().equals(query.getEndKey())) {
            Get get = new Get(toBytes(query.getStartKey()));
            addFields(get, query.getFields());
            addTimeRange(get, query);
            Result result = table.get(get);
            return new HBaseGetResult<>(this, query, result);
        } else {
            ResultScanner scanner = createScanner(query);
            org.apache.gora.query.Result<K, T> result = new HBaseScannerResult<>(this, query, scanner);
            return result;
        }
    } catch (IOException ex) {
        throw new GoraException(ex);
    }
}
Also used : GoraException(org.apache.gora.util.GoraException) ResultScanner(org.apache.hadoop.hbase.client.ResultScanner) Get(org.apache.hadoop.hbase.client.Get) HBaseScannerResult(org.apache.gora.hbase.query.HBaseScannerResult) IOException(java.io.IOException) HBaseScannerResult(org.apache.gora.hbase.query.HBaseScannerResult) Result(org.apache.hadoop.hbase.client.Result) HBaseGetResult(org.apache.gora.hbase.query.HBaseGetResult) HBaseGetResult(org.apache.gora.hbase.query.HBaseGetResult)

Aggregations

IOException (java.io.IOException)1 HBaseGetResult (org.apache.gora.hbase.query.HBaseGetResult)1 HBaseScannerResult (org.apache.gora.hbase.query.HBaseScannerResult)1 GoraException (org.apache.gora.util.GoraException)1 Get (org.apache.hadoop.hbase.client.Get)1 Result (org.apache.hadoop.hbase.client.Result)1 ResultScanner (org.apache.hadoop.hbase.client.ResultScanner)1