use of org.apache.fluo.api.client.Snapshot in project incubator-rya by apache.
the class BatchIT method getNodeIdStrings.
private List<String> getNodeIdStrings(FluoClient fluoClient, String queryId) throws UnsupportedQueryException {
List<String> nodeStrings;
try (Snapshot sx = fluoClient.newSnapshot()) {
FluoQuery query = dao.readFluoQuery(sx, queryId);
nodeStrings = FluoQueryUtils.collectNodeIds(query);
}
return nodeStrings;
}
use of org.apache.fluo.api.client.Snapshot 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;
}
}
use of org.apache.fluo.api.client.Snapshot in project incubator-rya by apache.
the class GetPcjMetadata method getMetadata.
/**
* Get the {@link PcjMetadata} of a query that is being maintained by the
* Fluo app.
*
* @param pcjStorage - The PCJ Storage that will be searched. (not null)
* @param fluo - The Fluo instance that will be searched. (not null)
* @param queryId - The Query Id whose metadata will be fetched. (not null)
* @return The {@link PcjMetadata} of the query.
* @throws NotInFluoException The query Id does not have a PCJ export able
* associated with it in the Fluo table.
* @throws NotInAccumuloException The PCJ export table that was found either
* does not exist in Accumulo or it is not a PCJ table.
*/
public PcjMetadata getMetadata(final PrecomputedJoinStorage pcjStorage, final FluoClient fluo, final String queryId) throws NotInFluoException, NotInAccumuloException {
requireNonNull(pcjStorage);
requireNonNull(fluo);
requireNonNull(queryId);
// Lookup the Rya PCJ ID associated with the query.
String pcjId = null;
try (Snapshot snap = fluo.newSnapshot()) {
pcjId = FluoQueryUtils.convertFluoQueryIdToPcjId(queryId);
if (pcjId == null) {
throw new NotInFluoException("Could not get the PcjMetadata for queryId '" + queryId + "' because a Rya PCJ ID not stored in the Fluo table.");
}
}
// Fetch the metadata from the storage.
try {
return pcjStorage.getPcjMetadata(pcjId);
} catch (final PcjException e) {
throw new NotInAccumuloException("Could not get the PcjMetadata for queryId '" + queryId + "' because the metadata was missing from the Rya storage.", e);
}
}
use of org.apache.fluo.api.client.Snapshot in project incubator-rya by apache.
the class ListQueryIds method listQueryIds.
/**
* Finds all queries that are being managed by this instance of Fluo that
* are also being exported to the provided instance of Accumulo.
*
* @param fluo - The Fluo instance that will be searched. (not null)
* @return An ascending alphabetically sorted list of the Query IDs being
* managed by the Fluo app and exported to an instance of Accumulo.
*/
public List<String> listQueryIds(final FluoClient fluo) {
checkNotNull(fluo);
final List<String> queryIds = new ArrayList<>();
try (Snapshot snap = fluo.newSnapshot()) {
// Create an iterator that iterates over the QUERY_ID column.
final CellScanner cellScanner = snap.scanner().fetch(FluoQueryColumns.QUERY_NODE_ID).build();
for (RowColumnValue rcv : cellScanner) {
queryIds.add(rcv.getsValue());
// TODO this was doing a snap.get that seemed unnecessary
}
}
// Sort them alphabetically.
Collections.sort(queryIds);
return queryIds;
}
use of org.apache.fluo.api.client.Snapshot in project incubator-rya by apache.
the class PeriodicNotificationBinPrunerIT method compareFluoCounts.
private void compareFluoCounts(FluoClient client, String pcjId, long bin) {
QueryBindingSet bs = new QueryBindingSet();
bs.addBinding(IncrementalUpdateConstants.PERIODIC_BIN_ID, new LiteralImpl(Long.toString(bin), XMLSchema.LONG));
VariableOrder varOrder = new VariableOrder(IncrementalUpdateConstants.PERIODIC_BIN_ID);
try (Snapshot sx = client.newSnapshot()) {
String fluoQueryId = NodeType.generateNewIdForType(NodeType.QUERY, pcjId);
Set<String> ids = new HashSet<>();
PeriodicQueryUtil.getPeriodicQueryNodeAncestorIds(sx, fluoQueryId, ids);
for (String id : ids) {
NodeType optNode = NodeType.fromNodeId(id).orNull();
if (optNode == null)
throw new RuntimeException("Invalid NodeType.");
Bytes prefix = RowKeyUtil.makeRowKey(id, varOrder, bs);
RowScanner scanner = sx.scanner().fetch(optNode.getResultColumn()).over(Span.prefix(prefix)).byRow().build();
int count = 0;
Iterator<ColumnScanner> colScannerIter = scanner.iterator();
while (colScannerIter.hasNext()) {
ColumnScanner colScanner = colScannerIter.next();
String row = colScanner.getRow().toString();
Iterator<ColumnValue> values = colScanner.iterator();
while (values.hasNext()) {
values.next();
count++;
}
}
Assert.assertEquals(0, count);
}
}
}
Aggregations