use of org.apache.accumulo.core.client.ScannerBase 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());
}
use of org.apache.accumulo.core.client.ScannerBase in project vertexium by visallo.
the class AccumuloFindPathStrategy method getConnectedVertexIds.
private Map<String, Set<String>> getConnectedVertexIds(Set<String> vertexIds) {
Span trace = Trace.start("getConnectedVertexIds");
try {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("getConnectedVertexIds:\n %s", IterableUtils.join(vertexIds, "\n "));
}
if (vertexIds.size() == 0) {
return new HashMap<>();
}
List<org.apache.accumulo.core.data.Range> ranges = new ArrayList<>();
for (String vertexId : vertexIds) {
ranges.add(RangeUtils.createRangeFromString(vertexId));
}
int maxVersions = 1;
Long startTime = null;
Long endTime = null;
ScannerBase scanner = graph.createElementScanner(FetchHints.EDGE_REFS, ElementType.VERTEX, maxVersions, startTime, endTime, ranges, false, authorizations);
IteratorSetting connectedVertexIdsIteratorSettings = new IteratorSetting(1000, ConnectedVertexIdsIterator.class.getSimpleName(), ConnectedVertexIdsIterator.class);
ConnectedVertexIdsIterator.setLabels(connectedVertexIdsIteratorSettings, deflatedLabels);
ConnectedVertexIdsIterator.setExcludedLabels(connectedVertexIdsIteratorSettings, deflatedExcludedLabels);
scanner.addScanIterator(connectedVertexIdsIteratorSettings);
final long timerStartTime = System.currentTimeMillis();
try {
Map<String, Set<String>> results = new HashMap<>();
for (Map.Entry<Key, Value> row : scanner) {
try {
Map<String, Boolean> verticesExist = graph.doVerticesExist(ConnectedVertexIdsIterator.decodeValue(row.getValue()), authorizations);
Set<String> rowVertexIds = stream(verticesExist.keySet()).filter(key -> verticesExist.getOrDefault(key, false)).collect(Collectors.toSet());
results.put(row.getKey().getRow().toString(), rowVertexIds);
} catch (IOException e) {
throw new VertexiumException("Could not decode vertex ids for row: " + row.getKey().toString(), e);
}
}
return results;
} finally {
scanner.close();
AccumuloGraph.GRAPH_LOGGER.logEndIterator(System.currentTimeMillis() - timerStartTime);
}
} finally {
trace.stop();
}
}
Aggregations