use of org.janusgraph.graphdb.tinkerpop.optimize.step.MultiQueriable in project janusgraph by JanusGraph.
the class JanusGraphMultiQueryStepTest method generateTestParameters.
private static Stream<Arguments> generateTestParameters() {
Traversal.Admin mockedTraversal = mock(Traversal.Admin.class);
when(mockedTraversal.getTraverserSetSupplier()).thenReturn(TraverserSet::new);
MultiQueriable mqA = mock(MultiQueriable.class);
MultiQueriable mqB = mock(MultiQueriable.class);
List<MultiQueriable> emptyClientList = Collections.emptyList();
List<MultiQueriable> singleClientList = Collections.singletonList(mqA);
List<MultiQueriable> multiClientList = Arrays.asList(mqA, mqB);
return Arrays.stream(new Arguments[] { arguments(mockedTraversal, true, emptyClientList), arguments(mockedTraversal, false, emptyClientList), arguments(mockedTraversal, true, singleClientList), arguments(mockedTraversal, false, singleClientList), arguments(mockedTraversal, true, multiClientList), arguments(mockedTraversal, false, multiClientList) });
}
use of org.janusgraph.graphdb.tinkerpop.optimize.step.MultiQueriable in project janusgraph by JanusGraph.
the class JanusGraphMultiQueryStrategy method configureMultiQueriables.
/**
* Looks for MultiQueriables in within the traversal and registers them as clients of their respective
* JanusGraphMultiQuerySteps
*
* @param traversal The local traversal layer.
*/
private void configureMultiQueriables(final Admin<?, ?> traversal) {
TraversalHelper.getStepsOfAssignableClass(MultiQueriable.class, traversal).forEach(multiQueriable -> {
final List<Step> mqPositions = JanusGraphTraversalUtil.getAllMultiQueryPositionsForMultiQueriable(multiQueriable);
// If one position is not legal, this means that the entire step can not use the multiQuery feature.
for (Step mqPos : mqPositions) {
if (!JanusGraphTraversalUtil.isLegalMultiQueryPosition(mqPos)) {
return;
}
}
// MultiQuery is applicable
multiQueriable.setUseMultiQuery(true);
for (Step mqPos : mqPositions) {
final Optional<JanusGraphMultiQueryStep> multiQueryStep = JanusGraphTraversalUtil.getPreviousStepOfClass(JanusGraphMultiQueryStep.class, mqPos);
multiQueryStep.ifPresent(mqs -> mqs.attachClient(multiQueriable));
}
});
}
Aggregations