当前位置: 首页>>代码示例>>Java>>正文


Java TraversalStrategy类代码示例

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


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

示例1: ser

import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy; //导入依赖的package包/类
public void ser(final TraversalExplanation te, final JsonGenerator jsonGenerator) throws IOException {
    final Map<String, Object> m = new HashMap<>();
    m.put(GraphSONTokens.ORIGINAL, getStepsAsList(te.getOriginalTraversal()));

    final List<Pair<TraversalStrategy, Traversal.Admin<?,?>>> strategyTraversals = te.getStrategyTraversals();

    final List<Map<String,Object>> intermediates = new ArrayList<>();
    for (final Pair<TraversalStrategy, Traversal.Admin<?, ?>> pair : strategyTraversals) {
        final Map<String,Object> intermediate = new HashMap<>();
        intermediate.put(GraphSONTokens.STRATEGY, pair.getValue0().toString());
        intermediate.put(GraphSONTokens.CATEGORY, pair.getValue0().getTraversalCategory().getSimpleName());
        intermediate.put(GraphSONTokens.TRAVERSAL, getStepsAsList(pair.getValue1()));
        intermediates.add(intermediate);
    }
    m.put(GraphSONTokens.INTERMEDIATE, intermediates);

    if (strategyTraversals.isEmpty())
        m.put(GraphSONTokens.FINAL, getStepsAsList(te.getOriginalTraversal()));
    else
        m.put(GraphSONTokens.FINAL, getStepsAsList(strategyTraversals.get(strategyTraversals.size() - 1).getValue1()));

    jsonGenerator.writeObject(m);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:24,代码来源:GraphSONSerializers.java

示例2: addStrategies

import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy; //导入依赖的package包/类
@Override
@SuppressWarnings({"unchecked", "varargs"})
public TraversalStrategies addStrategies(final TraversalStrategy<?>... strategies) {
    final List<TraversalStrategy<?>> toRemove = new ArrayList<>(strategies.length);
    for (final TraversalStrategy<?> addStrategy : strategies) {
        for (final TraversalStrategy<?> currentStrategy : this.traversalStrategies) {
            if (addStrategy.getClass().equals(currentStrategy.getClass())) {
                toRemove.add(currentStrategy);
                break;
            }
        }
    }
    this.traversalStrategies.removeAll(toRemove);
    Collections.addAll(this.traversalStrategies, strategies);
    this.traversalStrategies = TraversalStrategies.sortStrategies(this.traversalStrategies);
    return this;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:18,代码来源:DefaultTraversalStrategies.java

示例3: generateProgram

import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy; //导入依赖的package包/类
@Override
public TraversalVertexProgram generateProgram(final Graph graph, final Memory memory) {
    final Traversal.Admin<?, ?> computerSpecificTraversal = this.computerTraversal.getPure();
    final TraversalStrategies computerSpecificStrategies = this.getTraversal().getStrategies().clone();
    TraversalStrategies.GlobalCache.getStrategies(graph.getClass())
            .toList()
            .stream()
            .filter(s -> s instanceof TraversalStrategy.ProviderOptimizationStrategy)
            .forEach(computerSpecificStrategies::addStrategies);
    computerSpecificTraversal.setStrategies(computerSpecificStrategies);
    computerSpecificTraversal.setSideEffects(new MemoryTraversalSideEffects(this.getTraversal().getSideEffects()));
    computerSpecificTraversal.setParent(this);
    final TraversalVertexProgram.Builder builder = TraversalVertexProgram.build().traversal(computerSpecificTraversal);
    if (memory.exists(TraversalVertexProgram.HALTED_TRAVERSERS))
        builder.haltedTraversers(memory.get(TraversalVertexProgram.HALTED_TRAVERSERS));
    return builder.create(graph);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:18,代码来源:TraversalVertexProgramStep.java

示例4: serialize

import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy; //导入依赖的package包/类
@Override
public void serialize(final TraversalExplanation traversalExplanation, final JsonGenerator jsonGenerator,
                      final SerializerProvider serializerProvider) throws IOException {
    final Map<String, Object> m = new HashMap<>();
    m.put(GraphSONTokens.ORIGINAL, getStepsAsList(traversalExplanation.getOriginalTraversal()));

    final List<Pair<TraversalStrategy, Traversal.Admin<?, ?>>> strategyTraversals = traversalExplanation.getStrategyTraversals();

    final List<Map<String, Object>> intermediates = new ArrayList<>();
    for (final Pair<TraversalStrategy, Traversal.Admin<?, ?>> pair : strategyTraversals) {
        final Map<String, Object> intermediate = new HashMap<>();
        intermediate.put(GraphSONTokens.STRATEGY, pair.getValue0().toString());
        intermediate.put(GraphSONTokens.CATEGORY, pair.getValue0().getTraversalCategory().getSimpleName());
        intermediate.put(GraphSONTokens.TRAVERSAL, getStepsAsList(pair.getValue1()));
        intermediates.add(intermediate);
    }
    m.put(GraphSONTokens.INTERMEDIATE, intermediates);

    if (strategyTraversals.isEmpty())
        m.put(GraphSONTokens.FINAL, getStepsAsList(traversalExplanation.getOriginalTraversal()));
    else
        m.put(GraphSONTokens.FINAL, getStepsAsList(strategyTraversals.get(strategyTraversals.size() - 1).getValue1()));

    jsonGenerator.writeObject(m);
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:26,代码来源:GraphSONSerializersV3d0.java

示例5: doTest

import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy; //导入依赖的package包/类
@Test
public void doTest() {
    final TraversalStrategies strategies = new DefaultTraversalStrategies();
    strategies.addStrategies(TinkerGraphCountStrategy.instance());
    for (final TraversalStrategy strategy : this.otherStrategies) {
        strategies.addStrategies(strategy);
    }
    this.original.asAdmin().setStrategies(strategies);
    this.original.asAdmin().applyStrategies();
    assertEquals(this.optimized, this.original);
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:12,代码来源:TinkerGraphCountStrategyTest.java

示例6: doTest

import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy; //导入依赖的package包/类
@Test
public void doTest() {
    final TraversalStrategies strategies = new DefaultTraversalStrategies();
    strategies.addStrategies(TinkerGraphStepStrategy.instance());
    for (final TraversalStrategy strategy : this.otherStrategies) {
        strategies.addStrategies(strategy);
    }
    this.original.asAdmin().setStrategies(strategies);
    this.original.asAdmin().applyStrategies();
    assertEquals(this.optimized, this.original);
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:12,代码来源:TinkerGraphStepStrategyTest.java

示例7: traversal

import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy; //导入依赖的package包/类
@Override
public GraphTraversalSource traversal(final Graph graph) {
    final List<Class> toRemove = TraversalStrategies.GlobalCache.getStrategies(TinkerGraph.class).toList().stream()
            .map(TraversalStrategy::getClass)
            .filter(clazz -> !REQUIRED_STRATEGIES.contains(clazz))
            .collect(Collectors.toList());
    return graph.traversal().withoutStrategies(toRemove.toArray(new Class[toRemove.size()]));
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:9,代码来源:TinkerGraphNoStrategyProvider.java

示例8: traversal

import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy; //导入依赖的package包/类
@Override
public GraphTraversalSource traversal(final Graph graph) {
    final List<Class> toRemove = TraversalStrategies.GlobalCache.getStrategies(TinkerGraph.class).toList().stream()
            .map(TraversalStrategy::getClass)
            .filter(clazz -> !REQUIRED_STRATEGIES.contains(clazz))
            .collect(Collectors.toList());
    return graph.traversal().withoutStrategies(toRemove.toArray(new Class[toRemove.size()])).withComputer();
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:9,代码来源:TinkerGraphNoStrategyComputerProvider.java

示例9: whenUsingAJanusGraph_TheTitanPreviousPropertyStepStrategyIsInList

import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy; //导入依赖的package包/类
@Test
public void whenUsingAJanusGraph_TheTitanPreviousPropertyStepStrategyIsInList() {
    GraphTraversal<Vertex, Vertex> traversal = optimisableTraversal(janus);
    List<TraversalStrategy<?>> strategies = traversal.asAdmin().getStrategies().toList();

    assertThat(strategies, hasItem(instanceOf(JanusPreviousPropertyStepStrategy.class)));
}
 
开发者ID:graknlabs,项目名称:grakn,代码行数:8,代码来源:JanusPreviousPropertyStepTest.java

示例10: whenUsingANonJanusGraph_TheTitanPreviousPropertyStepStrategyIsNotInList

import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy; //导入依赖的package包/类
@Test
public void whenUsingANonJanusGraph_TheTitanPreviousPropertyStepStrategyIsNotInList() {
    GraphTraversal<Vertex, Vertex> traversal = optimisableTraversal(tinker);
    List<TraversalStrategy<?>> strategies = traversal.asAdmin().getStrategies().toList();

    assertThat(strategies, not(hasItem(instanceOf(JanusPreviousPropertyStepStrategy.class))));
}
 
开发者ID:graknlabs,项目名称:grakn,代码行数:8,代码来源:JanusPreviousPropertyStepTest.java

示例11: with

import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy; //导入依赖的package包/类
/**
 * @deprecated As of release 3.2.0. Please use {@link Graph#traversal(Class)}.
 */
@Deprecated
@Override
public Builder with(final TraversalStrategy strategy) {
    this.withStrategies.add(strategy);
    return this;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:10,代码来源:GraphTraversalSource.java

示例12: without

import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy; //导入依赖的package包/类
/**
 * @deprecated As of release 3.2.0. Please use {@link Graph#traversal(Class)}.
 */
@Deprecated
@Override
public TraversalSource.Builder without(final Class<? extends TraversalStrategy> strategyClass) {
    this.withoutStrategies.add(strategyClass);
    return this;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:10,代码来源:GraphTraversalSource.java

示例13: create

import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy; //导入依赖的package包/类
/**
 * @deprecated As of release 3.2.0. Please use {@link Graph#traversal(Class)}.
 */
@Deprecated
@Override
public GraphTraversalSource create(final Graph graph) {
    GraphTraversalSource traversalSource = new GraphTraversalSource(graph);
    if (!this.withStrategies.isEmpty())
        traversalSource = traversalSource.withStrategies(this.withStrategies.toArray(new TraversalStrategy[this.withStrategies.size()]));
    if (!this.withoutStrategies.isEmpty())
        traversalSource = traversalSource.withoutStrategies(this.withoutStrategies.toArray(new Class[this.withoutStrategies.size()]));
    if (this.engineBuilder instanceof ComputerTraversalEngine.Builder)
        traversalSource = (GraphTraversalSource) ((ComputerTraversalEngine.Builder) this.engineBuilder).create(traversalSource);
    return traversalSource;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:16,代码来源:GraphTraversalSource.java

示例14: TraversalExplanation

import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy; //导入依赖的package包/类
public TraversalExplanation(final Traversal.Admin<?, ?> traversal) {
    this.traversal = traversal.clone();
    TraversalStrategies mutatingStrategies = new DefaultTraversalStrategies();
    for (final TraversalStrategy strategy : this.traversal.getStrategies().toList()) {
        final Traversal.Admin<?, ?> mutatingTraversal = this.traversal.clone();
        mutatingStrategies.addStrategies(strategy);
        mutatingTraversal.setStrategies(mutatingStrategies);
        mutatingTraversal.applyStrategies();
        this.strategyTraversals.add(Pair.with(strategy, mutatingTraversal));
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:12,代码来源:TraversalExplanation.java

示例15: removeStrategies

import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy; //导入依赖的package包/类
@Override
@SuppressWarnings({"unchecked", "varargs"})
public TraversalStrategies removeStrategies(final Class<? extends TraversalStrategy>... strategyClasses) {
    boolean removed = false;
    for (final Class<? extends TraversalStrategy> strategyClass : strategyClasses) {
        final Optional<TraversalStrategy<?>> strategy = this.traversalStrategies.stream().filter(s -> s.getClass().equals(strategyClass)).findAny();
        if (strategy.isPresent()) {
            this.traversalStrategies.remove(strategy.get());
            removed = true;
        }
    }
    if (removed) this.traversalStrategies = TraversalStrategies.sortStrategies(this.traversalStrategies);
    return this;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:15,代码来源:DefaultTraversalStrategies.java


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