本文整理汇总了Java中org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper.copyLabels方法的典型用法代码示例。如果您正苦于以下问题:Java TraversalHelper.copyLabels方法的具体用法?Java TraversalHelper.copyLabels怎么用?Java TraversalHelper.copyLabels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper
的用法示例。
在下文中一共展示了TraversalHelper.copyLabels方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的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.util.TraversalHelper; //导入方法依赖的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();
}
}
}
示例3: apply
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
for (final VertexStep originalVertexStep : TraversalHelper.getStepsOfClass(VertexStep.class, traversal)) {
final HBaseVertexStep<?> hbaseVertexStep = new HBaseVertexStep<>(originalVertexStep);
TraversalHelper.replaceStep(originalVertexStep, hbaseVertexStep, traversal);
Step<?, ?> currentStep = hbaseVertexStep.getNextStep();
while (currentStep instanceof HasStep || currentStep instanceof NoOpBarrierStep) {
if (currentStep instanceof HasStep) {
for (final HasContainer hasContainer : ((HasContainerHolder) currentStep).getHasContainers()) {
hbaseVertexStep.addHasContainer(hasContainer);
}
TraversalHelper.copyLabels(currentStep, currentStep.getPreviousStep(), false);
traversal.removeStep(currentStep);
}
currentStep = currentStep.getNextStep();
}
}
}
示例4: apply
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的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: processTraversalFilterStep
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
private static final boolean processTraversalFilterStep(final TraversalFilterStep<?> step, final Traversal.Admin<?, ?> traversal) {
final Traversal.Admin<?, ?> childTraversal = step.getLocalChildren().get(0);
if (TraversalHelper.hasAllStepsOfClass(childTraversal, FilterStep.class) &&
!TraversalHelper.hasStepOfClass(childTraversal,
DropStep.class,
RangeGlobalStep.class,
DedupGlobalStep.class,
LambdaHolder.class)) {
TraversalHelper.applySingleLevelStrategies(traversal, childTraversal, InlineFilterStrategy.class);
final Step<?, ?> finalStep = childTraversal.getEndStep();
TraversalHelper.insertTraversal((Step) step, childTraversal, traversal);
TraversalHelper.copyLabels(step, finalStep, false);
traversal.removeStep(step);
return true;
}
return false;
}
示例6: apply
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
boolean modified = true;
while (modified) {
modified = false;
final List<Step> steps = traversal.getSteps();
for (int i = 0; i < steps.size() - 1; i++) {
final Step<?, ?> step = steps.get(i);
final Step<?, ?> nextStep = step.getNextStep();
if (!usesLabels(nextStep, step.getLabels())) {
final int nextRank = getStepRank(nextStep);
if (nextRank != 0) {
if (!step.getLabels().isEmpty()) {
TraversalHelper.copyLabels(step, nextStep, true);
modified = true;
}
if (getStepRank(step) > nextRank) {
traversal.removeStep(nextStep);
traversal.addStep(i, nextStep);
modified = true;
}
}
}
}
}
}
示例7: apply
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的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();
}
}
}
示例8: apply
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
if (traversal.getSteps().size() <= 1)
return;
for (final IdentityStep<?> identityStep : TraversalHelper.getStepsOfClass(IdentityStep.class, traversal)) {
if (identityStep.getLabels().isEmpty() || !(identityStep.getPreviousStep() instanceof EmptyStep)) {
TraversalHelper.copyLabels(identityStep, identityStep.getPreviousStep(), false);
traversal.removeStep(identityStep);
}
}
}
示例9: processOrStep
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
private static final boolean processOrStep(final OrStep<?> step, final Traversal.Admin<?, ?> traversal) {
boolean process = true;
String key = null;
P predicate = null;
final List<String> labels = new ArrayList<>();
for (final Traversal.Admin<?, ?> childTraversal : step.getLocalChildren()) {
InlineFilterStrategy.instance().apply(childTraversal); // todo: this may be a bad idea, but I can't seem to find a test case to break it
for (final Step<?, ?> childStep : childTraversal.getSteps()) {
if (childStep instanceof HasStep) {
for (final HasContainer hasContainer : ((HasStep<?>) childStep).getHasContainers()) {
if (null == key)
key = hasContainer.getKey();
else if (!hasContainer.getKey().equals(key)) {
process = false;
break;
}
predicate = null == predicate ?
hasContainer.getPredicate() :
predicate.or(hasContainer.getPredicate());
}
labels.addAll(childStep.getLabels());
} else {
process = false;
break;
}
}
if (!process)
break;
}
if (process) {
final HasStep hasStep = new HasStep<>(traversal, new HasContainer(key, predicate));
TraversalHelper.replaceStep(step, hasStep, traversal);
TraversalHelper.copyLabels(step, hasStep, false);
for (final String label : labels) {
hasStep.addLabel(label);
}
return true;
}
return false;
}
示例10: apply
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的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
}
}
}
}
示例11: apply
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的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;
}
}
示例12: applyCriterion
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
private static void applyCriterion(final List<Step> stepsToApplyCriterionAfter, final Traversal.Admin traversal,
final Traversal.Admin<? extends Element, ?> criterion) {
for (final Step<?, ?> step : stepsToApplyCriterionAfter) {
// re-assign the step label to the criterion because the label should apply seamlessly after the filter
final Step filter = new TraversalFilterStep<>(traversal, criterion.clone());
TraversalHelper.insertAfterStep(filter, step, traversal);
TraversalHelper.copyLabels(step, filter, true);
}
}