Search in sources :

Example 6 with DocumentStream

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;
    }
}
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

DocumentStream (org.ojai.DocumentStream)6 Table (com.mapr.db.Table)4 InputStream (java.io.InputStream)4 BeforeClass (org.junit.BeforeClass)3 Document (org.ojai.Document)3 DBDocumentReaderBase (com.mapr.db.ojai.DBDocumentReaderBase)1 StringBufferInputStream (java.io.StringBufferInputStream)1 UserException (org.apache.drill.common.exceptions.UserException)1 SchemaChangeException (org.apache.drill.exec.exception.SchemaChangeException)1 DocumentStore (org.ojai.store.DocumentStore)1 Query (org.ojai.store.Query)1 QueryCondition (org.ojai.store.QueryCondition)1