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