Search in sources :

Example 1 with Query

use of org.ojai.store.Query in project YCSB by brianfrankcooper.

the class MapRJSONDBClient method scan.

@Override
public Status scan(String table, String startkey, int recordcount, Set<String> fields, Vector<HashMap<String, ByteIterator>> result) {
    try {
        DocumentStore docStore = getTable(table);
        QueryCondition condition = driver.newCondition().is(DocumentConstants.ID_FIELD, Op.GREATER_OR_EQUAL, startkey).build();
        Query query = driver.newQuery().select(getFieldPaths(fields)).where(condition).build();
        try (DocumentStream stream = docStore.findQuery(query)) {
            int numResults = 0;
            for (Document record : stream) {
                result.add(buildRowResult(record));
                numResults++;
                if (numResults >= recordcount) {
                    break;
                }
            }
        }
        return Status.OK;
    } catch (Exception e) {
        e.printStackTrace();
        return Status.ERROR;
    }
}
Also used : DocumentStore(org.ojai.store.DocumentStore) Query(org.ojai.store.Query) Document(org.ojai.Document) QueryCondition(org.ojai.store.QueryCondition) DocumentStream(org.ojai.DocumentStream)

Aggregations

Document (org.ojai.Document)1 DocumentStream (org.ojai.DocumentStream)1 DocumentStore (org.ojai.store.DocumentStore)1 Query (org.ojai.store.Query)1 QueryCondition (org.ojai.store.QueryCondition)1