• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Scope类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.tinkerpop.gremlin.process.traversal.Scope的典型用法代码示例。如果您正苦于以下问题:Java Scope类的具体用法?Java Scope怎么用?Java Scope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Scope类属于org.apache.tinkerpop.gremlin.process.traversal包,在下文中一共展示了Scope类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getStepsOfAssignableClassRecursively

import org.apache.tinkerpop.gremlin.process.traversal.Scope; //导入依赖的package包/类
public static <S> List<S> getStepsOfAssignableClassRecursively(final Scope scope, final Class<S> stepClass, final Traversal.Admin<?, ?> traversal) {
    final List<S> list = new ArrayList<>();
    for (final Step<?, ?> step : traversal.getSteps()) {
        if (stepClass.isAssignableFrom(step.getClass()))
            list.add((S) step);
        if (step instanceof TraversalParent) {
            if (null == scope || Scope.local.equals(scope)) {
                for (final Traversal.Admin<?, ?> localChild : ((TraversalParent) step).getLocalChildren()) {
                    list.addAll(TraversalHelper.getStepsOfAssignableClassRecursively(stepClass, localChild));
                }
            }
            if (null == scope || Scope.global.equals(scope)) {
                for (final Traversal.Admin<?, ?> globalChild : ((TraversalParent) step).getGlobalChildren()) {
                    list.addAll(TraversalHelper.getStepsOfAssignableClassRecursively(stepClass, globalChild));
                }
            }
        }
    }
    return list;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:21,代码来源:TraversalHelper.java


示例2: hasStepOfAssignableClassRecursively

import org.apache.tinkerpop.gremlin.process.traversal.Scope; //导入依赖的package包/类
/**
 * Determine if the traversal has a step of an assignable class in the current {@link Traversal} and its
 * {@link Scope} child traversals.
 *
 * @param scope     the child traversal scope to check
 * @param stepClass the step class to look for
 * @param traversal the traversal in which to look for the given step class
 * @return <code>true</code> if any step in the given traversal (and its child traversals) is an instance of the
 * given <code>stepClass</code>, otherwise <code>false</code>.
 */
public static boolean hasStepOfAssignableClassRecursively(final Scope scope, final Class stepClass, final Traversal.Admin<?, ?> traversal) {
    for (final Step<?, ?> step : traversal.getSteps()) {
        if (stepClass.isAssignableFrom(step.getClass())) {
            return true;
        }
        if (step instanceof TraversalParent) {
            if (null == scope || Scope.local.equals(scope)) {
                for (final Traversal.Admin<?, ?> localChild : ((TraversalParent) step).getLocalChildren()) {
                    if (hasStepOfAssignableClassRecursively(stepClass, localChild)) return true;
                }
            }
            if (null == scope || Scope.global.equals(scope)) {
                for (final Traversal.Admin<?, ?> globalChild : ((TraversalParent) step).getGlobalChildren()) {
                    if (hasStepOfAssignableClassRecursively(stepClass, globalChild)) return true;
                }
            }
        }
    }
    return false;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:31,代码来源:TraversalHelper.java


示例3: data

import org.apache.tinkerpop.gremlin.process.traversal.Scope; //导入依赖的package包/类
@Parameterized.Parameters(name = "{0}")
public static Iterable<Object[]> data() {
    return Arrays.asList(new Object[][]{
            {"filter(x->true)", __.filter(x -> true), false},
            {"map(Traverser::get)", __.map(Traverser::get), false},
            {"sideEffect(x -> {int i = 1+1;})", __.sideEffect(x -> {
                int i = 1 + 1;
            }), false},
            {"select('a','b').by(Object::toString)", __.select("a", "b").by(Object::toString), false},
            {"order().by((a,b)->a.compareTo(b))", __.order().by((a, b) -> ((Integer) a).compareTo((Integer) b)), false},
            {"order(local).by((a,b)->a.compareTo(b))", __.order(Scope.local).by((a, b) -> ((Integer) a).compareTo((Integer) b)), false},
            {"__.choose(v->v.toString().equals(\"marko\"),__.out(),__.in())", __.choose(v -> v.toString().equals("marko"), __.out(), __.in()), false},
            {"order(local).by(values,decr)", __.order(Scope.local).by(Column.values, (a, b) -> ((Double) a).compareTo((Double) b)), false},
            //
            {"order(local).by(values,decr)", __.order(Scope.local).by(Column.values, Order.decr), true},
            {"order().by(label,decr)", __.order().by(T.label, Order.decr), true},
            {"groupCount().by(label)", __.groupCount().by(T.label), true},
    });
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:20,代码来源:LambdaRestrictionStrategyTest.java


示例4: isLegal

import org.apache.tinkerpop.gremlin.process.traversal.Scope; //导入依赖的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);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:22,代码来源:SparkStarBarrierInterceptor.java


示例5: apply

import org.apache.tinkerpop.gremlin.process.traversal.Scope; //导入依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
    final Graph graph = traversal.getGraph().orElse(EmptyGraph.instance()); // best guess at what the graph will be as its dynamically determined
    for (final TraversalVertexProgramStep step : TraversalHelper.getStepsOfClass(TraversalVertexProgramStep.class, traversal)) {
        final Traversal.Admin<?, ?> computerTraversal = step.generateProgram(graph, EmptyMemory.instance()).getTraversal().get().clone();
        if (!computerTraversal.isLocked())
            computerTraversal.applyStrategies();
        boolean doesMessagePass = TraversalHelper.hasStepOfAssignableClassRecursively(Scope.global, MULTI_ITERATION_CLASSES, computerTraversal);
        if (!doesMessagePass) {
            for (final VertexStep vertexStep : TraversalHelper.getStepsOfAssignableClassRecursively(Scope.global, VertexStep.class, computerTraversal)) {
                if (vertexStep.returnsVertex() || !vertexStep.getDirection().equals(Direction.OUT)) { // in-edges require message pass in OLAP
                    doesMessagePass = true;
                    break;
                }
            }
        }
        if (!doesMessagePass) {
            step.setComputer(step.getComputer()
                    // if no message passing, don't partition the loaded graph
                    .configure(Constants.GREMLIN_SPARK_SKIP_PARTITIONER, true)
                            // if no message passing, don't cache the loaded graph
                    .configure(Constants.GREMLIN_SPARK_SKIP_GRAPH_CACHE, true));
        }
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:26,代码来源:SparkSingleIterationStrategy.java


示例6: isLegal

import org.apache.tinkerpop.gremlin.process.traversal.Scope; //导入依赖的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);
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:25,代码来源:SparkStarBarrierInterceptor.java


示例7: g_V_asXaX_out_asXaX_out_asXaX_selectXaX_byXunfold_valuesXnameX_foldX_rangeXlocal_1_2X

import org.apache.tinkerpop.gremlin.process.traversal.Scope; //导入依赖的package包/类
@Test
public void g_V_asXaX_out_asXaX_out_asXaX_selectXaX_byXunfold_valuesXnameX_foldX_rangeXlocal_1_2X() throws IOException {
    loadModern();
    Graph g = this.sqlgGraph;
    assertModernGraph(g, true, false);
    DefaultGraphTraversal<Vertex, String> traversal = (DefaultGraphTraversal) g.traversal()
            .V().as("a")
            .out().as("a")
            .out().as("a")
            .<List<String>>select(Pop.all, "a")
            .by(__.unfold().values("name").fold())
            .range(Scope.local, 1, 2);
    Assert.assertEquals(5, traversal.getSteps().size());
    int counter = 0;
    while (traversal.hasNext()) {
        final String s = traversal.next();
        Assert.assertEquals("josh", s);
        counter++;
    }
    Assert.assertEquals(2, counter);
    Assert.assertEquals(3, traversal.getSteps().size());
}
 
开发者ID:pietermartin,项目名称:sqlg,代码行数:23,代码来源:TestGremlinCompileWithHas.java


示例8: isLegal

import org.apache.tinkerpop.gremlin.process.traversal.Scope; //导入依赖的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);
}
 
开发者ID:graknlabs,项目名称:grakn,代码行数:31,代码来源:GraknSparkStarBarrierInterceptor.java


示例9: getTraversals

import org.apache.tinkerpop.gremlin.process.traversal.Scope; //导入依赖的package包/类
@Override
protected List<Traversal> getTraversals() {
    return Arrays.asList(
            __.sample(Scope.local, 5),
            __.sample(Scope.local, 10)
    );
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:8,代码来源:SampleLocalStepTest.java


示例10: shouldSelectSubsetsCorrectly

import org.apache.tinkerpop.gremlin.process.traversal.Scope; //导入依赖的package包/类
@Test
public void shouldSelectSubsetsCorrectly() {
    final List<Integer> list = new ArrayList<>();
    for (int i = 0; i < 100; i++) {
        list.add(i);
    }
    for(int i=0; i<100; i++) {
        List<Integer> result;
        result = __.inject(list).sample(Scope.local, i).next();
        assertEquals(i, result.size());
        assertEquals(i, new HashSet<>(result).size());
        assertTrue(list.containsAll(result));
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:15,代码来源:SampleLocalStepTest.java


示例11: testReturnTypes

import org.apache.tinkerpop.gremlin.process.traversal.Scope; //导入依赖的package包/类
@Test
public void testReturnTypes() {
    assertEquals(3d, __.__(2, 4).fold().mean(Scope.local).next());
    assertEquals(3d, __.__((short) 2, (short) 4).fold().mean(Scope.local).next()); // why? because the internal counter is a Long value
    assertEquals(BigDecimal.ONE, __.__(BigInteger.ONE, BigInteger.ONE).fold().mean(Scope.local).next());
    assertEquals(BigDecimal.ONE, __.__((short) 1, BigInteger.ONE).fold().mean(Scope.local).next());
    assertEquals(BigDecimal.ONE, __.__(BigInteger.ONE, (short) 1).fold().mean(Scope.local).next());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:9,代码来源:MeanLocalStepTest.java


示例12: getTraversals

import org.apache.tinkerpop.gremlin.process.traversal.Scope; //导入依赖的package包/类
@Override
protected List<Traversal> getTraversals() {
    return Arrays.asList(
            __.limit(Scope.local, 10L),
            __.range(Scope.local, 1L, 10L)
    );
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:8,代码来源:RangeLocalStepTest.java


示例13: getTraversals

import org.apache.tinkerpop.gremlin.process.traversal.Scope; //导入依赖的package包/类
@Override
protected List<Traversal> getTraversals() {
    return Arrays.asList(
            __.order(Scope.local),
            __.order(Scope.local).by(Order.decr),
            __.order(Scope.local).by("age", Order.incr),
            __.order(Scope.local).by("age", Order.decr),
            __.order(Scope.local).by(outE().count(), Order.incr),
            __.order(Scope.local).by("age", Order.incr).by(outE().count(), Order.incr),
            __.order(Scope.local).by(outE().count(), Order.incr).by("age", Order.incr)
    );
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:13,代码来源:OrderLocalStepTest.java


示例14: shouldNotThrowContractException

import org.apache.tinkerpop.gremlin.process.traversal.Scope; //导入依赖的package包/类
@Test
public void shouldNotThrowContractException() {
    for (int x = 0; x < 1000; x++) {
        final List<Integer> list = new ArrayList<>();
        for (int i = 0; i < 1000; i++) {
            list.add(i);
        }
        __.inject(list).order(Scope.local).by(Order.shuffle).iterate();
        __.inject(list).order(Scope.local).by().by(Order.shuffle).iterate();
        __.inject(list).order(Scope.local).by(Order.shuffle).by().iterate();
        __.inject(list).order(Scope.local).by(__.identity(), Order.shuffle).iterate();
        __.inject(list).order(Scope.local).by().by(__.identity(), Order.shuffle).iterate();
        __.inject(list).order(Scope.local).by(__.identity(), Order.shuffle).by().iterate();
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:16,代码来源:OrderLocalStepTest.java


示例15: getTraversals

import org.apache.tinkerpop.gremlin.process.traversal.Scope; //导入依赖的package包/类
@Override
protected List<Traversal> getTraversals() {
    return Arrays.asList(
            __.tail(Scope.local, 5L),
            __.tail(Scope.local, 10L)
    );
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:8,代码来源:TailLocalStepTest.java


示例16: getTraversals

import org.apache.tinkerpop.gremlin.process.traversal.Scope; //导入依赖的package包/类
@Override
protected List<Traversal> getTraversals() {
    return Arrays.asList(
            __.groupV3d0("a").by(T.label),
            __.groupV3d0("a").by(T.label).by("name"),
            __.groupV3d0("a").by(T.label).by("name").by(count(Scope.local))
    );
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:9,代码来源:GroupSideEffectStepV3d0Test.java


示例17: benchmarkGroup

import org.apache.tinkerpop.gremlin.process.traversal.Scope; //导入依赖的package包/类
@Test
@Ignore
public void benchmarkGroup() throws Exception {
    Graph graph = TinkerGraph.open();
    GraphTraversalSource g = graph.traversal();
    graph.io(GraphMLIo.build()).readGraph("../data/grateful-dead.xml");
    /////////

    //g.V().group().by(T.label).by(values("name")).forEachRemaining(x -> logger.info(x.toString()));

    System.out.println("group: " + g.V().both("followedBy").both("followedBy").group().by("songType").by(count()).next());
    System.out.println("groupV3d0: " + g.V().both("followedBy").both("followedBy").groupV3d0().by("songType").by().by(__.count(Scope.local)).next());

    //
    System.out.println("\n\nBig Values -- by(songType)");

    System.out.println("group: " + TimeUtil.clock(10, () -> g.V().both("followedBy").both("followedBy").group().by("songType").by(count()).next()));
    System.out.println("groupV3d0: " + TimeUtil.clock(10, () -> g.V().both("followedBy").both("followedBy").groupV3d0().by("songType").by().by(__.count(Scope.local)).next()) + "\n");

    ///

    System.out.println("group: " + TimeUtil.clock(10, () -> g.V().both("followedBy").both("followedBy").group().by("songType").by(fold()).next()));
    System.out.println("groupV3d0: " + TimeUtil.clock(10, () -> g.V().both("followedBy").both("followedBy").groupV3d0().by("songType").by().next()));

    ///
    System.out.println("\n\nBig Keys -- by(name)");

    System.out.println("group: " + TimeUtil.clock(10, () -> g.V().both("followedBy").both("followedBy").group().by("name").by(count()).next()));
    System.out.println("groupV3d0: " + TimeUtil.clock(10, () -> g.V().both("followedBy").both("followedBy").groupV3d0().by("name").by().by(__.count(Scope.local)).next()) + "\n");

    ///

    System.out.println("group: " + TimeUtil.clock(10, () -> g.V().both("followedBy").both("followedBy").group().by("name").by(fold()).next()));
    System.out.println("groupV3d0: " + TimeUtil.clock(10, () -> g.V().both("followedBy").both("followedBy").groupV3d0().by("name").by().next()));

}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:37,代码来源:TinkerGraphPlayTest.java


示例18: apply

import org.apache.tinkerpop.gremlin.process.traversal.Scope; //导入依赖的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
            }
        }
    }
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:33,代码来源:RepeatUnrollStrategy.java


示例19: data

import org.apache.tinkerpop.gremlin.process.traversal.Scope; //导入依赖的package包/类
@Parameterized.Parameters(name = "{0}")
public static Iterable<Object[]> data() {
    return Arrays.asList(new Object[][]{
            {"map(Lambda.function('true')}", __.map(Lambda.function("true")), false},
            {"filter(Lambda.predicate('true')}", __.filter(Lambda.predicate("true")), false},
            {"filter(x->true)", __.filter(x -> true), false},
            {"map(Traverser::get)", __.map(Traverser::get), false},
            {"sideEffect(x -> {int i = 1+1;})", __.sideEffect(x -> {
                int i = 1 + 1;
            }), false},
            {"select('a').by(values)", __.select("a").by(values), true},
            {"select('a','b').by(Object::toString)", __.select("a", "b").by(Object::toString), false},
            {"order().by((a,b)->a.compareTo(b))", __.order().by((a, b) -> ((Integer) a).compareTo((Integer) b)), false},
            {"order(local).by((a,b)->a.compareTo(b))", __.order(Scope.local).by((a, b) -> ((Integer) a).compareTo((Integer) b)), false},
            {"__.choose(v->v.toString().equals(\"marko\"),__.out(),__.in())", __.choose(v -> v.toString().equals("marko"), __.out(), __.in()), false},
            {"order().by(label,decr)", __.order().by(T.label, Order.decr), true},
            {"order(local).by(values)", __.order(Scope.local).by(values), true},
            {"order(local).by(values,decr)", __.order(Scope.local).by(values,Order.decr), true},
            {"order(local).by(values,(a,b) -> a.compareTo(b))", __.order(Scope.local).by(values, (a, b) -> ((Double) a).compareTo((Double) b)), false},
            //
            {"groupCount().by(label)", __.groupCount().by(T.label), true},
            //
            {"sack(sum).by('age')", __.sack(sum).by("age"), true},
            {"sack{a,b -> a+b}.by('age')", __.sack((a, b) -> (int) a + (int) b).by("age"), false},
            //
            {"order().by(outE('rating').values('stars').mean()).profile()", __.order().by(outE("ratings").values("stars").mean()).profile(), true}
    });
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:29,代码来源:LambdaRestrictionStrategyTest.java


示例20: apply

import org.apache.tinkerpop.gremlin.process.traversal.Scope; //导入依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
    final Graph graph = traversal.getGraph().orElse(EmptyGraph.instance()); // best guess at what the graph will be as its dynamically determined
    for (final TraversalVertexProgramStep step : TraversalHelper.getStepsOfClass(TraversalVertexProgramStep.class, traversal)) {
        final Traversal.Admin<?, ?> computerTraversal = step.generateProgram(graph, EmptyMemory.instance()).getTraversal().get().clone();
        if (!computerTraversal.isLocked())
            computerTraversal.applyStrategies();
        ///
        boolean doesMessagePass = TraversalHelper.hasStepOfAssignableClassRecursively(Scope.global, MULTI_ITERATION_CLASSES, computerTraversal);
        if (!doesMessagePass) {
            for (final VertexStep vertexStep : TraversalHelper.getStepsOfAssignableClassRecursively(Scope.global, VertexStep.class, computerTraversal)) {
                if (vertexStep.returnsVertex() || !vertexStep.getDirection().equals(Direction.OUT)) { // in-edges require message pass in OLAP
                    doesMessagePass = true;
                    break;
                }
            }
        }
        if (!doesMessagePass &&
                !MessagePassingReductionStrategy.endsWithElement(computerTraversal.getEndStep()) &&
                !(computerTraversal.getTraverserRequirements().contains(TraverserRequirement.LABELED_PATH) || // TODO: remove this when dynamic detachment is available in 3.3.0
                        computerTraversal.getTraverserRequirements().contains(TraverserRequirement.PATH))) {  // TODO: remove this when dynamic detachment is available in 3.3.0
            step.setComputer(step.getComputer()
                    // if no message passing, don't partition the loaded graph
                    .configure(Constants.GREMLIN_SPARK_SKIP_PARTITIONER, true)
                    // if no message passing, don't cache the loaded graph
                    .configure(Constants.GREMLIN_SPARK_SKIP_GRAPH_CACHE, true));
        }
    }
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:30,代码来源:SparkSingleIterationStrategy.java



注:本文中的org.apache.tinkerpop.gremlin.process.traversal.Scope类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AbstractEditPolicy类代码示例发布时间:2022-05-23
下一篇:
Java Config类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap