Search in sources :

Example 6 with PeriodicQueryStorageException

use of org.apache.rya.indexing.pcj.storage.PeriodicQueryStorageException in project incubator-rya by apache.

the class AccumuloPeriodicQueryResultStorage method listResults.

@Override
public CloseableIterator<BindingSet> listResults(final String queryId, final Optional<Long> binId) throws PeriodicQueryStorageException {
    requireNonNull(queryId);
    final String tableName = tableNameFactory.makeTableName(ryaInstance, queryId);
    // Fetch the Variable Orders for the binding sets and choose one of
    // them. It
    // doesn't matter which one we choose because they all result in the
    // same output.
    final PeriodicQueryStorageMetadata metadata = getPeriodicQueryMetadata(queryId);
    final VariableOrder varOrder = metadata.getVariableOrder();
    try {
        // Fetch only the Binding Sets whose Variable Order matches the
        // selected one.
        final Scanner scanner = accumuloConn.createScanner(tableName, auths);
        scanner.fetchColumnFamily(new Text(varOrder.toString()));
        if (binId.isPresent()) {
            scanner.setRange(Range.prefix(getRowPrefix(binId.get())));
        }
        return new AccumuloValueBindingSetIterator(scanner);
    } catch (final Exception e) {
        throw new PeriodicQueryStorageException(String.format("PCJ Table does not exist for name '%s'.", tableName), e);
    }
}
Also used : Scanner(org.apache.accumulo.core.client.Scanner) PeriodicQueryStorageException(org.apache.rya.indexing.pcj.storage.PeriodicQueryStorageException) PeriodicQueryStorageMetadata(org.apache.rya.indexing.pcj.storage.PeriodicQueryStorageMetadata) Text(org.apache.hadoop.io.Text) PeriodicQueryStorageException(org.apache.rya.indexing.pcj.storage.PeriodicQueryStorageException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) MalformedQueryException(org.openrdf.query.MalformedQueryException) BindingSetConversionException(org.apache.rya.indexing.pcj.storage.accumulo.BindingSetConverter.BindingSetConversionException) AccumuloException(org.apache.accumulo.core.client.AccumuloException)

Aggregations

PeriodicQueryStorageException (org.apache.rya.indexing.pcj.storage.PeriodicQueryStorageException)6 MalformedQueryException (org.openrdf.query.MalformedQueryException)6 AccumuloException (org.apache.accumulo.core.client.AccumuloException)3 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)3 BindingSetConversionException (org.apache.rya.indexing.pcj.storage.accumulo.BindingSetConverter.BindingSetConversionException)3 Text (org.apache.hadoop.io.Text)2 FluoQuery (org.apache.rya.indexing.pcj.fluo.app.query.FluoQuery)2 PeriodicQueryNode (org.apache.rya.indexing.pcj.fluo.app.query.PeriodicQueryNode)2 UnsupportedQueryException (org.apache.rya.indexing.pcj.fluo.app.query.UnsupportedQueryException)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 BatchDeleter (org.apache.accumulo.core.client.BatchDeleter)1 BatchWriterConfig (org.apache.accumulo.core.client.BatchWriterConfig)1 Scanner (org.apache.accumulo.core.client.Scanner)1 PeriodicQueryStorageMetadata (org.apache.rya.indexing.pcj.storage.PeriodicQueryStorageMetadata)1 PeriodicNotification (org.apache.rya.periodic.notification.notification.PeriodicNotification)1