use of org.ojai.DocumentStream 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;
}
}
Aggregations