Search in sources :

Example 1 with RowScanner

use of org.apache.fluo.api.client.scanner.RowScanner in project incubator-rya by apache.

the class GetQueryReport method countBindingSets.

private BigInteger countBindingSets(final SnapshotBase sx, final String nodeId, final Column bindingSetColumn) {
    checkNotNull(sx);
    checkNotNull(nodeId);
    checkNotNull(bindingSetColumn);
    NodeType type = NodeType.fromNodeId(nodeId).get();
    Bytes prefixBytes = Bytes.of(type.getNodeTypePrefix());
    // Limit the scan to the binding set column and node id.
    final RowScanner rows = sx.scanner().over(Span.prefix(prefixBytes)).fetch(bindingSetColumn).byRow().build();
    BigInteger count = BigInteger.valueOf(0L);
    for (ColumnScanner columns : rows) {
        String row = BindingSetRow.makeFromShardedRow(prefixBytes, columns.getRow()).getNodeId();
        if (row.equals(nodeId)) {
            count = count.add(BigInteger.ONE);
        }
    }
    return count;
}
Also used : Bytes(org.apache.fluo.api.data.Bytes) NodeType(org.apache.rya.indexing.pcj.fluo.app.NodeType) RowScanner(org.apache.fluo.api.client.scanner.RowScanner) BigInteger(java.math.BigInteger) ColumnScanner(org.apache.fluo.api.client.scanner.ColumnScanner)

Example 2 with RowScanner

use of org.apache.fluo.api.client.scanner.RowScanner in project incubator-rya by apache.

the class PeriodicNotificationProvider method getNotifications.

/**
 * Retrieve all of the information about Periodic Query results already registered
 * with Fluo.  This is returned in the form of {@link CommandNotification}s that
 * can be registered with the {@link NotificationCoordinatorExecutor}.
 * @param sx - snapshot for reading results from Fluo
 * @return - collection of CommandNotifications that indicate Periodic Query information registered with system
 */
public Collection<CommandNotification> getNotifications(Snapshot sx) {
    Set<PeriodicQueryMetadata> periodicMetadata = new HashSet<>();
    RowScanner scanner = sx.scanner().fetch(FluoQueryColumns.PERIODIC_QUERY_NODE_ID).over(Span.prefix(IncrementalUpdateConstants.PERIODIC_QUERY_PREFIX)).byRow().build();
    Iterator<ColumnScanner> colScannerIter = scanner.iterator();
    while (colScannerIter.hasNext()) {
        ColumnScanner colScanner = colScannerIter.next();
        Iterator<ColumnValue> values = colScanner.iterator();
        while (values.hasNext()) {
            PeriodicQueryMetadata metadata = dao.readPeriodicQueryMetadata(sx, values.next().getsValue());
            periodicMetadata.add(metadata);
        }
    }
    return getCommandNotifications(sx, periodicMetadata);
}
Also used : PeriodicQueryMetadata(org.apache.rya.indexing.pcj.fluo.app.query.PeriodicQueryMetadata) RowScanner(org.apache.fluo.api.client.scanner.RowScanner) ColumnScanner(org.apache.fluo.api.client.scanner.ColumnScanner) ColumnValue(org.apache.fluo.api.data.ColumnValue) HashSet(java.util.HashSet)

Example 3 with RowScanner

use of org.apache.fluo.api.client.scanner.RowScanner in project incubator-rya by apache.

the class CreateDeleteIT method getFluoTableEntries.

private List<Bytes> getFluoTableEntries(final FluoClient fluoClient) {
    try (Snapshot snapshot = fluoClient.newSnapshot()) {
        final List<Bytes> rows = new ArrayList<>();
        final RowScanner rscanner = snapshot.scanner().over(Span.prefix("")).byRow().build();
        for (final ColumnScanner cscanner : rscanner) {
            rows.add(cscanner.getRow());
        }
        return rows;
    }
}
Also used : Snapshot(org.apache.fluo.api.client.Snapshot) Bytes(org.apache.fluo.api.data.Bytes) ArrayList(java.util.ArrayList) RowScanner(org.apache.fluo.api.client.scanner.RowScanner) ColumnScanner(org.apache.fluo.api.client.scanner.ColumnScanner)

Example 4 with RowScanner

use of org.apache.fluo.api.client.scanner.RowScanner in project incubator-rya by apache.

the class BatchIT method countResults.

private int countResults(FluoClient fluoClient, String nodeId, Column bsColumn) {
    try (Transaction tx = fluoClient.newTransaction()) {
        int count = 0;
        Optional<NodeType> type = NodeType.fromNodeId(nodeId);
        Bytes prefixBytes = Bytes.of(type.get().getNodeTypePrefix());
        RowScanner scanner = tx.scanner().over(Span.prefix(prefixBytes)).fetch(bsColumn).byRow().build();
        Iterator<ColumnScanner> colScanners = scanner.iterator();
        while (colScanners.hasNext()) {
            ColumnScanner colScanner = colScanners.next();
            BindingSetRow bsRow = BindingSetRow.makeFromShardedRow(prefixBytes, colScanner.getRow());
            if (bsRow.getNodeId().equals(nodeId)) {
                Iterator<ColumnValue> vals = colScanner.iterator();
                while (vals.hasNext()) {
                    vals.next();
                    count++;
                }
            }
        }
        tx.commit();
        return count;
    }
}
Also used : Bytes(org.apache.fluo.api.data.Bytes) Transaction(org.apache.fluo.api.client.Transaction) NodeType(org.apache.rya.indexing.pcj.fluo.app.NodeType) BindingSetRow(org.apache.rya.indexing.pcj.fluo.app.BindingSetRow) RowScanner(org.apache.fluo.api.client.scanner.RowScanner) ColumnScanner(org.apache.fluo.api.client.scanner.ColumnScanner) ColumnValue(org.apache.fluo.api.data.ColumnValue)

Example 5 with RowScanner

use of org.apache.fluo.api.client.scanner.RowScanner in project incubator-rya by apache.

the class CreateDeletePeriodicPCJ method getFluoTableEntries.

private List<Bytes> getFluoTableEntries(final FluoClient fluoClient) {
    try (Snapshot snapshot = fluoClient.newSnapshot()) {
        final List<Bytes> rows = new ArrayList<>();
        final RowScanner rscanner = snapshot.scanner().over(Span.prefix("")).byRow().build();
        for (final ColumnScanner cscanner : rscanner) {
            rows.add(cscanner.getRow());
        }
        return rows;
    }
}
Also used : Snapshot(org.apache.fluo.api.client.Snapshot) Bytes(org.apache.fluo.api.data.Bytes) ArrayList(java.util.ArrayList) RowScanner(org.apache.fluo.api.client.scanner.RowScanner) ColumnScanner(org.apache.fluo.api.client.scanner.ColumnScanner)

Aggregations

ColumnScanner (org.apache.fluo.api.client.scanner.ColumnScanner)9 RowScanner (org.apache.fluo.api.client.scanner.RowScanner)9 Bytes (org.apache.fluo.api.data.Bytes)8 ColumnValue (org.apache.fluo.api.data.ColumnValue)6 NodeType (org.apache.rya.indexing.pcj.fluo.app.NodeType)4 Snapshot (org.apache.fluo.api.client.Snapshot)3 RowColumn (org.apache.fluo.api.data.RowColumn)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 BigInteger (java.math.BigInteger)1 Transaction (org.apache.fluo.api.client.Transaction)1 Column (org.apache.fluo.api.data.Column)1 Span (org.apache.fluo.api.data.Span)1 BindingSetRow (org.apache.rya.indexing.pcj.fluo.app.BindingSetRow)1 PeriodicQueryMetadata (org.apache.rya.indexing.pcj.fluo.app.query.PeriodicQueryMetadata)1 VariableOrder (org.apache.rya.indexing.pcj.storage.accumulo.VariableOrder)1 LiteralImpl (org.openrdf.model.impl.LiteralImpl)1 QueryBindingSet (org.openrdf.query.algebra.evaluation.QueryBindingSet)1