Search in sources :

Example 6 with KeyParts

use of org.apache.rya.indexing.KeyParts in project incubator-rya by apache.

the class AccumuloTemporalIndexer method queryInstantBeforeInstant.

/**
 * get statements where the db row ID is BEFORE the given queryInstant.
 */
@Override
public CloseableIteration<Statement, QueryEvaluationException> queryInstantBeforeInstant(final TemporalInstant queryInstant, final StatementConstraints constraints) throws QueryEvaluationException {
    // get rows where the repository time is before the given time.
    final Query query = new Query() {

        @Override
        public Range getRange(final KeyParts keyParts) {
            Text start = null;
            if (keyParts.constraintPrefix != null) {
                // <-- start specific logic
                start = keyParts.constraintPrefix;
            } else {
                start = new Text(KeyParts.HASH_PREFIX_FOLLOWING);
            }
            // <-- end specific logic
            final Text endAt = keyParts.getQueryKey();
            // System.out.println("Scanning queryInstantBeforeInstant: from:" + KeyParts.toHumanString(start) + " up to:" + KeyParts.toHumanString(endAt));
            return new Range(start, true, endAt, false);
        }
    };
    final ScannerBase scanner = query.doQuery(queryInstant, constraints);
    return getContextIteratorWrapper(scanner, constraints.getContext());
}
Also used : ScannerBase(org.apache.accumulo.core.client.ScannerBase) Text(org.apache.hadoop.io.Text) KeyParts(org.apache.rya.indexing.KeyParts) Range(org.apache.accumulo.core.data.Range)

Aggregations

KeyParts (org.apache.rya.indexing.KeyParts)6 ScannerBase (org.apache.accumulo.core.client.ScannerBase)4 Range (org.apache.accumulo.core.data.Range)3 Text (org.apache.hadoop.io.Text)3 Mutation (org.apache.accumulo.core.data.Mutation)2 TemporalInterval (org.apache.rya.indexing.TemporalInterval)1