本文整理汇总了Java中org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep类的典型用法代码示例。如果您正苦于以下问题:Java GraphStep类的具体用法?Java GraphStep怎么用?Java GraphStep使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GraphStep类属于org.apache.tinkerpop.gremlin.process.traversal.step.map包,在下文中一共展示了GraphStep类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep; //导入依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
if (TraversalHelper.onGraphComputer(traversal))
return;
for (final GraphStep originalGraphStep : TraversalHelper.getStepsOfClass(GraphStep.class, traversal)) {
final TinkerGraphStep<?, ?> tinkerGraphStep = new TinkerGraphStep<>(originalGraphStep);
TraversalHelper.replaceStep(originalGraphStep, tinkerGraphStep, traversal);
Step<?, ?> currentStep = tinkerGraphStep.getNextStep();
while (currentStep instanceof HasStep || currentStep instanceof NoOpBarrierStep) {
if (currentStep instanceof HasStep) {
for (final HasContainer hasContainer : ((HasContainerHolder) currentStep).getHasContainers()) {
if (!GraphStep.processHasContainerIds(tinkerGraphStep, hasContainer))
tinkerGraphStep.addHasContainer(hasContainer);
}
TraversalHelper.copyLabels(currentStep, currentStep.getPreviousStep(), false);
traversal.removeStep(currentStep);
}
currentStep = currentStep.getNextStep();
}
}
}
示例2: apply
import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep; //导入依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
if (!(traversal.getParent() instanceof EmptyStep) || TraversalHelper.onGraphComputer(traversal))
return;
final List<Step> steps = traversal.getSteps();
if (steps.size() < 2 ||
!(steps.get(0) instanceof GraphStep) ||
0 != ((GraphStep) steps.get(0)).getIds().length ||
!(steps.get(steps.size() - 1) instanceof CountGlobalStep))
return;
for (int i = 1; i < steps.size() - 1; i++) {
final Step current = steps.get(i);
if (!(current instanceof MapStep ||
current instanceof IdentityStep ||
current instanceof NoOpBarrierStep ||
current instanceof CollectingBarrierStep) ||
(current instanceof TraversalParent &&
TraversalHelper.anyStepRecursively(s -> (s instanceof SideEffectStep || s instanceof AggregateStep), (TraversalParent) current)))
return;
}
final Class<? extends Element> elementClass = ((GraphStep<?, ?>) steps.get(0)).getReturnClass();
TraversalHelper.removeAllSteps(traversal);
traversal.addStep(new TinkerCountGlobalStep<>(traversal, elementClass));
}
示例3: apply
import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep; //导入依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
for (final GraphStep originalGraphStep : TraversalHelper.getStepsOfClass(GraphStep.class, traversal)) {
final BitsyGraphStep<?, ?> bitsyGraphStep = new BitsyGraphStep<>(originalGraphStep);
TraversalHelper.replaceStep(originalGraphStep, bitsyGraphStep, traversal);
Step<?, ?> currentStep = bitsyGraphStep.getNextStep();
while (currentStep instanceof HasStep || currentStep instanceof NoOpBarrierStep) {
if (currentStep instanceof HasStep) {
for (final HasContainer hasContainer : ((HasContainerHolder) currentStep).getHasContainers()) {
if (!GraphStep.processHasContainerIds(bitsyGraphStep, hasContainer))
bitsyGraphStep.addHasContainer(hasContainer);
}
TraversalHelper.copyLabels(currentStep, currentStep.getPreviousStep(), false);
traversal.removeStep(currentStep);
}
currentStep = currentStep.getNextStep();
}
}
}
示例4: apply
import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
for (final GraphStep originalGraphStep : TraversalHelper.getStepsOfClass(GraphStep.class, traversal)) {
final HBaseGraphStep<?, ?> hbaseGraphStep = new HBaseGraphStep<>(originalGraphStep);
TraversalHelper.replaceStep(originalGraphStep, hbaseGraphStep, traversal);
Step<?, ?> currentStep = hbaseGraphStep.getNextStep();
while (currentStep instanceof HasStep || currentStep instanceof NoOpBarrierStep) {
if (currentStep instanceof HasStep) {
for (final HasContainer hasContainer : ((HasContainerHolder) currentStep).getHasContainers()) {
if (!GraphStep.processHasContainerIds(hbaseGraphStep, hasContainer))
hbaseGraphStep.addHasContainer(hasContainer);
}
TraversalHelper.copyLabels(currentStep, currentStep.getPreviousStep(), false);
traversal.removeStep(currentStep);
}
currentStep = currentStep.getNextStep();
}
}
}
示例5: apply
import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep; //导入依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
if (TraversalHelper.onGraphComputer(traversal))
return;
TraversalHelper.getStepsOfClass(GraphStep.class, traversal).forEach(originalGraphStep -> {
final TinkerGraphStep<?, ?> tinkerGraphStep = new TinkerGraphStep<>(originalGraphStep);
TraversalHelper.replaceStep(originalGraphStep, (Step) tinkerGraphStep, traversal);
Step<?, ?> currentStep = tinkerGraphStep.getNextStep();
while (currentStep instanceof HasContainerHolder) {
((HasContainerHolder) currentStep).getHasContainers().forEach(hasContainer -> {
if (!GraphStep.processHasContainerIds(tinkerGraphStep, hasContainer))
tinkerGraphStep.addHasContainer(hasContainer);
});
currentStep.getLabels().forEach(tinkerGraphStep::addLabel);
traversal.removeStep(currentStep);
currentStep = currentStep.getNextStep();
}
});
}
示例6: isLegal
import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep; //导入依赖的package包/类
public static boolean isLegal(final Traversal.Admin<?, ?> traversal) {
final Step<?, ?> startStep = traversal.getStartStep();
final Step<?, ?> endStep = traversal.getEndStep();
if (!startStep.getClass().equals(GraphStep.class) || ((GraphStep) startStep).returnsEdge())
return false;
if (!endStep.getClass().equals(CountGlobalStep.class) &&
!endStep.getClass().equals(SumGlobalStep.class) &&
!endStep.getClass().equals(MeanGlobalStep.class) &&
!endStep.getClass().equals(MaxGlobalStep.class) &&
!endStep.getClass().equals(MinGlobalStep.class) &&
!endStep.getClass().equals(FoldStep.class) &&
!endStep.getClass().equals(GroupStep.class) &&
!endStep.getClass().equals(GroupCountStep.class))
// TODO: tree()
return false;
if (TraversalHelper.getStepsOfAssignableClassRecursively(Scope.global, Barrier.class, traversal).size() != 1)
return false;
if (traversal.getTraverserRequirements().contains(TraverserRequirement.SACK))
return false;
return TraversalHelper.isLocalStarGraph(traversal);
}
示例7: apply
import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep; //导入依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
TraversalHelper.getStepsOfClass(GraphStep.class, traversal).forEach(originalGraphStep -> {
final Neo4jGraphStep<?, ?> neo4jGraphStep = new Neo4jGraphStep<>(originalGraphStep);
TraversalHelper.replaceStep(originalGraphStep, (Step) neo4jGraphStep, traversal);
Step<?, ?> currentStep = neo4jGraphStep.getNextStep();
while (currentStep instanceof HasContainerHolder) {
((HasContainerHolder) currentStep).getHasContainers().forEach(hasContainer -> {
if (!GraphStep.processHasContainerIds(neo4jGraphStep, hasContainer))
neo4jGraphStep.addHasContainer(hasContainer);
});
currentStep.getLabels().forEach(neo4jGraphStep::addLabel);
traversal.removeStep(currentStep);
currentStep = currentStep.getNextStep();
}
});
}
示例8: assertNumStep
import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep; //导入依赖的package包/类
private static void assertNumStep(int expectedResults, int expectedSteps, GraphTraversal traversal, Class<? extends Step>... expectedStepTypes) {
int num = 0;
while (traversal.hasNext()) {
traversal.next();
num++;
}
// System.out.println(traversal);
assertEquals(expectedResults, num);
//Verify that steps line up with what is expected after Titan's optimizations are applied
List<Step> steps = traversal.asAdmin().getSteps();
Set<Class<? extends Step>> expSteps = Sets.newHashSet(expectedStepTypes);
int numSteps = 0;
for (Step s : steps) {
// System.out.println(s.getClass());
if (s.getClass().equals(GraphStep.class) || s.getClass().equals(StartStep.class)) continue;
assertTrue(s.getClass().getName(), expSteps.contains(s.getClass()));
numSteps++;
}
assertEquals(expectedSteps, numSteps);
}
示例9: apply
import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep; //导入依赖的package包/类
@Override
public void apply(Traversal.Admin<?, ?> traversal) {
if(TraversalHelper.onGraphComputer(traversal)) return;
Graph graph = traversal.getGraph().get();
if(!(graph instanceof UniGraph)) {
return;
}
UniGraph uniGraph = (UniGraph) graph;
TraversalHelper.getStepsOfClass(GraphStep.class, traversal).forEach(graphStep -> {
final UniGraphStartStep<?,?> uniGraphStartStep = new UniGraphStartStep<>(graphStep, uniGraph.getControllerManager());
TraversalHelper.replaceStep(graphStep, (Step) uniGraphStartStep, traversal);
PredicatesUtil.collectPredicates(uniGraphStartStep, traversal);
});
}
示例10: apply
import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep; //导入依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
final Step<?, ?> startStep = traversal.getStartStep();
// only apply once
if (startStep instanceof GraphStep && !(startStep instanceof OrientGraphStep)) {
final GraphStep<?, ?> originalGraphStep = (GraphStep) startStep;
final OrientGraphStep<?, ?> orientGraphStep = new OrientGraphStep<>(originalGraphStep);
TraversalHelper.replaceStep(startStep, (Step) orientGraphStep, traversal);
Step<?, ?> currentStep = orientGraphStep.getNextStep();
while (currentStep instanceof HasContainerHolder) {
((HasContainerHolder) currentStep).getHasContainers().forEach(orientGraphStep::addHasContainer);
currentStep.getLabels().forEach(orientGraphStep::addLabel);
traversal.removeStep(currentStep);
currentStep = currentStep.getNextStep();
}
}
}
示例11: processesPropertyType
import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep; //导入依赖的package包/类
private static final char processesPropertyType(Step step) {
while (!(step instanceof EmptyStep)) {
if (step instanceof FilterStep || step instanceof SideEffectStep)
step = step.getPreviousStep();
else if (step instanceof GraphStep && ((GraphStep) step).returnsVertex())
return 'v';
else if (step instanceof EdgeVertexStep)
return 'v';
else if (step instanceof VertexStep)
return ((VertexStep) step).returnsVertex() ? 'v' : 'p';
else if (step instanceof PropertyMapStep || step instanceof PropertiesStep)
return 'p';
else
return 'x';
}
return 'x';
}
示例12: isLegal
import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep; //导入依赖的package包/类
public static boolean isLegal(final Traversal.Admin<?, ?> traversal) {
final Step<?, ?> startStep = traversal.getStartStep();
final Step<?, ?> endStep = traversal.getEndStep();
// right now this is not supported because of how the SparkStarBarrierInterceptor mutates the traversal prior to local evaluation
if (traversal.getStrategies().toList().stream().filter(strategy -> strategy instanceof SubgraphStrategy).findAny().isPresent())
return false;
if (!startStep.getClass().equals(GraphStep.class) || ((GraphStep) startStep).returnsEdge())
return false;
if (!endStep.getClass().equals(CountGlobalStep.class) &&
!endStep.getClass().equals(SumGlobalStep.class) &&
!endStep.getClass().equals(MeanGlobalStep.class) &&
!endStep.getClass().equals(MaxGlobalStep.class) &&
!endStep.getClass().equals(MinGlobalStep.class) &&
!endStep.getClass().equals(FoldStep.class) &&
!endStep.getClass().equals(GroupStep.class) &&
!endStep.getClass().equals(GroupCountStep.class))
// TODO: tree()
return false;
if (TraversalHelper.getStepsOfAssignableClassRecursively(Scope.global, Barrier.class, traversal).size() != 1)
return false;
if (traversal.getTraverserRequirements().contains(TraverserRequirement.SACK))
return false;
return TraversalHelper.isLocalStarGraph(traversal);
}
示例13: apply
import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep; //导入依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
for (final GraphStep originalGraphStep : TraversalHelper.getStepsOfClass(GraphStep.class, traversal)) {
final Neo4jGraphStep<?, ?> neo4jGraphStep = new Neo4jGraphStep<>(originalGraphStep);
TraversalHelper.replaceStep(originalGraphStep, neo4jGraphStep, traversal);
Step<?, ?> currentStep = neo4jGraphStep.getNextStep();
while (currentStep instanceof HasStep || currentStep instanceof NoOpBarrierStep) {
if (currentStep instanceof HasStep) {
for (final HasContainer hasContainer : ((HasContainerHolder) currentStep).getHasContainers()) {
if (!GraphStep.processHasContainerIds(neo4jGraphStep, hasContainer))
neo4jGraphStep.addHasContainer(hasContainer);
}
TraversalHelper.copyLabels(currentStep, currentStep.getPreviousStep(), false);
traversal.removeStep(currentStep);
}
currentStep = currentStep.getNextStep();
}
}
}
示例14: walkReplacedSteps
import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep; //导入依赖的package包/类
void walkReplacedSteps(Set<SchemaTableTree> schemaTableTrees) {
//The tree only has one linear path from root to the deepest leaf node.
//This represents the regular path where each ReplacedStep goes one step deeper down the graph.
//First build the SchemaTableTrees for this path.
//The other nodes in this ReplacedStepTree are nodes that need to join onto the left join nodes coming from optional steps.
List<ReplacedStep<?, ?>> replacedSteps = linearPathToLeafNode();
for (ReplacedStep<?, ?> replacedStep : replacedSteps) {
//skip the graph step
if (replacedStep.getStep() instanceof GraphStep) {
continue;
}
if (!(replacedStep.getStep() instanceof OrderGlobalStep) && !(replacedStep.getStep() instanceof RangeGlobalStep)) {
//This schemaTableTree represents the tree nodes as build up to this depth. Each replacedStep goes a level further
schemaTableTrees = replacedStep.calculatePathForStep(schemaTableTrees);
}
}
}
示例15: apply
import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep; //导入依赖的package包/类
void apply() {
final Step<?, ?> startStep = traversal.getStartStep();
if (!(startStep instanceof GraphStep)) {
return;
}
final GraphStep originalGraphStep = (GraphStep) startStep;
if (this.sqlgGraph.features().supportsBatchMode() && this.sqlgGraph.tx().isInNormalBatchMode()) {
this.sqlgGraph.tx().flush();
}
if (originalGraphStep.getIds().length > 0) {
Object id = originalGraphStep.getIds()[0];
if (id != null) {
Class clazz = id.getClass();
if (!Stream.of(originalGraphStep.getIds()).allMatch(i -> clazz.isAssignableFrom(i.getClass())))
throw Graph.Exceptions.idArgsMustBeEitherIdOrElement();
}
}
if (this.canNotBeOptimized()) {
this.logger.debug("gremlin not optimized due to path or tree step. " + this.traversal.toString() + "\nPath to gremlin:\n" + ExceptionUtils.getStackTrace(new Throwable()));
return;
}
combineSteps();
}