use of org.apache.accumulo.core.trace.Trace 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