private GraphTraversalSource create() { return graphProvider.traversal(graph, ReadOnlyStrategy.instance()); }
@Benchmark public GraphTraversal.Admin<Vertex,Vertex> testTranslationWithStrategy() { return translator.translate(g.withStrategies(ReadOnlyStrategy.instance()) .withStrategies(SubgraphStrategy.build().vertices(hasLabel("person")).create()) .V().out().in("link").out().in("link").asAdmin().getBytecode()); } }
private GraphTraversalSource create() { return graphProvider.traversal(graph, ReadOnlyStrategy.instance()); }
/** * Utility function to get a read-only Tinkerpop traversal. * * @return A read-only Tinkerpop traversal for manually traversing the graph */ public GraphTraversalSource getTinkerTraversal() { operateOnOpenGraph(() -> null); //This is to check if the graph is open if (graphTraversalSource == null) { graphTraversalSource = getTinkerPopGraph().traversal().withStrategies(ReadOnlyStrategy.instance()); } return graphTraversalSource; }
@Test @LoadGraphWith(LoadGraphWith.GraphData.MODERN) public void shouldHandleStrategies() throws Exception { final GraphTraversalSource g = graph.traversal().withStrategies(SubgraphStrategy.create(new MapConfiguration(new HashMap<String, Object>() {{ put(SubgraphStrategy.VERTICES, __.has("name", "marko")); }}))); final Bindings bindings = new SimpleBindings(); bindings.put("g", g); Traversal.Admin<Vertex, Object> traversal = engine.eval(g.V().values("name").asAdmin().getBytecode(), bindings, "g"); assertEquals("marko", traversal.next()); assertFalse(traversal.hasNext()); // traversal = engine.eval(g.withoutStrategies(SubgraphStrategy.class).V().count().asAdmin().getBytecode(), bindings, "g"); assertEquals(new Long(6), traversal.next()); assertFalse(traversal.hasNext()); // traversal = engine.eval(g.withStrategies(SubgraphStrategy.create(new MapConfiguration(new HashMap<String, Object>() {{ put(SubgraphStrategy.VERTICES, __.has("name", "marko")); }})), ReadOnlyStrategy.instance()).V().values("name").asAdmin().getBytecode(), bindings, "g"); assertEquals("marko", traversal.next()); assertFalse(traversal.hasNext()); }