本文整理汇总了Java中org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep类的典型用法代码示例。如果您正苦于以下问题:Java ConnectiveStep类的具体用法?Java ConnectiveStep怎么用?Java ConnectiveStep使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConnectiveStep类属于org.apache.tinkerpop.gremlin.process.traversal.step.filter包,在下文中一共展示了ConnectiveStep类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hasMatched
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
private boolean hasMatched(final ConnectiveStep.Connective connective, final Traverser.Admin<S> traverser) {
int counter = 0;
boolean matched = false;
for (final Traversal.Admin<Object, Object> matchTraversal : this.matchTraversals) {
if (traverser.getTags().contains(matchTraversal.getStartStep().getId())) {
if (connective == ConnectiveStep.Connective.OR) {
matched = true;
break;
}
counter++;
}
}
if (!matched)
matched = this.matchTraversals.size() == counter;
if (matched && this.dedupLabels != null) {
final Path path = traverser.path();
final List<Object> objects = new ArrayList<>(this.dedupLabels.size());
for (final String label : this.dedupLabels) {
objects.add(path.get(Pop.last, label));
}
this.dedups.add(objects);
}
return matched;
}
示例2: apply
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
final List<Step> steps = traversal.getSteps();
final int size = steps.size() - 1;
Step prev = null;
for (int i = 0; i <= size; i++) {
final Step curr = steps.get(i);
if (i == size && isOptimizable(curr)) {
final TraversalParent parent = curr.getTraversal().getParent();
if (parent instanceof NotStep || parent instanceof TraversalFilterStep || parent instanceof WhereTraversalStep || parent instanceof ConnectiveStep) {
optimizeStep(traversal, curr);
}
} else if (isOptimizable(prev)) {
if (curr instanceof CountGlobalStep) {
optimizeStep(traversal, prev);
}
}
if (!(curr instanceof RangeGlobalStep)) {
prev = curr;
}
}
}
示例3: testPreCompilationOfOr
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
@Test
public void testPreCompilationOfOr() {
final List<Traversal.Admin<?, ?>> traversals = Arrays.asList(
__.match(as("a").out().as("b"), or(as("c").path().as("d"), as("e").coin(0.5).as("f"))).asAdmin(),
__.match(as("a").out().as("b"), as("c").path().as("d").or().as("e").coin(0.5).as("f")).asAdmin());
assertEquals(1, new HashSet<>(traversals).size()); // the two patterns should pre-compile to the same traversal
traversals.forEach(traversal -> {
final MatchStep<?, ?> matchStep = (MatchStep<?, ?>) traversal.getStartStep();
assertEquals(2, matchStep.getGlobalChildren().size());
Traversal.Admin<Object, Object> pattern = matchStep.getGlobalChildren().get(0);
assertEquals("a", ((MatchStep.MatchStartStep) pattern.getStartStep()).getSelectKey().get());
assertEquals(VertexStep.class, pattern.getStartStep().getNextStep().getClass());
assertEquals("b", ((MatchStep.MatchEndStep) pattern.getEndStep()).getMatchKey().get());
//
pattern = matchStep.getGlobalChildren().get(1);
assertEquals(MatchStep.class, pattern.getStartStep().getClass());
assertEquals(ConnectiveStep.Connective.OR, ((MatchStep<?, ?>) pattern.getStartStep()).getConnective());
assertEquals("c", ((MatchStep.MatchStartStep) ((MatchStep<?, ?>) pattern.getStartStep()).getGlobalChildren().get(0).getStartStep()).getSelectKey().get());
assertEquals(PathStep.class, ((MatchStep<?, ?>) pattern.getStartStep()).getGlobalChildren().get(0).getStartStep().getNextStep().getClass());
assertEquals("d", ((MatchStep.MatchEndStep) ((MatchStep<?, ?>) pattern.getStartStep()).getGlobalChildren().get(0).getEndStep()).getMatchKey().get());
assertEquals("e", ((MatchStep.MatchStartStep) ((MatchStep<?, ?>) pattern.getStartStep()).getGlobalChildren().get(1).getStartStep()).getSelectKey().get());
assertEquals(CoinStep.class, ((MatchStep<?, ?>) pattern.getStartStep()).getGlobalChildren().get(1).getStartStep().getNextStep().getClass());
assertEquals("f", ((MatchStep.MatchEndStep) ((MatchStep<?, ?>) pattern.getStartStep()).getGlobalChildren().get(1).getEndStep()).getMatchKey().get());
});
}
示例4: testPreCompilationOfAnd
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
@Test
public void testPreCompilationOfAnd() {
final List<Traversal.Admin<?, ?>> traversals = Arrays.asList(
__.match(as("a").out().as("b"), and(as("c").path().as("d"), as("e").barrier())).asAdmin(),
__.match(as("a").out().as("b"), as("c").path().as("d").and().as("e").barrier()).asAdmin());
assertEquals(1, new HashSet<>(traversals).size()); // the two patterns should pre-compile to the same traversal
traversals.forEach(traversal -> {
final MatchStep<?, ?> matchStep = (MatchStep<?, ?>) traversal.getStartStep();
assertEquals(2, matchStep.getGlobalChildren().size());
Traversal.Admin<Object, Object> pattern = matchStep.getGlobalChildren().get(0);
assertEquals("a", ((MatchStep.MatchStartStep) pattern.getStartStep()).getSelectKey().get());
assertEquals(VertexStep.class, pattern.getStartStep().getNextStep().getClass());
assertEquals("b", ((MatchStep.MatchEndStep) pattern.getEndStep()).getMatchKey().get());
//
pattern = matchStep.getGlobalChildren().get(1);
assertEquals(MatchStep.class, pattern.getStartStep().getClass());
assertEquals(ConnectiveStep.Connective.AND, ((MatchStep<?, ?>) pattern.getStartStep()).getConnective());
assertEquals("c", ((MatchStep.MatchStartStep) ((MatchStep<?, ?>) pattern.getStartStep()).getGlobalChildren().get(0).getStartStep()).getSelectKey().get());
assertEquals(PathStep.class, ((MatchStep<?, ?>) pattern.getStartStep()).getGlobalChildren().get(0).getStartStep().getNextStep().getClass());
assertEquals("d", ((MatchStep.MatchEndStep) ((MatchStep<?, ?>) pattern.getStartStep()).getGlobalChildren().get(0).getEndStep()).getMatchKey().get());
assertEquals("e", ((MatchStep.MatchStartStep) ((MatchStep<?, ?>) pattern.getStartStep()).getGlobalChildren().get(1).getStartStep()).getSelectKey().get());
assertEquals(NoOpBarrierStep.class, ((MatchStep<?, ?>) pattern.getStartStep()).getGlobalChildren().get(1).getStartStep().getNextStep().getClass());
assertFalse(((MatchStep.MatchEndStep) ((MatchStep<?, ?>) pattern.getStartStep()).getGlobalChildren().get(1).getEndStep()).getMatchKey().isPresent());
});
}
示例5: MatchStep
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
public MatchStep(final Traversal.Admin traversal, final ConnectiveStep.Connective connective, final Traversal... matchTraversals) {
super(traversal);
this.connective = connective;
this.matchTraversals = (List) Stream.of(matchTraversals).map(Traversal::asAdmin).collect(Collectors.toList());
this.matchTraversals.forEach(this::configureStartAndEndSteps); // recursively convert to MatchStep, MatchStartStep, or MatchEndStep
this.matchTraversals.forEach(this::integrateChild);
this.computedStartLabel = Helper.computeStartLabel(this.matchTraversals);
}
示例6: pullOutVariableStartStepToParent
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
private Set<String> pullOutVariableStartStepToParent(final Set<String> selectKeys, final Traversal.Admin<?, ?> traversal, boolean testRun) {
final Step<?, ?> startStep = traversal.getStartStep();
if (startStep instanceof WhereTraversalStep.WhereStartStep && !((WhereTraversalStep.WhereStartStep) startStep).getScopeKeys().isEmpty()) {
selectKeys.addAll(((WhereTraversalStep.WhereStartStep<?>) startStep).getScopeKeys());
if (!testRun) ((WhereTraversalStep.WhereStartStep) startStep).removeScopeKey();
} else if (startStep instanceof ConnectiveStep || startStep instanceof NotStep) {
((TraversalParent) startStep).getLocalChildren().forEach(child -> this.pullOutVariableStartStepToParent(selectKeys, child, testRun));
}
return selectKeys;
}
示例7: getVariableLocations
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
private static Set<Scoping.Variable> getVariableLocations(final Set<Scoping.Variable> variables, final Traversal.Admin<?, ?> traversal) {
if (variables.size() == 2) return variables; // has both START and END so no need to compute further
final Step<?, ?> startStep = traversal.getStartStep();
if (StartStep.isVariableStartStep(startStep))
variables.add(Scoping.Variable.START);
else if (startStep instanceof WherePredicateStep) {
if (((WherePredicateStep) startStep).getStartKey().isPresent())
variables.add(Scoping.Variable.START);
} else if (startStep instanceof WhereTraversalStep.WhereStartStep) {
if (!((WhereTraversalStep.WhereStartStep) startStep).getScopeKeys().isEmpty())
variables.add(Scoping.Variable.START);
} else if (startStep instanceof MatchStep.MatchStartStep) {
if (((MatchStep.MatchStartStep) startStep).getSelectKey().isPresent())
variables.add(Scoping.Variable.START);
} else if (startStep instanceof MatchStep) {
((MatchStep<?, ?>) startStep).getGlobalChildren().forEach(child -> TraversalHelper.getVariableLocations(variables, child));
} else if (startStep instanceof ConnectiveStep || startStep instanceof NotStep || startStep instanceof WhereTraversalStep)
((TraversalParent) startStep).getLocalChildren().forEach(child -> TraversalHelper.getVariableLocations(variables, child));
///
final Step<?, ?> endStep = traversal.getEndStep();
if (endStep instanceof WherePredicateStep) {
if (((WherePredicateStep) endStep).getStartKey().isPresent())
variables.add(Scoping.Variable.END);
} else if (endStep instanceof WhereTraversalStep.WhereEndStep) {
if (!((WhereTraversalStep.WhereEndStep) endStep).getScopeKeys().isEmpty())
variables.add(Scoping.Variable.END);
} else if (endStep instanceof MatchStep.MatchEndStep) {
if (((MatchStep.MatchEndStep) endStep).getMatchKey().isPresent())
variables.add(Scoping.Variable.END);
} else if (!endStep.getLabels().isEmpty())
variables.add(Scoping.Variable.END);
///
return variables;
}
示例8: processConjunctionMarker
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
private static void processConjunctionMarker(final Class<? extends ConnectiveStep> markerClass, final Traversal.Admin<?, ?> traversal) {
TraversalHelper.getStepsOfClass(markerClass, traversal).stream()
.filter(conjunctionStep -> conjunctionStep.getLocalChildren().isEmpty())
.findFirst().ifPresent(connectiveStep -> {
Step<?, ?> currentStep = connectiveStep.getNextStep();
final Traversal.Admin<?, ?> rightTraversal = __.start().asAdmin();
if (!connectiveStep.getLabels().isEmpty()) {
final StartStep<?> startStep = new StartStep<>(rightTraversal);
final Set<String> conjunctionLabels = ((Step<?, ?>) connectiveStep).getLabels();
conjunctionLabels.forEach(startStep::addLabel);
conjunctionLabels.forEach(label -> connectiveStep.removeLabel(label));
rightTraversal.addStep(startStep);
}
while (legalCurrentStep(currentStep)) {
final Step<?, ?> nextStep = currentStep.getNextStep();
rightTraversal.addStep(currentStep);
traversal.removeStep(currentStep);
currentStep = nextStep;
}
processConnectiveMarker(rightTraversal);
currentStep = connectiveStep.getPreviousStep();
final Traversal.Admin<?, ?> leftTraversal = __.start().asAdmin();
while (legalCurrentStep(currentStep)) {
final Step<?, ?> previousStep = currentStep.getPreviousStep();
leftTraversal.addStep(0, currentStep);
traversal.removeStep(currentStep);
currentStep = previousStep;
}
processConnectiveMarker(leftTraversal);
TraversalHelper.replaceStep(connectiveStep,
connectiveStep instanceof AndStep ?
new AndStep(traversal, leftTraversal, rightTraversal) :
new OrStep(traversal, leftTraversal, rightTraversal), traversal);
});
}
示例9: getVariableLocations
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
private static Set<Scoping.Variable> getVariableLocations(final Set<Scoping.Variable> variables, final Traversal.Admin<?, ?> traversal) {
if (variables.size() == 2) return variables; // has both START and END so no need to compute further
final Step<?, ?> startStep = traversal.getStartStep();
if (StartStep.isVariableStartStep(startStep))
variables.add(Scoping.Variable.START);
else if (startStep instanceof WherePredicateStep) {
if (((WherePredicateStep) startStep).getStartKey().isPresent())
variables.add(Scoping.Variable.START);
} else if (startStep instanceof WhereTraversalStep.WhereStartStep) {
if (!((WhereTraversalStep.WhereStartStep) startStep).getScopeKeys().isEmpty())
variables.add(Scoping.Variable.START);
} else if (startStep instanceof MatchStep.MatchStartStep) {
if (((MatchStep.MatchStartStep) startStep).getSelectKey().isPresent())
variables.add(Scoping.Variable.START);
} else if (startStep instanceof MatchStep) {
for (final Traversal.Admin<?, ?> global : ((MatchStep<?, ?>) startStep).getGlobalChildren()) {
TraversalHelper.getVariableLocations(variables, global);
}
} else if (startStep instanceof ConnectiveStep || startStep instanceof NotStep || startStep instanceof WhereTraversalStep) {
for (final Traversal.Admin<?, ?> local : ((TraversalParent) startStep).getLocalChildren()) {
TraversalHelper.getVariableLocations(variables, local);
}
}
///
final Step<?, ?> endStep = traversal.getEndStep();
if (endStep instanceof WherePredicateStep) {
if (((WherePredicateStep) endStep).getStartKey().isPresent())
variables.add(Scoping.Variable.END);
} else if (endStep instanceof WhereTraversalStep.WhereEndStep) {
if (!((WhereTraversalStep.WhereEndStep) endStep).getScopeKeys().isEmpty())
variables.add(Scoping.Variable.END);
} else if (endStep instanceof MatchStep.MatchEndStep) {
if (((MatchStep.MatchEndStep) endStep).getMatchKey().isPresent())
variables.add(Scoping.Variable.END);
} else if (!endStep.getLabels().isEmpty())
variables.add(Scoping.Variable.END);
///
return variables;
}
示例10: processConjunctionMarker
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
private static void processConjunctionMarker(final Class<? extends ConnectiveStep> markerClass, final Traversal.Admin<?, ?> traversal) {
TraversalHelper.getStepsOfClass(markerClass, traversal).stream()
.filter(conjunctionStep -> conjunctionStep.getLocalChildren().isEmpty())
.findFirst().ifPresent(connectiveStep -> {
Step<?, ?> currentStep = connectiveStep.getNextStep();
final Traversal.Admin<?, ?> rightTraversal = __.start().asAdmin();
if (!connectiveStep.getLabels().isEmpty()) {
final StartStep<?> startStep = new StartStep<>(rightTraversal);
final Set<String> conjunctionLabels = ((Step<?, ?>) connectiveStep).getLabels();
conjunctionLabels.forEach(startStep::addLabel);
conjunctionLabels.forEach(label -> connectiveStep.removeLabel(label));
rightTraversal.addStep(startStep);
}
while (legalCurrentStep(currentStep)) {
final Step<?, ?> nextStep = currentStep.getNextStep();
rightTraversal.addStep(currentStep);
traversal.removeStep(currentStep);
currentStep = nextStep;
}
processConnectiveMarker(rightTraversal);
currentStep = connectiveStep.getPreviousStep();
final Traversal.Admin<?, ?> leftTraversal = __.start().asAdmin();
while (legalCurrentStep(currentStep)) {
final Step<?, ?> previousStep = currentStep.getPreviousStep();
leftTraversal.addStep(0, currentStep);
traversal.removeStep(currentStep);
currentStep = previousStep;
}
processConnectiveMarker(leftTraversal);
if (connectiveStep instanceof AndStep)
TraversalHelper.replaceStep((Step) connectiveStep, new AndStep(traversal, leftTraversal, rightTraversal), traversal);
else
TraversalHelper.replaceStep((Step) connectiveStep, new OrStep(traversal, leftTraversal, rightTraversal), traversal);
});
}
示例11: isLocalElement
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
private static boolean isLocalElement(final Step<?, ?> step) {
return step instanceof PropertiesStep || step instanceof PropertyMapStep ||
step instanceof IdStep || step instanceof LabelStep || step instanceof SackStep ||
step instanceof PropertyKeyStep || step instanceof PropertyValueStep ||
step instanceof TailGlobalStep || step instanceof RangeGlobalStep || step instanceof HasStep ||
step instanceof ConnectiveStep;
}
示例12: from
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
public static TYPE from(ConnectiveStep<?> connectiveStep) {
if (connectiveStep instanceof AndStep) {
return AND;
} else if (connectiveStep instanceof OrStep) {
return OR;
} else {
return NONE;
}
}
示例13: getConnective
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
public ConnectiveStep.Connective getConnective() {
return this.connective;
}
示例14: apply
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
if (TraversalHelper.hasStepOfAssignableClass(ConnectiveStep.class, traversal)) {
processConnectiveMarker(traversal);
}
}
示例15: match
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
/**
* Map the {@link Traverser} to a {@link Map} of bindings as specified by the provided match traversals.
*
* @param matchTraversals the traversal that maintain variables which must hold for the life of the traverser
* @param <E2> the type of the obejcts bound in the variables
* @return the traversal with an appended {@link MatchStep}.
*/
public default <E2> GraphTraversal<S, Map<String, E2>> match(final Traversal<?, ?>... matchTraversals) {
return this.asAdmin().addStep(new MatchStep<>(this.asAdmin(), ConnectiveStep.Connective.AND, matchTraversals));
}