本文整理汇总了Java中org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies类的典型用法代码示例。如果您正苦于以下问题:Java TraversalStrategies类的具体用法?Java TraversalStrategies怎么用?Java TraversalStrategies使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TraversalStrategies类属于org.apache.tinkerpop.gremlin.process.traversal包,在下文中一共展示了TraversalStrategies类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateTestParameters
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies; //导入依赖的package包/类
@Parameterized.Parameters(name = "{0}")
public static Iterable<Object[]> generateTestParameters() {
return Arrays.asList(new Object[][]{
{__.V().count(), countStep(Vertex.class), Collections.emptyList()},
{__.V().count(), countStep(Vertex.class), TraversalStrategies.GlobalCache.getStrategies(TinkerGraph.class).toList()},
{__.V().as("a").count(), countStep(Vertex.class), TraversalStrategies.GlobalCache.getStrategies(TinkerGraph.class).toList()},
{__.V().count().as("a"), countStep(Vertex.class), TraversalStrategies.GlobalCache.getStrategies(TinkerGraph.class).toList()},
{__.V().map(out()).count().as("a"), countStep(Vertex.class), TraversalStrategies.GlobalCache.getStrategies(TinkerGraph.class).toList()},
{__.V().map(out()).identity().count().as("a"), countStep(Vertex.class), TraversalStrategies.GlobalCache.getStrategies(TinkerGraph.class).toList()},
{__.V().map(out().groupCount()).identity().count().as("a"), countStep(Vertex.class), TraversalStrategies.GlobalCache.getStrategies(TinkerGraph.class).toList()},
{__.V().label().map(s -> s.get().length()).count(), countStep(Vertex.class), TraversalStrategies.GlobalCache.getStrategies(TinkerGraph.class).toList()},
{__.V().as("a").map(select("a")).count(), countStep(Vertex.class),TraversalStrategies.GlobalCache.getStrategies(TinkerGraph.class).toList()},
//
{__.V(), __.V(), Collections.emptyList()},
{__.V().out().count(), __.V().out().count(), Collections.emptyList()},
{__.V(1).count(), __.V(1).count(), Collections.emptyList()},
{__.count(), __.count(), Collections.emptyList()},
{__.V().map(out().groupCount("m")).identity().count().as("a"), __.V().map(out().groupCount("m")).identity().count().as("a"), Collections.emptyList()},
});
}
示例2: addStrategies
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies; //导入依赖的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;
}
示例3: generateProgram
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies; //导入依赖的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);
}
示例4: testWellDefinedDependency3
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies; //导入依赖的package包/类
@Test
public void testWellDefinedDependency3() {
//Dependency well defined
TraversalStrategies s = new DefaultTraversalStrategies();
s.addStrategies(d, c, a, e, b);
assertEquals(5, s.toList().size());
assertEquals(a, s.toList().get(0));
assertEquals(b, s.toList().get(1));
assertEquals(d, s.toList().get(2));
assertEquals(c, s.toList().get(3));
assertEquals(e, s.toList().get(4));
s = s.clone();
assertEquals(5, s.toList().size());
assertEquals(a, s.toList().get(0));
assertEquals(b, s.toList().get(1));
assertEquals(d, s.toList().get(2));
assertEquals(c, s.toList().get(3));
assertEquals(e, s.toList().get(4));
}
示例5: shouldBeVerifiedIllegal
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies; //导入依赖的package包/类
@Test
public void shouldBeVerifiedIllegal() {
final TraversalStrategies strategies = new DefaultTraversalStrategies();
strategies.addStrategies(ComputerVerificationStrategy.instance());
this.traversal.asAdmin().setParent(new TraversalVertexProgramStep(EmptyTraversal.instance(), EmptyTraversal.instance())); // trick it
this.traversal.asAdmin().setStrategies(strategies);
try {
this.traversal.asAdmin().applyStrategies();
if (!this.legal)
fail("The traversal should not be allowed: " + this.traversal);
} catch (final VerificationException ise) {
if (this.legal)
fail("The traversal should be allowed: " + this.traversal);
}
}
示例6: shouldBeVerifiedIllegal
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies; //导入依赖的package包/类
@Test
public void shouldBeVerifiedIllegal() {
final TraversalStrategies strategies = new DefaultTraversalStrategies();
strategies.addStrategies(LambdaRestrictionStrategy.instance());
traversal.asAdmin().setStrategies(strategies);
if (allow) {
traversal.asAdmin().applyStrategies();
} else {
try {
traversal.asAdmin().applyStrategies();
fail("The strategy should not allow lambdas: " + this.traversal);
} catch (VerificationException ise) {
assertTrue(ise.getMessage().contains("lambda"));
}
}
}
示例7: doTest
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies; //导入依赖的package包/类
@Test
public void doTest() {
final TraversalStrategies originalStrategies = new DefaultTraversalStrategies();
originalStrategies.addStrategies(SubgraphStrategy.build().
vertices(__.and(has("name", "marko"), has("age", 29))).
edges(hasLabel("knows")).
vertexProperties(__.<VertexProperty, Long>values().count().and(is(P.lt(10)), is(0))).create());
originalStrategies.addStrategies(InlineFilterStrategy.instance());
originalStrategies.addStrategies(StandardVerificationStrategy.instance());
this.original.asAdmin().setStrategies(originalStrategies);
this.original.asAdmin().applyStrategies();
final TraversalStrategies optimizedStrategies = new DefaultTraversalStrategies();
optimizedStrategies.addStrategies(InlineFilterStrategy.instance());
this.optimized.asAdmin().setStrategies(optimizedStrategies);
this.optimized.asAdmin().applyStrategies();
assertEquals(this.optimized, this.original);
}
示例8: shouldBeVerifiedIllegal
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies; //导入依赖的package包/类
@Test
public void shouldBeVerifiedIllegal() {
final TraversalStrategies strategies = new DefaultTraversalStrategies();
strategies.addStrategies(ProfileStrategy.instance());
strategies.addStrategies(LambdaRestrictionStrategy.instance());
traversal.asAdmin().setStrategies(strategies);
if (allow) {
traversal.asAdmin().applyStrategies();
} else {
try {
traversal.asAdmin().applyStrategies();
fail("The strategy should not allow lambdas: " + this.traversal);
} catch (VerificationException ise) {
assertTrue(ise.getMessage().contains("lambda"));
}
}
}
示例9: shouldBeVerified
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies; //导入依赖的package包/类
@Test
public void shouldBeVerified() {
final TraversalStrategies strategies = new DefaultTraversalStrategies();
strategies.addStrategies(StandardVerificationStrategy.instance());
traversal.asAdmin().setStrategies(strategies);
if (legalTraversal) {
traversal.asAdmin().applyStrategies();
} else {
try {
traversal.asAdmin().applyStrategies();
fail("The strategy should not allow traversal: " + this.traversal);
} catch (IllegalStateException ise) {
assertTrue(true);
}
}
}
示例10: doTest
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies; //导入依赖的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);
}
示例11: doTest
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies; //导入依赖的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);
}
示例12: generateTestParameters
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies; //导入依赖的package包/类
@Parameterized.Parameters(name = "{0}")
public static Iterable<Object[]> generateTestParameters() {
final int LAZY_SIZE = 2500;
return Arrays.asList(new Object[][]{
{__.V().out(), g_V().out(), Collections.emptyList()},
{__.V().has("name", "marko").out(), g_V("name", eq("marko")).out(), Collections.emptyList()},
{__.V().has("name", "marko").has("age", gt(31).and(lt(10))).out(),
g_V("name", eq("marko"), "age", gt(31), "age", lt(10)).out(), Collections.emptyList()},
{__.V().has("name", "marko").or(has("age"), has("age", gt(32))).has("lang", "java"),
g_V("name", eq("marko"), "lang", eq("java")).or(has("age"), has("age", gt(32))), Collections.singletonList(FilterRankingStrategy.instance())},
{__.V().has("name", "marko").as("a").or(has("age"), has("age", gt(32))).has("lang", "java"),
g_V("name", eq("marko")).as("a").or(has("age"), has("age", gt(32))).has("lang", "java"), Collections.emptyList()},
{__.V().has("name", "marko").as("a").or(has("age"), has("age", gt(32))).has("lang", "java"),
g_V("name", eq("marko"), "lang", eq("java")).or(has("age"), has("age", gt(32))).as("a"), Collections.singletonList(FilterRankingStrategy.instance())},
{__.V().dedup().has("name", "marko").or(has("age"), has("age", gt(32))).has("lang", "java"),
g_V("name", eq("marko"), "lang", eq("java")).or(has("age"), has("age", gt(32))).dedup(), Collections.singletonList(FilterRankingStrategy.instance())},
{__.V().as("a").dedup().has("name", "marko").or(has("age"), has("age", gt(32))).has("lang", "java"),
g_V("name", eq("marko"), "lang", eq("java")).or(has("age"), has("age", gt(32))).dedup().as("a"), Collections.singletonList(FilterRankingStrategy.instance())},
{__.V().as("a").has("name", "marko").as("b").or(has("age"), has("age", gt(32))).has("lang", "java"),
g_V("name", eq("marko"), "lang", eq("java")).or(has("age"), has("age", gt(32))).as("b", "a"), Collections.singletonList(FilterRankingStrategy.instance())},
{__.V().as("a").dedup().has("name", "marko").or(has("age"), has("age", gt(32))).filter(has("name", "bob")).has("lang", "java"),
g_V("name", eq("marko"), "lang", eq("java"), "name", eq("bob")).or(has("age"), has("age", gt(32))).dedup().as("a"), Arrays.asList(InlineFilterStrategy.instance(), FilterRankingStrategy.instance())},
{__.V().as("a").dedup().has("name", "marko").or(has("age", 10), has("age", gt(32))).filter(has("name", "bob")).has("lang", "java"),
g_V("name", eq("marko"), "lang", eq("java"), "name", eq("bob"), "age", eq(10).or(gt(32))).dedup().as("a"), TraversalStrategies.GlobalCache.getStrategies(TinkerGraph.class).toList()},
{__.V().has("name", "marko").or(not(has("age")), has("age", gt(32))).has("name", "bob").has("lang", "java"),
g_V("name", eq("marko"), "name", eq("bob"), "lang", eq("java")).or(not(filter(properties("age"))), has("age", gt(32))), TraversalStrategies.GlobalCache.getStrategies(TinkerGraph.class).toList()},
{__.V().has("name", P.eq("marko").or(P.eq("bob").and(P.eq("stephen")))).out("knows"),
g_V("name", eq("marko").or(P.eq("bob").and(P.eq("stephen")))).out("knows"), Collections.emptyList()},
{__.V().has("name", P.eq("marko").and(P.eq("bob").and(P.eq("stephen")))).out("knows"),
g_V("name", eq("marko"), "name", eq("bob"), "name", eq("stephen")).out("knows"), Collections.emptyList()},
{__.V().has("name", P.eq("marko").and(P.eq("bob").or(P.eq("stephen")))).out("knows"),
g_V("name", eq("marko"), "name", P.eq("bob").or(eq("stephen"))).out("knows"), Collections.emptyList()},
///////
{__.V().out().out().V().has("name", "marko").out(), g_V().out().barrier(LAZY_SIZE).out().barrier(LAZY_SIZE).asAdmin().addStep(V("name", eq("marko"))).barrier(LAZY_SIZE).out(), Arrays.asList(InlineFilterStrategy.instance(), FilterRankingStrategy.instance(), LazyBarrierStrategy.instance())},
{__.V().out().out().V().has("name", "marko").as("a").out(), g_V().out().barrier(LAZY_SIZE).out().barrier(LAZY_SIZE).asAdmin().addStep(V("name", eq("marko"))).barrier(LAZY_SIZE).as("a").out(), Arrays.asList(InlineFilterStrategy.instance(), FilterRankingStrategy.instance(), LazyBarrierStrategy.instance())},
{__.V().out().V().has("age", gt(32)).barrier(10).has("name", "marko").as("a"), g_V().out().barrier(LAZY_SIZE).asAdmin().addStep(V("age", gt(32), "name", eq("marko"))).barrier(LAZY_SIZE).barrier(10).as("a"), Arrays.asList(InlineFilterStrategy.instance(), FilterRankingStrategy.instance(), LazyBarrierStrategy.instance())},
{__.V().out().V().has("age", gt(32)).barrier(10).has("name", "marko").as("a"), g_V().out().barrier(LAZY_SIZE).asAdmin().addStep(V("age", gt(32), "name", eq("marko"))).barrier(LAZY_SIZE).barrier(10).as("a"), TraversalStrategies.GlobalCache.getStrategies(TinkerGraph.class).toList()},
});
}
示例13: traversal
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies; //导入依赖的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()]));
}
示例14: traversal
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies; //导入依赖的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
示例15: TraversalExplanation
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies; //导入依赖的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));
}
}