View gist:8711493
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void testUnion() { | |
Graph g = TinkerFactory.createClassic(); | |
Gremlin.of(g).v(1).union( | |
Gremlin.of().out("knows"), | |
Gremlin.of().out("created").in("created") | |
).value("name").forEach(System.out::println); | |
} | |
View gist:8739037
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static TinkerGraph createModern() { | |
final TinkerGraph g = TinkerGraph.open(); | |
final Vertex marko = g.addVertex(Element.ID, 1, Element.LABEL, "person", "name", "marko", "locations", AnnotatedList.make()); | |
final Vertex stephen = g.addVertex(Element.ID, 7, Element.LABEL, "person", "name", "stephen", "locations", AnnotatedList.make()); | |
final Vertex matthias = g.addVertex(Element.ID, 8, Element.LABEL, "person", "name", "matthias", "locations", AnnotatedList.make()); | |
final Vertex daniel = g.addVertex(Element.ID, 9, Element.LABEL, "person", "name", "daniel", "locations", AnnotatedList.make()); | |
final Vertex gremlin = g.addVertex(Element.ID, 10, Element.LABEL, "software", "name", "gremlin"); | |
final Vertex blueprints = g.addVertex(Element.ID, 11, Element.LABEL, "software", "name", "blueprints"); |
View gist:8828362
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////////////////////////////////// | |
///////// BLUEPRINTS //////////// | |
///////////////////////////////// | |
public interface Graph { | |
public <S, A extends Flow<A, S, Vertex>> A V(); | |
... | |
} | |
public interface Flow<A extends Flow, S, E> { |
View gist:8829550
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void shouldFlow() { | |
Graph g = TinkerFactory.createClassic(); | |
g.V().has("name", "marko").has("age", 29).out("created", "knows").forEachRemaining(System.out::println); | |
} |
View gist:8830081
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public <A extends Gremlin<?, Vertex>> A V() { | |
Gremlin gremlin = new DefaultGremlin<Object, Vertex>(); | |
gremlin.addStarts(new HolderIterator<>(this.vertices.values().iterator())); | |
return (A) gremlin; | |
} |
View gist:9104098
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void testStuff() throws Exception { | |
Graph g = TinkerFactory.createClassic(); | |
g.V().out().value("name").forEach(System.out::println); | |
System.out.println("----------"); | |
g.V().out().value("name").submit(g.compute()).forEachRemaining(System.out::println); | |
} | |
/////////// | |
lop |
View gist:9105890
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
g.V().pageRank().forEachRemaining(System.out::println); | |
[v[1], 0.15000000000000002] | |
[v[2], 0.19250000000000003] | |
[v[3], 0.4018125] | |
[v[4], 0.19250000000000003] | |
[v[5], 0.23181250000000003] | |
[v[6], 0.15000000000000002] | |
View gist:9125599
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void testOLAPWriteBack() throws Exception { | |
Graph g = TinkerFactory.createClassic(); | |
g.V().pageRank().sideEffect(p -> p.get().getValue0().setProperty("pageRank", p.get().getValue1())).forEachRemaining(System.out::println); | |
System.out.println("---------------"); | |
g.V().value("pageRank").forEachRemaining(System.out::println); | |
System.out.println("---------------"); | |
g.V().pageRank().sideEffect(p -> p.get().getValue0().setProperty("pageRank", p.get().getValue1())).submit(g.compute()).forEachRemaining(System.out::println); | |
} | |
View gist:9237525
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private SliceRange getSliceRange(final VertexQueryFilter inputFilter, final int limit) { | |
final SliceQuery slice = TitanInputFormat.inputSlice(inputFilter, this.graph); | |
final SliceRange sliceRange = new SliceRange(); | |
sliceRange.setStart(slice.getSliceStart().asByteBuffer()); | |
sliceRange.setFinish(slice.getSliceEnd().asByteBuffer()); | |
sliceRange.setCount(Math.min(limit, slice.getLimit())); | |
return sliceRange; | |
} |
View gist:9237551
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class VertexQueryFilter extends DefaultVertexQuery { | |
public static final String FAUNUS_GRAPH_INPUT_VERTEX_QUERY_FILTER = "faunus.graph.input.vertex-query-filter"; | |
private static final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(); | |
private static final String V = "v"; | |
private static final DummyVertex DUMMY_VERTEX = new DummyVertex(); | |
private boolean doesFilter = false; |
OlderNewer