本文整理汇总了Java中org.apache.tinkerpop.gremlin.process.traversal.step.Barrier类的典型用法代码示例。如果您正苦于以下问题:Java Barrier类的具体用法?Java Barrier怎么用?Java Barrier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Barrier类属于org.apache.tinkerpop.gremlin.process.traversal.step包,在下文中一共展示了Barrier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isLegal
import org.apache.tinkerpop.gremlin.process.traversal.step.Barrier; //导入依赖的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);
}
示例2: modulateBy
import org.apache.tinkerpop.gremlin.process.traversal.step.Barrier; //导入依赖的package包/类
@Override
public void modulateBy(final Traversal.Admin<?, ?> kvTraversal) {
if ('k' == this.state) {
this.keyTraversal = this.integrateChild(kvTraversal);
this.state = 'v';
} else if ('v' == this.state) {
this.valueTraversal = this.integrateChild(GroupStep.convertValueTraversal(kvTraversal));
this.barrierStep = TraversalHelper.getFirstStepOfAssignableClass(Barrier.class, this.valueTraversal).orElse(null);
this.getTraversal().getSideEffects().register(this.sideEffectKey, null,
new GroupStep.GroupBiOperator<>(null == this.barrierStep ?
Operator.assign :
this.barrierStep.getMemoryComputeKey().getReducer()));
this.state = 'x';
} else {
throw new IllegalStateException("The key and value traversals for group()-step have already been set: " + this);
}
}
示例3: isLegal
import org.apache.tinkerpop.gremlin.process.traversal.step.Barrier; //导入依赖的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);
}
示例4: isLegal
import org.apache.tinkerpop.gremlin.process.traversal.step.Barrier; //导入依赖的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);
}
示例5: GroupBiOperator
import org.apache.tinkerpop.gremlin.process.traversal.step.Barrier; //导入依赖的package包/类
public GroupBiOperator(final Traversal.Admin<?, V> valueTraversal) {
// if there is a lambda that can not be serialized, then simply use TraverserSets
if (TraversalHelper.hasStepOfAssignableClassRecursively(LambdaHolder.class, valueTraversal)) {
this.valueTraversal = null;
this.barrierStep = null;
} else {
this.valueTraversal = valueTraversal;
this.barrierStep = TraversalHelper.getFirstStepOfAssignableClass(Barrier.class, this.valueTraversal).orElse(null);
}
}
示例6: generatePreTraversal
import org.apache.tinkerpop.gremlin.process.traversal.step.Barrier; //导入依赖的package包/类
public static Traversal.Admin<?, ?> generatePreTraversal(final Traversal.Admin<?, ?> valueTraversal) {
if (!TraversalHelper.hasStepOfAssignableClass(Barrier.class, valueTraversal))
return valueTraversal;
final Traversal.Admin<?, ?> first = __.identity().asAdmin();
for (final Step step : valueTraversal.getSteps()) {
if (step instanceof Barrier)
break;
first.addStep(step.clone());
}
return first.getSteps().size() == 1 ? null : first;
}
示例7: addGlobalChildOption
import org.apache.tinkerpop.gremlin.process.traversal.step.Barrier; //导入依赖的package包/类
@Override
public void addGlobalChildOption(final M pickToken, final Traversal.Admin<S, E> traversalOption) {
if (this.traversalOptions.containsKey(pickToken))
this.traversalOptions.get(pickToken).add(traversalOption);
else
this.traversalOptions.put(pickToken, new ArrayList<>(Collections.singletonList(traversalOption)));
traversalOption.addStep(new EndStep(traversalOption));
if (!this.hasBarrier && !TraversalHelper.getStepsOfAssignableClassRecursively(Barrier.class, traversalOption).isEmpty())
this.hasBarrier = true;
this.integrateChild(traversalOption);
}
示例8: apply
import org.apache.tinkerpop.gremlin.process.traversal.step.Barrier; //导入依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
if (TraversalHelper.onGraphComputer(traversal))
return;
for (int i = 0; i < traversal.getSteps().size(); i++) {
if (traversal.getSteps().get(i) instanceof RepeatStep) {
final RepeatStep<?> repeatStep = (RepeatStep) traversal.getSteps().get(i);
if (null == repeatStep.getEmitTraversal() && repeatStep.getUntilTraversal() instanceof LoopTraversal && ((LoopTraversal) repeatStep.getUntilTraversal()).getMaxLoops() > 0) {
final Traversal.Admin<?, ?> repeatTraversal = repeatStep.getGlobalChildren().get(0);
final int repeatLength = repeatTraversal.getSteps().size() - 1;
repeatTraversal.removeStep(repeatLength); // removes the RepeatEndStep
int insertIndex = i;
final int loops = (int) ((LoopTraversal) repeatStep.getUntilTraversal()).getMaxLoops();
for (int j = 0; j < loops; j++) {
TraversalHelper.insertTraversal(insertIndex, repeatTraversal.clone(), traversal);
insertIndex = insertIndex + repeatLength;
if (j != (loops - 1) || !(traversal.getSteps().get(insertIndex).getNextStep() instanceof Barrier)) // only add a final NoOpBarrier is subsequent step is not a barrier
traversal.addStep(++insertIndex, new NoOpBarrierStep<>(traversal, 5000));
}
// label last step if repeat() was labeled
if (!repeatStep.getLabels().isEmpty()) {
final Step<?, ?> lastStep = traversal.getSteps().get(insertIndex);
repeatStep.getLabels().forEach(lastStep::addLabel);
}
traversal.removeStep(i); // remove the RepeatStep
}
}
}
}
示例9: GroupStep
import org.apache.tinkerpop.gremlin.process.traversal.step.Barrier; //导入依赖的package包/类
public GroupStep(final Traversal.Admin traversal) {
super(traversal);
this.valueTraversal = this.integrateChild(__.fold().asAdmin());
this.barrierStep = TraversalHelper.getFirstStepOfAssignableClass(Barrier.class, this.valueTraversal).orElse(null);
this.setReducingBiOperator(new GroupBiOperator<>(null == this.barrierStep ? Operator.assign : this.barrierStep.getMemoryComputeKey().getReducer()));
this.setSeedSupplier(HashMapSupplier.instance());
}
示例10: modulateBy
import org.apache.tinkerpop.gremlin.process.traversal.step.Barrier; //导入依赖的package包/类
@Override
public void modulateBy(final Traversal.Admin<?, ?> kvTraversal) {
if ('k' == this.state) {
this.keyTraversal = this.integrateChild(kvTraversal);
this.state = 'v';
} else if ('v' == this.state) {
this.valueTraversal = this.integrateChild(convertValueTraversal(kvTraversal));
this.barrierStep = TraversalHelper.getFirstStepOfAssignableClass(Barrier.class, this.valueTraversal).orElse(null);
this.setReducingBiOperator(new GroupBiOperator<>(null == this.barrierStep ? Operator.assign : this.barrierStep.getMemoryComputeKey().getReducer()));
this.state = 'x';
} else {
throw new IllegalStateException("The key and value traversals for group()-step have already been set: " + this);
}
}
示例11: doFinalReduction
import org.apache.tinkerpop.gremlin.process.traversal.step.Barrier; //导入依赖的package包/类
public static <K, V> Map<K, V> doFinalReduction(final Map<K, Object> map, final Traversal.Admin<?, V> valueTraversal) {
TraversalHelper.getFirstStepOfAssignableClass(Barrier.class, valueTraversal).ifPresent(barrierStep -> {
for (final K key : map.keySet()) {
valueTraversal.reset();
barrierStep.addBarrier(map.get(key));
if (valueTraversal.hasNext())
map.put(key, valueTraversal.next());
}
});
return (Map<K, V>) map;
}
示例12: GroupSideEffectStep
import org.apache.tinkerpop.gremlin.process.traversal.step.Barrier; //导入依赖的package包/类
public GroupSideEffectStep(final Traversal.Admin traversal, final String sideEffectKey) {
super(traversal);
this.sideEffectKey = sideEffectKey;
this.valueTraversal = this.integrateChild(__.fold().asAdmin());
this.barrierStep = TraversalHelper.getFirstStepOfAssignableClass(Barrier.class, this.valueTraversal).orElse(null);
this.getTraversal().getSideEffects().registerIfAbsent(this.sideEffectKey, HashMapSupplier.instance(),
new GroupStep.GroupBiOperator<>(null == this.barrierStep ?
Operator.assign :
this.barrierStep.getMemoryComputeKey().getReducer()));
}
示例13: apply
import org.apache.tinkerpop.gremlin.process.traversal.step.Barrier; //导入依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
if (TraversalHelper.onGraphComputer(traversal))
return;
for (int i = 0; i < traversal.getSteps().size(); i++) {
if (traversal.getSteps().get(i) instanceof RepeatStep) {
final RepeatStep<?> repeatStep = (RepeatStep) traversal.getSteps().get(i);
if (null == repeatStep.getEmitTraversal() && null != repeatStep.getRepeatTraversal() &&
repeatStep.getUntilTraversal() instanceof LoopTraversal && ((LoopTraversal) repeatStep.getUntilTraversal()).getMaxLoops() > 0 &&
!TraversalHelper.hasStepOfAssignableClassRecursively(Scope.global, DedupGlobalStep.class, repeatStep.getRepeatTraversal()) &&
!TraversalHelper.hasStepOfAssignableClassRecursively(INVALIDATING_STEPS, repeatStep.getRepeatTraversal())) {
final Traversal.Admin<?, ?> repeatTraversal = repeatStep.getGlobalChildren().get(0);
repeatTraversal.removeStep(repeatTraversal.getSteps().size() - 1); // removes the RepeatEndStep
TraversalHelper.applySingleLevelStrategies(traversal, repeatTraversal, RepeatUnrollStrategy.class);
final int repeatLength = repeatTraversal.getSteps().size();
int insertIndex = i;
final int loops = (int) ((LoopTraversal) repeatStep.getUntilTraversal()).getMaxLoops();
for (int j = 0; j < loops; j++) {
TraversalHelper.insertTraversal(insertIndex, repeatTraversal.clone(), traversal);
insertIndex = insertIndex + repeatLength;
if (j != (loops - 1) || !(traversal.getSteps().get(insertIndex).getNextStep() instanceof Barrier)) // only add a final NoOpBarrier is subsequent step is not a barrier
traversal.addStep(++insertIndex, new NoOpBarrierStep<>(traversal, MAX_BARRIER_SIZE));
}
// label last step if repeat() was labeled
if (!repeatStep.getLabels().isEmpty())
TraversalHelper.copyLabels(repeatStep, traversal.getSteps().get(insertIndex), false);
traversal.removeStep(i); // remove the RepeatStep
}
}
}
}
示例14: apply
import org.apache.tinkerpop.gremlin.process.traversal.step.Barrier; //导入依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
if (TraversalHelper.onGraphComputer(traversal) ||
traversal.getTraverserRequirements().contains(TraverserRequirement.PATH) ||
(IS_TESTING && ((TraversalHelper.hasStepOfAssignableClass(ProfileStep.class, TraversalHelper.getRootTraversal(traversal)) ||
TraversalHelper.hasStepOfAssignableClass(ProfileSideEffectStep.class, TraversalHelper.getRootTraversal(traversal)))))) // necessary cause ProfileTest analyzes counts
return;
boolean foundFlatMap = false;
boolean labeledPath = false;
for (int i = 0; i < traversal.getSteps().size(); i++) {
final Step<?, ?> step = traversal.getSteps().get(i);
if (step instanceof PathProcessor) {
final Set<String> keepLabels = ((PathProcessor) step).getKeepLabels();
if (null != keepLabels && keepLabels.isEmpty()) // if no more path data, then start barrier'ing again
labeledPath = false;
}
if (step instanceof FlatMapStep &&
!(step instanceof VertexStep && ((VertexStep) step).returnsEdge()) ||
(step instanceof GraphStep &&
(i > 0 || ((GraphStep) step).getIds().length >= BIG_START_SIZE ||
(((GraphStep) step).getIds().length == 0 && !(step.getNextStep() instanceof HasStep))))) {
if (foundFlatMap && !labeledPath &&
!(step.getNextStep() instanceof Barrier) &&
!(step.getNextStep() instanceof NoneStep) &&
!(step.getNextStep() instanceof EmptyStep)) {
final Step noOpBarrierStep = new NoOpBarrierStep<>(traversal, MAX_BARRIER_SIZE);
TraversalHelper.copyLabels(step, noOpBarrierStep, true);
TraversalHelper.insertAfterStep(noOpBarrierStep, step, traversal);
} else
foundFlatMap = true;
}
if (!step.getLabels().isEmpty())
labeledPath = true;
}
}
示例15: insertElementId
import org.apache.tinkerpop.gremlin.process.traversal.step.Barrier; //导入依赖的package包/类
private static boolean insertElementId(final Step<?, ?> barrier) {
if (!(barrier instanceof Barrier))
return false;
else if (!endsWithElement(barrier.getPreviousStep()))
return false;
else if (barrier instanceof CountGlobalStep)
return true;
else if (barrier instanceof DedupGlobalStep &&
((DedupGlobalStep) barrier).getScopeKeys().isEmpty() &&
((DedupGlobalStep) barrier).getLocalChildren().isEmpty() &&
barrier.getNextStep() instanceof CountGlobalStep)
return true;
else
return false;
}