Skip to content

Commit

Permalink
Updates in docs to remove :remote in console, gephi plugin, bytecode …
Browse files Browse the repository at this point in the history
…instances, deprecate neo4j, etc.
  • Loading branch information
xiazcy committed Dec 4, 2024
1 parent 0eef27f commit 9eb2e0e
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 440 deletions.
6 changes: 2 additions & 4 deletions docs/src/dev/developer/for-committers.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -591,10 +591,8 @@ best example of this sort of test would be one that uses the remote `Lambda` syn
** `@WithSeedStrategy`
** `@WithSubgraphStrategy`
Tag filters can be applied to Intellij at execution time by adding a system property of
`-Dcucumber.filter.tags=<tag-expression>`. In addition, the scenarios that pass the `<tag-expression>` can be further
filtered by name with `-Dcucumber.filter.name=<scenario-regex>`. Note that these settings will override those
configured by `CucumberOptions` on "*FeatureTest" setups.
Tag filters can be applied to Intellij at execution time by adding a system properties of
`-Dcucumber.filter.tags=<step-filter>`.
[[gremlin-socket-server-tests]]
=== Gremlin Socket Server Tests
Expand Down
2 changes: 1 addition & 1 deletion docs/src/recipes/anti-patterns.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ for (relation in relations) {
from("p${relation.from}").
to("p${relation.to}")
} ; []
traversalAsString = org.apache.tinkerpop.gremlin.process.traversal.translator.GroovyTranslator.of("g").translate(t.bytecode).getScript() ; []
traversalAsString = traversalAsString = t.gremlinLang.getGremlin() ; []
[ "Traversal String Length": traversalAsString.length()
, "Traversal Preview": traversalAsString.replaceFirst(/^(.{104}).*(.{64})$/, '$1 ... $2') ]
----
Expand Down
439 changes: 26 additions & 413 deletions docs/src/reference/gremlin-applications.asciidoc

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/src/reference/gremlin-variants.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ objects and then re-use them.
[gremlin-groovy]
----
cluster = Cluster.open('conf/remote-objects.yaml')
cluster = Cluster.open('conf/remote.yaml')
client = cluster.connect()
g = traversal().with(DriverRemoteConnection.using(client, "g"))
g.V().elementMap()
Expand Down
110 changes: 105 additions & 5 deletions docs/src/reference/implementations-neo4j.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Neo4j that TinkerPop currently supports in the `neo4j-tinkerpop-api-impl`.
TIP: For configuring Grape, the dependency resolver of Groovy, please refer to the <<gremlin-applications,Gremlin Applications>> section.
[source,groovy]
[source,text]
----
gremlin> :install org.apache.tinkerpop neo4j-gremlin x.y.z
==>Loaded: [org.apache.tinkerpop, neo4j-gremlin, x.y.z] - restart the console to use [tinkerpop.neo4j]
Expand Down Expand Up @@ -86,7 +86,25 @@ The Gremlin-Console session below demonstrates Neo4j indices. For more informati
* Manipulating indices with link:http://neo4j.com/docs/developer-manual/current/#query-schema-index[Cypher].
* Manipulating indices with the Neo4j link:http://neo4j.com/docs/stable/tutorials-java-embedded-new-index.html[Java API].
[gremlin-groovy]
[source,text]
----
gremlin> graph = Neo4jGraph.open('/tmp/neo4j')
==>neo4jgraph[community single [/tmp/neo4j]]
gremlin> g = traversal().withEmbedded(graph)
==>graphtraversalsource[neo4jgraph[community single [/tmp/neo4j]], standard]
gremlin> graph.cypher("CREATE INDEX ON :person(name)")
gremlin> graph.tx().commit() //// (1)
==>null
gremlin> g.addV('person').property('name','marko')
==>v[0]
gremlin> g.addV('dog').property('name','puppy')
==>v[1]
gremlin> g.V().hasLabel('person').has('name','marko').values('name')
==>marko
gremlin> graph.close()
==>null
----
[source,text]
----
graph = Neo4jGraph.open('/tmp/neo4j')
g = traversal().with(graph)
Expand All @@ -103,7 +121,33 @@ graph.close()
Below demonstrates the runtime benefits of indices and demonstrates how if there is no defined index (only vertex
labels), a linear scan of the vertex-label partition is still faster than a linear scan of all vertices.
[gremlin-groovy]
[source,text]
----
gremlin> graph = Neo4jGraph.open('/tmp/neo4j')
==>neo4jgraph[community single [/tmp/neo4j]]
gremlin> g = traversal().withEmbedded(graph)
==>graphtraversalsource[neo4jgraph[community single [/tmp/neo4j]], standard]
gremlin> g.io('data/grateful-dead.xml').read().iterate()
gremlin> g.tx().commit()
==>null
gremlin> clock(1000) {g.V().hasLabel('artist').has('name','Garcia').iterate()} //// (1)
==>0.35031228
gremlin> graph.cypher("CREATE INDEX ON :artist(name)") //// (2)
gremlin> g.tx().commit()
==>null
gremlin> Thread.sleep(5000) //// (3)
==>null
gremlin> clock(1000) {g.V().hasLabel('artist').has('name','Garcia').iterate()} //// (4)
==>0.061846079
gremlin> clock(1000) {g.V().has('name','Garcia').iterate()} //// (5)
==>0.6680353569999999
gremlin> graph.cypher("DROP INDEX ON :artist(name)") //// (6)
gremlin> g.tx().commit()
==>null
gremlin> graph.close()
==>null
----
[source,text]
----
graph = Neo4jGraph.open('/tmp/neo4j')
g = traversal().with(graph)
Expand Down Expand Up @@ -134,7 +178,22 @@ image::gremlin-loves-cypher.png[width=400]
NeoTechnology are the creators of the graph pattern-match query language link:https://neo4j.com/developer/cypher-query-language/[Cypher].
It is possible to leverage Cypher from within Gremlin by using the `Neo4jGraph.cypher()` graph traversal method.
[gremlin-groovy]
[source,text]
----
gremlin> graph = Neo4jGraph.open('/tmp/neo4j')
==>neo4jgraph[community single [/tmp/neo4j]]
gremlin> g = traversal().withEmbedded(graph)
==>graphtraversalsource[neo4jgraph[community single [/tmp/neo4j]], standard]
gremlin> g.io('data/tinkerpop-modern.kryo').read().iterate()
gremlin> graph.cypher('MATCH (a {name:"marko"}) RETURN a')
==>[a:v[0]]
gremlin> graph.cypher('MATCH (a {name:"marko"}) RETURN a').select('a').out('knows').values('name')
==>josh
==>vadas
gremlin> graph.close()
==>null
----
[source,text]
----
graph = Neo4jGraph.open('/tmp/neo4j')
g = traversal().with(graph)
Expand Down Expand Up @@ -165,7 +224,48 @@ public void removeLabel(String label) // remove a label from the vertex
An example use case is presented below.
[gremlin-groovy]
[source,text]
----
gremlin> graph = Neo4jGraph.open('/tmp/neo4j')
==>neo4jgraph[community single [/tmp/neo4j]]
gremlin> g = traversal().withEmbedded(graph)
==>graphtraversalsource[neo4jgraph[community single [/tmp/neo4j]], standard]
gremlin> vertex = (Neo4jVertex) g.addV('human::animal').next() //// (1)
==>v[0]
gremlin> vertex.label() //// (2)
==>animal::human
gremlin> vertex.labels() //// (3)
==>animal
==>human
gremlin> vertex.addLabel('organism') //// (4)
==>null
gremlin> vertex.label()
==>animal::human::organism
gremlin> vertex.removeLabel('human') //// (5)
==>null
gremlin> vertex.labels()
==>animal
==>organism
gremlin> vertex.addLabel('organism') //// (6)
==>null
gremlin> vertex.labels()
==>animal
==>organism
gremlin> vertex.removeLabel('human') //// (7)
==>null
gremlin> vertex.label()
==>animal::organism
gremlin> g.V().has(label,'organism') //// (8)
gremlin> g.V().has(label,of('organism')) //// (9)
==>v[0]
gremlin> g.V().has(label,of('organism')).has(label,of('animal'))
==>v[0]
gremlin> g.V().has(label,of('organism').and(of('animal')))
==>v[0]
gremlin> graph.close()
==>null
----
[source,text]
----
graph = Neo4jGraph.open('/tmp/neo4j')
g = traversal().with(graph)
Expand Down
10 changes: 1 addition & 9 deletions docs/src/reference/implementations-spark.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,7 @@ g.V().count()
g.V().out().out().values('name')
----
For using lambdas in Gremlin-Groovy, simply provide `:remote connect` a `TraversalSource` which leverages SparkGraphComputer.
[gremlin-groovy]
----
graph = GraphFactory.open('conf/hadoop/hadoop-gryo.properties')
g = traversal().with(graph).withComputer(SparkGraphComputer)
:remote connect tinkerpop.hadoop graph g
:> g.V().group().by{it.value('name')[1]}.by('name')
----
NOTE: We will no longer support lambda executions via `:remote` on the Gremlin Console.
The `SparkGraphComputer` algorithm leverages Spark's caching abilities to reduce the amount of data shuffled across
the wire on each iteration of the <<vertexprogram,`VertexProgram`>>. When the graph is loaded as a Spark RDD
Expand Down
13 changes: 7 additions & 6 deletions docs/src/reference/the-traversal.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -5602,26 +5602,27 @@ g.withStrategies(EdgeLabelVerificationStrategy(throwException=true))
=== ElementIdStrategy
`ElementIdStrategy` provides control over element identifiers. Some Graph implementations, such as TinkerGraph,
`ElementIdStrategy` provides control over element identifiers. Some Graph implementations, such as `TinkerGraph`,
allow specification of custom identifiers when creating elements:
[gremlin-groovy]
----
g = traversal().with(TinkerGraph.open())
g = traversal().withEmbedded(TinkerGraph.open())
v = g.addV().property(id,'42a').next()
g.V('42a')
----
Other `Graph` implementations, such as Neo4j, generate element identifiers automatically and cannot be assigned.
Other `Graph` implementations generate element identifiers automatically and cannot be assigned.
As a helper, `ElementIdStrategy` can be used to make identifier assignment possible by using vertex and edge indices
under the hood.
under the hood. Note that this demonstration is using `TinkerGraph` for convenience, however in practice
`ElementIdStrategy` offers little value in a `Graph` which allows custom identifiers.
[gremlin-groovy]
----
graph = Neo4jGraph.open('/tmp/neo4j')
strategy = ElementIdStrategy.build().create()
g = traversal().with(graph).withStrategies(strategy)
g = traversal().withEmbedded(TinkerGraph.open()).withStrategies(strategy)
g.addV().property(id, '42a').id()
g.V().elementMap()
----
IMPORTANT: The key that is used to store the assigned identifier should be indexed in the underlying graph
Expand Down
3 changes: 2 additions & 1 deletion gremlin-server/conf/gremlin-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ scriptEngines: {
plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {},
org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {},
org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]},
org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [scripts/empty-sample.groovy]}}}}
org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [scripts/empty-sample.groovy]},
org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyCompilerGremlinPlugin: {enableThreadInterrupt: true}}}}
serializers:
- { className: org.apache.tinkerpop.gremlin.util.ser.GraphSONMessageSerializerV4, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV3] }} # application/json
- { className: org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV4 } # application/vnd.graphbinary-v1.0
Expand Down

0 comments on commit 9eb2e0e

Please sign in to comment.