### Build and Install Project with Maven Source: https://tinkerpop.apache.org/docs/3.7.1/dev/developer Use this command for a basic build and installation of the project. Ensure Maven is installed and configured. ```bash mvn clean install ``` -------------------------------- ### union() Start Step Usage Source: https://tinkerpop.apache.org/docs/3.7.1/upgrade Compares the legacy inject() workaround for union() with the direct usage of union() as a start step. ```gremlin gremlin> g.inject(0).union(V().has('name','vadas'), ......1> V().has('software','name','lop').in('created')). ......2> values('name') ==>vadas ==>marko ==>josh ==>peter ``` ```gremlin gremlin> g.union(V().has('name','vadas'), ......1> V().has('software','name','lop').in('created')). ......2> values('name') ==>vadas ==>marko ==>josh ==>peter ``` -------------------------------- ### Start Gremlin Console Source: https://tinkerpop.apache.org/docs/3.7.1/tutorials/getting-started Download, unpack, and start the Gremlin Console. Ensure you are in the correct directory before running the start script. ```bash $ unzip apache-tinkerpop-gremlin-console-3.7.1-bin.zip $ cd apache-tinkerpop-gremlin-console-3.7.1 $ bin/gremlin.sh ``` -------------------------------- ### Install gperfutils Benchmarking Tool Source: https://tinkerpop.apache.org/docs/3.7.1/upgrade Use the :install command in the Gremlin Console to add gperfutils benchmarking tools. Ensure you specify the correct version. ```gremlin gremlin> :install org.gperfutils gbench ``` ```gremlin gremlin> :install org.gperfutils gprof ``` -------------------------------- ### Initialize Gremlin-Go Connection Source: https://tinkerpop.apache.org/docs/3.7.1/upgrade Example of establishing a remote connection and executing a basic traversal in Go. ```go package main import ( "fmt" "github.com/apache/tinkerpop/gremlin-go/v3/driver" ) func main() { // Creating the connection to the server driverRemoteConnection, err := gremlingo.NewDriverRemoteConnection("ws://localhost:8182/gremlin", func(settings *gremlingo.DriverRemoteConnectionSettings) { // Configure optional settings settings.LogVerbosity = gremlingo.Info settings.InitialConcurrentConnections = 2 } ) // Handle error if err != nil { fmt.Println(err) return } // Cleanup defer driverRemoteConnection.Close() // Creating graph traversal g := gremlingo.Traversal_().WithRemote(driverRemoteConnection) // Perform traversal result, err := g.V().Count().ToList() if err != nil { fmt.Println(err) return } fmt.Println(result[0].GetString()) } ``` -------------------------------- ### Setup Graph Data Source: https://tinkerpop.apache.org/docs/3.7.1/recipes Initializes a graph structure with users, movies, and friendship/like relationships. ```groovy gremlin> g.addV("user").property("name", "alice").as("u1"). addV("user").property("name", "jen").as("u2"). addV("user").property("name", "dave").as("u3"). addV("movie").property("name", "the wild bunch").as("m1"). addV("movie").property("name", "young guns").as("m2"). addV("movie").property("name", "unforgiven").as("m3"). addE("friend").from("u1").to("u2"). addE("friend").from("u1").to("u3"). addE("like").from("u2").to("m1"). addE("like").from("u2").to("m2"). addE("like").from("u3").to("m2"). addE("like").from("u3").to("m3").iterate() ``` ```groovy g.addV("user").property("name", "alice").as("u1"). addV("user").property("name", "jen").as("u2"). addV("user").property("name", "dave").as("u3"). addV("movie").property("name", "the wild bunch").as("m1"). addV("movie").property("name", "young guns").as("m2"). addV("movie").property("name", "unforgiven").as("m3"). addE("friend").from("u1").to("u2"). addE("friend").from("u1").to("u3"). addE("like").from("u2").to("m1"). addE("like").from("u2").to("m2"). addE("like").from("u3").to("m2"). addE("like").from("u3").to("m3").iterate() ``` -------------------------------- ### Start Gremlin Server for Transactions Source: https://tinkerpop.apache.org/docs/3.7.1/upgrade Command to initialize the Gremlin Server with a transaction-enabled configuration. ```bash bin/gremlin-server.sh conf/gremlin-server-transaction.yaml ``` -------------------------------- ### Javascript Transaction Example Source: https://tinkerpop.apache.org/docs/3.7.1/upgrade An example demonstrating the `tx()` syntax for remote transactions in Javascript, a new feature in this release. ```javascript gremlin> g.tx().commit() ``` -------------------------------- ### Clean Install Project Source: https://tinkerpop.apache.org/docs/3.7.1/dev/developer Perform a clean install of the project, skipping tests initially. This is used to update GLV versions and ensure the project builds with the new version. ```bash mvn clean install -DskipTests ``` -------------------------------- ### Build gremlin-go with Go Source: https://tinkerpop.apache.org/docs/3.7.1/dev/developer After installing Go, you can build the gremlin-go module directly from the command line. ```bash go build ``` -------------------------------- ### Install Gremlin-Go Dependency Source: https://tinkerpop.apache.org/docs/3.7.1/upgrade Command to add the Gremlin-Go driver as a dependency in a Go project. ```bash go get github.com/apache/tinkerpop/gremlin-go/v3@v3.5.4 ``` -------------------------------- ### Install Kerberos dependencies for Python Source: https://tinkerpop.apache.org/docs/3.7.1/dev/developer Required system-level dependencies for testing Kerberos authentication in Python. ```bash sudo apt install libkrb5-dev krb5-user ``` -------------------------------- ### Get or Create Edge with fold() and coalesce() Source: https://tinkerpop.apache.org/docs/3.7.1/recipes Apply the 'get or create' pattern to edges. This example checks for an existing 'created' edge between two vertices and creates it with a weight if it doesn't exist. ```groovy gremlin> g.V().has('person','name','vadas').as('v'). V().has('software','name','ripple'). coalesce(__.inE('created').where(outV().as('v')), addE('created').from('v').property('weight',0.5)) ``` ```groovy g.V().has('person','name','vadas').as('v'). V().has('software','name','ripple'). coalesce(__.inE('created').where(outV().as('v')), addE('created').from('v').property('weight',0.5)) ``` -------------------------------- ### Set up Hadoop winutils for Windows Build Source: https://tinkerpop.apache.org/docs/3.7.1/dev/developer Instructions for setting up Hadoop winutils on Windows, including downloading binaries, setting HADOOP_HOME, and updating the PATH environment variable. ```bash set HADOOP_HOME=C:\path\to\hadoop-3.3.1 set PATH=%HADOOP_HOME%\bin;%PATH% ``` -------------------------------- ### Demonstrate String Substring Extraction with Closures Source: https://tinkerpop.apache.org/docs/3.7.1/upgrade Use closures with `substring()` to extract parts of strings. Examples show extracting substrings with start and end indices, only a start index, and negative indices. ```gremlin gremlin> g.V().hasLabel("person").values("name").map{it.get().substring(1,4)} ==>ark ==>ada ==>osh ==>ete ``` ```gremlin gremlin> g.V().hasLabel("person").values("name").map{it.get().substring(1)} ==>arko ==>adas ==>osh ==>eter ``` ```gremlin gremlin> g.V().hasLabel("person").values("name").map{it.get().substring(-2)} String index out of range: -2 Type ':help' or ':h' for help. ``` -------------------------------- ### Get Help for a Specific Gremlin Console Command Source: https://tinkerpop.apache.org/docs/3.7.1/tutorials/the-gremlin-console To get detailed usage information for a specific command, append the command name to ':help'. For example, ':help :remote' provides details on managing remote connections. ```groovy gremlin> :help :remote usage: :remote [current|connect []|config |list|next|prev|choose |close] Define and manage remote connections to use in conjunction with the :submit command, which will send Gremlin scripts to the specified remote agent for processing. ``` ```groovy :help :remote ``` -------------------------------- ### Initial Vertex Creation with Properties Source: https://tinkerpop.apache.org/docs/3.7.1/upgrade Basic example of adding a vertex with an ID and then setting properties with different cardinalities. This demonstrates the foundational steps before applying more complex upsert logic. ```gremlin g.addV().property(id,1234).property('age',19).property(set, 'city', 'detroit') ``` ```gremlin g.addV().property(id,1234).property('age',19).property(set, 'city', 'detroit') ``` -------------------------------- ### Gremlin Traversal to Get All Vertices Source: https://tinkerpop.apache.org/docs/3.7.1/tutorials/gremlins-anatomy Retrieves all vertices in the graph. This is a common starting point for many Gremlin traversals. ```groovy gremlin> g.V() ==>v[1] ==>v[2] ==>v[3] ==>v[4] ==>v[5] ==>v[6] ``` ```groovy g.V() ``` -------------------------------- ### Initialize GLV Sessions Source: https://tinkerpop.apache.org/docs/3.7.1/upgrade Examples of initializing a client with session support across different Gremlin Language Variants. ```javascript const client = new Client('ws://localhost:8182/gremlin', { traversalSource: 'g', 'session': 'unique-string-id' }); ``` ```python client = Client('ws://localhost:8182/gremlin', 'g', session=str(uuid.uuid4())) ``` ```csharp var gremlinServer = new GremlinServer("localhost", 8182); var client = new GremlinClient(gremlinServer, sessionId: Guid.NewGuid().ToString())) ``` -------------------------------- ### Demonstrate String Substring Extraction with Standard Gremlin Syntax Source: https://tinkerpop.apache.org/docs/3.7.1/upgrade Extract substrings using the standard Gremlin `substring()` step. Examples cover specifying start and end indices, only a start index, and using negative indices. ```gremlin gremlin> g.V().hasLabel("person").values("name").substring(1,4) ==>ark ==>ada ==>osh ==>ete ``` ```gremlin gremlin> g.V().hasLabel("person").values("name").substring(1) ==>arko ==>adas ==>osh ==>eter ``` ```gremlin gremlin> g.V().hasLabel("person").values("name").substring(-2) ==>ko ==>as ==>sh ==>er ``` -------------------------------- ### Build and Install with Integration Tests Source: https://tinkerpop.apache.org/docs/3.7.1/dev/developer Execute this command to perform a full build including integration tests. This is often necessary for comprehensive testing. ```bash mvn clean install -DskipIntegrationTests=false -DincludeNeo4j ``` -------------------------------- ### Get Vertex Age in Gremlin Source: https://tinkerpop.apache.org/docs/3.7.1/recipes Retrieves the 'age' property of a vertex identified by its 'name'. This is a basic example of accessing vertex properties. ```gremlin g.V().has('name','marko').values('age') ``` -------------------------------- ### Generate Local Website Source: https://tinkerpop.apache.org/docs/3.7.1/dev/developer Navigate to the 'site' directory and run the generate-home.sh script to build the project website locally. ```bash cd site bin/generate-home.sh ``` -------------------------------- ### Install Cassandra Driver in Gremlin Console Source: https://tinkerpop.apache.org/docs/3.7.1/tutorials/the-gremlin-console Installs the DataStax Cassandra Java driver (version 2.1.9) into the Gremlin Console classpath using the ':install' command. This is necessary for interacting with Cassandra from the console. ```gremlin gremlin> :install com.datastax.cassandra cassandra-driver-core 2.1.9 ``` -------------------------------- ### Start Gremlin Server with Docker Source: https://tinkerpop.apache.org/docs/3.7.1/dev/developer Launch Gremlin Server using the provided Docker script with the standard test configuration. ```bash docker/gremlin-server.sh ``` -------------------------------- ### Install groovy-sql in Gremlin Console Source: https://tinkerpop.apache.org/docs/3.7.1/upgrade Use this command to install the groovy-sql dependency in the Gremlin Console if it is no longer included by default. ```groovy :install org.codehaus.groovy groovy-sql 2.5.2 ``` -------------------------------- ### List Recipe Files Source: https://tinkerpop.apache.org/docs/3.7.1/recipes View the existing recipe files within the documentation directory. ```bash ls docs/src/recipes ``` -------------------------------- ### Gremlin Traversal Example Source: https://tinkerpop.apache.org/docs/3.7.1/dev/developer This is an example of a Gremlin traversal used in a test scenario. It demonstrates the use of `union`, `repeat`, and `times`. ```gremlin-groovy g.V(vId1).union(__.repeat(__.out()).times(2), __.out()).values("name") ``` -------------------------------- ### Initialize Graph for Looping Examples Source: https://tinkerpop.apache.org/docs/3.7.1/recipes Creates a small graph structure with parent-child relationships to demonstrate complex looping. ```gremlin gremlin> g.addV().property(id, 'A').as('a'). addV().property(id, 'B').as('b'). addV().property(id, 'C').as('c'). addV().property(id, 'D').as('d'). addV().property(id, 'E').as('e'). addV().property(id, 'F').as('f'). addV().property(id, 'G').as('g'). addE('hasParent').from('a').to('b'). addE('hasParent').from('b').to('c'). addE('hasParent').from('d').to('c'). addE('hasParent').from('c').to('e'). addE('hasParent').from('e').to('f'). addE('hasParent').from('g').to('f').iterate() ``` ```gremlin g.addV().property(id, 'A').as('a'). addV().property(id, 'B').as('b'). addV().property(id, 'C').as('c'). addV().property(id, 'D').as('d'). addV().property(id, 'E').as('e'). addV().property(id, 'F').as('f'). addV().property(id, 'G').as('g'). addE('hasParent').from('a').to('b'). addE('hasParent').from('b').to('c'). addE('hasParent').from('d').to('c'). addE('hasParent').from('c').to('e'). addE('hasParent').from('e').to('f'). addE('hasParent').from('g').to('f').iterate() ``` -------------------------------- ### Install gremlin-python Dependencies Source: https://tinkerpop.apache.org/docs/3.7.1/dev/developer Install the gremlin-python dependencies using pip within a virtual environment. This command should be run from the gremlin-python/src/main/python directory. ```shell venv/bin/pip3 install -e . ``` -------------------------------- ### Start Gremlin Server container Source: https://tinkerpop.apache.org/docs/3.7.1/dev/developer Launches the Gremlin Server instance using the local build or a specific version. ```bash docker/gremlin-server.sh ``` ```bash docker/gremlin-server.sh 3.4.2 ``` -------------------------------- ### Install groovy-sql in Gremlin Server Source: https://tinkerpop.apache.org/docs/3.7.1/upgrade Execute this command to install the groovy-sql dependency for Gremlin Server. This is necessary if your application relies on groovy-sql functionality. ```bash bin/gremlin-server.sh install org.codehaus.groovy groovy-sql 2.5.2 ``` -------------------------------- ### Build and Test with Docker Source: https://tinkerpop.apache.org/docs/3.7.1/dev/developer Utilize this script for building and testing the project using Docker. It simplifies environment setup. ```bash docker/build.sh -t -i -n ``` -------------------------------- ### Install and Activate Gremlin Plugin in Console Source: https://tinkerpop.apache.org/docs/3.7.1/dev/provider Commands to install and activate a plugin within the Gremlin Console to enable graph system functionality. ```groovy gremlin> g = Neo4jGraph.open('/tmp/neo4j') No such property: Neo4jGraph for class: groovysh_evaluate Display stack trace? [yN] gremlin> :install org.apache.tinkerpop neo4j-gremlin 3.7.1 ==>loaded: [org.apache.tinkerpop, neo4j-gremlin, …] gremlin> :plugin use tinkerpop.neo4j ==>tinkerpop.neo4j activated gremlin> g = Neo4jGraph.open('/tmp/neo4j') ==>neo4jgraph[EmbeddedGraphDatabase [/tmp/neo4j]] ``` -------------------------------- ### Calculate Common Earliest Start Time Source: https://tinkerpop.apache.org/docs/3.7.1/tutorials/the-gremlin-console Determines the maximum of the minimum start times across all person vertices to establish a common baseline. ```groovy gremlin> firstYear = g.V().hasLabel('person'). local(properties('location').values('startTime').min()). max().next() ==>2004 ``` ```groovy firstYear = g.V().hasLabel('person'). local(properties('location').values('startTime').min()). max().next() ``` -------------------------------- ### Demonstrate Traversal Bulking in Gremlin Server Source: https://tinkerpop.apache.org/docs/3.7.1/dev/provider This example illustrates how the Traversal OpProcessor returns bulked results. The first snippet includes console output, while the second provides the raw script commands. ```groovy gremlin> cluster = Cluster.open() ==>localhost/127.0.0.1:8182 gremlin> client = cluster.connect() ==>org.apache.tinkerpop.gremlin.driver.Client$ClusteredClient@4ed343ea gremlin> aliased = client.alias("g") ==>org.apache.tinkerpop.gremlin.driver.Client$AliasClusteredClient@6d919a4 gremlin> g = traversal().withEmbedded(org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph.instance()) //// **(1)** ==>graphtraversalsource[emptygraph[empty], standard] gremlin> rs = aliased.submit(g.V().both().barrier().both().barrier()).all().get() //// **(2)** ==>result{object=v[1] class=org.apache.tinkerpop.gremlin.process.remote.traversal.DefaultRemoteTraverser} ==>result{object=v[4] class=org.apache.tinkerpop.gremlin.process.remote.traversal.DefaultRemoteTraverser} ==>result{object=v[6] class=org.apache.tinkerpop.gremlin.process.remote.traversal.DefaultRemoteTraverser} ==>result{object=v[5] class=org.apache.tinkerpop.gremlin.process.remote.traversal.DefaultRemoteTraverser} ==>result{object=v[3] class=org.apache.tinkerpop.gremlin.process.remote.traversal.DefaultRemoteTraverser} ==>result{object=v[2] class=org.apache.tinkerpop.gremlin.process.remote.traversal.DefaultRemoteTraverser} gremlin> aliased.submit(g.V().both().barrier().both().barrier().count()).all().get().get(0).getInt() //// **(3)** ==>30 gremlin> rs.collect{[value: it.getObject().get(), bulk: it.getObject().bulk()]} //// **(4)** ==>[value:v[1],bulk:7] ==>[value:v[4],bulk:7] ==>[value:v[6],bulk:3] ==>[value:v[5],bulk:3] ==>[value:v[3],bulk:7] ==>[value:v[2],bulk:3] ``` ```groovy cluster = Cluster.open() client = cluster.connect() aliased = client.alias("g") g = traversal().withEmbedded(org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph.instance()) //// **(1)** rs = aliased.submit(g.V().both().barrier().both().barrier()).all().get() //// **(2)** aliased.submit(g.V().both().barrier().both().barrier().count()).all().get().get(0).getInt() //// **(3)** rs.collect{[value: it.getObject().get(), bulk: it.getObject().bulk()]} //**4** ``` -------------------------------- ### Gremlin Server Response Message Example Source: https://tinkerpop.apache.org/docs/3.7.1/dev/provider An example of a ResponseMessage received from Gremlin Server, indicating partial content of a vertex query result. ```json {"result":{"data":[{"id": 2,"label": "person","type": "vertex","properties": [ {"id": 2, "value": "vadas", "label": "name"}, {"id": 3, "value": 27, "label": "age"}]}], "meta":{}}, "requestId":"1d6d02bd-8e56-421d-9438-3bd6d0079ff1", "status":{"code":206,"attributes":{},"message":""}} ``` -------------------------------- ### Build project and Gremlin Server image Source: https://tinkerpop.apache.org/docs/3.7.1/dev/developer Prepares the local environment and generates the necessary Docker images for Gremlin Server. ```bash mvn clean install -DskipTests ``` ```bash mvn clean install -pl :gremlin-server -DdockerImages -DskipTests ``` -------------------------------- ### Start Gremlin Server Docker Container Source: https://tinkerpop.apache.org/docs/3.7.1/dev/developer Start the Docker-based Gremlin Server for integration tests. The -n flag enables Neo4j for transaction-based tests. ```shell docker/gremlin-server.sh -n ``` -------------------------------- ### Initialize Graph and Create Elements Source: https://tinkerpop.apache.org/docs/3.7.1/dev/provider Demonstrates creating an in-memory TinkerGraph and populating it with vertices and edges using accessor tokens. ```java Graph graph = TinkerGraph.open(); //**1** Vertex marko = graph.addVertex(T.label, "person", T.id, 1, "name", "marko", "age", 29); //**2** Vertex vadas = graph.addVertex(T.label, "person", T.id, 2, "name", "vadas", "age", 27); Vertex lop = graph.addVertex(T.label, "software", T.id, 3, "name", "lop", "lang", "java"); Vertex josh = graph.addVertex(T.label, "person", T.id, 4, "name", "josh", "age", 32); Vertex ripple = graph.addVertex(T.label, "software", T.id, 5, "name", "ripple", "lang", "java"); Vertex peter = graph.addVertex(T.label, "person", T.id, 6, "name", "peter", "age", 35); marko.addEdge("knows", vadas, T.id, 7, "weight", 0.5f); //**3** marko.addEdge("knows", josh, T.id, 8, "weight", 1.0f); marko.addEdge("created", lop, T.id, 9, "weight", 0.4f); josh.addEdge("created", ripple, T.id, 10, "weight", 1.0f); josh.addEdge("created", lop, T.id, 11, "weight", 0.4f); peter.addEdge("created", lop, T.id, 12, "weight", 0.2f); ``` -------------------------------- ### Generate Sample Graph Data Source: https://tinkerpop.apache.org/docs/3.7.1/recipes Creates 'person' and 'product' vertices and 'bought' edges to simulate user purchase history. This is the initial setup for the recommendation system. ```groovy gremlin> g.addV("person").property("name","alice"). addV("person").property("name","bob"). addV("person").property("name","jon"). addV("person").property("name","jack"). addV("person").property("name","jill").iterate() gremlin> (1..10).each { g.addV("product").property("name","product #${it}").iterate() }; [] gremlin> (3..7).each { g.V().has("person","name","alice").as("p"). V().has("product","name","product #${it}").addE("bought").from("p").iterate() }; [] gremlin> (1..5).each { g.V().has("person","name","bob").as("p"). V().has("product","name","product #${it}").addE("bought").from("p").iterate() }; [] gremlin> (6..10).each { g.V().has("person","name","jon").as("p"). V().has("product","name","product #${it}").addE("bought").from("p").iterate() }; [] gremlin> 1.step(10, 2) { g.V().has("person","name","jack").as("p"). V().has("product","name","product #${it}").addE("bought").from("p").iterate() }; [] gremlin> 2.step(10, 2) { g.V().has("person","name","jill").as("p"). V().has("product","name","product #${it}").addE("bought").from("p").iterate() }; [] ``` ```groovy g.addV("person").property("name","alice"). addV("person").property("name","bob"). addV("person").property("name","jon"). addV("person").property("name","jack"). addV("person").property("name","jill").iterate() (1..10).each { g.addV("product").property("name","product #${it}").iterate() }; [] (3..7).each { g.V().has("person","name","alice").as("p"). V().has("product","name","product #${it}").addE("bought").from("p").iterate() }; [] (1..5).each { g.V().has("person","name","bob").as("p"). V().has("product","name","product #${it}").addE("bought").from("p").iterate() }; [] (6..10).each { g.V().has("person","name","jon").as("p"). V().has("product","name","product #${it}").addE("bought").from("p").iterate() }; [] 1.step(10, 2) { g.V().has("person","name","jack").as("p"). V().has("product","name","product #${it}").addE("bought").from("p").iterate() }; [] 2.step(10, 2) { g.V().has("person","name","jill").as("p"). V().has("product","name","product #${it}").addE("bought").from("p").iterate() }; [] ``` -------------------------------- ### Gremlin Traversal Profiling Example Source: https://tinkerpop.apache.org/docs/3.7.1/recipes This example demonstrates a Gremlin traversal that includes aliasing, conditional filtering, and profiling to capture detailed execution metrics. ```gremlin g.V().as('a'). both().where(lt('a')).by(id).as('b'). both().where(lt('a').and(gt('b'))).by(id).as('c'). not(both().where(eq('a'))). select('a','b','c'). by('name'). profile() ``` ```gremlin g.V().as('a'). both().where(lt('a')).by(id).as('b'). both().where(lt('a')).by(id).where(gt('b')).by(id).as('c'). not(both().where(eq('a'))). select('a','b','c'). by('name'). profile() ``` ```gremlin g.V().as('a'). both().where(lt('a')).by(id).as('b'). both().where(lt('a').and(gt('b'))).by(id).as('c'). not(both().where(eq('a'))). select('a','b','c'). by('name'). profile() ``` -------------------------------- ### Groovy Gremlin Sugar Syntax Example Source: https://tinkerpop.apache.org/docs/3.7.1/dev/developer This example demonstrates the Gremlin-Groovy sugar syntax, which should be used in Gremlin-Groovy test cases to specifically test sugar. ```groovy g.V.age.sum ``` -------------------------------- ### Using min() and max() on Comparable values Source: https://tinkerpop.apache.org/docs/3.7.1/upgrade min() and max() steps now support any Comparable value, simplifying queries that previously required sorting. ```gremlin gremlin> g.V().values('name').min() ==>josh gremlin> g.V().values('name').max() ==>vadas ``` -------------------------------- ### Configure Traversal Options Source: https://tinkerpop.apache.org/docs/3.7.1/upgrade Demonstrates different ways to apply traversal-level configurations using OptionsStrategy or the with() modulator. ```java g.withStrategies(OptionsStrategy.build().with("specialLimit", 10000).create()).V(); ``` ```java g.with("specialLimit", 10000)).V(); ``` -------------------------------- ### Generate Test Coverage Report Source: https://tinkerpop.apache.org/docs/3.7.1/dev/developer Create a test coverage report by running 'mvn clean install -Dcoverage'. The 'install' phase is required for report aggregation. ```bash mvn clean install -Dcoverage ``` -------------------------------- ### Demonstrate String Formatting with Element Properties Source: https://tinkerpop.apache.org/docs/3.7.1/upgrade Use the `format()` step to create strings by embedding element properties. This example shows formatting with the 'name' and 'age' properties. ```gremlin gremlin> g.V().format("%{name} is %{age} years old") ==>marko is 29 years old ==>vadas is 27 years old ==>josh is 32 years old ==>peter is 35 years old ``` -------------------------------- ### Build and Publish Release Candidate Source: https://tinkerpop.apache.org/docs/3.7.1/dev/developer Commands to build the project, publish documentation, and manage versioning for a release candidate. ```bash mvn clean install ``` ```bash docker/build.sh -t -i -n ``` ```bash bin/publish-docs.sh ``` ```bash mvn versions:set -DnewVersion=xx.yy.zz -DgenerateBackupPoms=false ``` ```bash mvn clean install -DskipTests ``` ```bash pushd gremlin-console/bin; ln -fs ../target/apache-tinkerpop-gremlin-console-xx.yy.zz-standalone/bin/gremlin.sh gremlin.sh; popd ``` ```bash git diff ``` ```bash git commit -a -m "TinkerPop xx.yy.zz release" && git push ``` ```bash git tag -a -m "TinkerPop xx.yy.zz release" xx.yy.zz && git push --tags ``` ```bash mvn clean install ``` ```bash mvn versions:set -DnewVersion=xx.yy.zz-SNAPSHOT -DgenerateBackupPoms=false ``` ```bash mvn clean install -DskipTests ``` ```bash pushd gremlin-console/bin; ln -fs ../target/apache-tinkerpop-gremlin-console-xx.yy.zz-SNAPSHOT-standalone/bin/gremlin.sh gremlin.sh; popd ``` ```bash git commit -a -m "Returned to xx.yy.zz-SNAPSHOT" && git push ``` -------------------------------- ### TinkerGraph Plugin Example Source: https://tinkerpop.apache.org/docs/3.7.1/dev/provider An example of a simple Gremlin plugin that provides a list of classes for import, making TinkerGraph implementations available to users. This plugin extends AbstractGremlinPlugin. ```java package org.apache.tinkerpop.gremlin.tinkergraph.jsr223; import org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin; import org.apache.tinkerpop.gremlin.jsr223.DefaultImportCustomizer; import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer; import org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerGraphComputer; import org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerGraphComputerView; import org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerMapEmitter; import org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerMemory; import org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerMessenger; import org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerReduceEmitter; import org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerWorkerPool; import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerEdge; import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerElement; import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory; import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraphVariables; import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerHelper; import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV1; import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV2; import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV3; import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerProperty; import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex; import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertexProperty; /** ``` -------------------------------- ### GraphSON Duration Example Source: https://tinkerpop.apache.org/docs/3.7.1/dev/io Represents a Duration value in GraphSON format, using ISO 8601 duration format. This example shows a duration of five days. This requires the `GraphSONXModuleV2` to be enabled. ```json { "@type" : "gx:Duration", "@value" : "PT120H" } ``` -------------------------------- ### Create Feature Branch and Initial Commit Source: https://tinkerpop.apache.org/docs/3.7.1/dev/developer This example demonstrates how to create a new feature branch from a specific release branch and make an initial commit. ```bash git checkout -b TINKERPOP-1234 3.4-dev // do a bunch of stuff to implement TINKERPOP-1234 and commit/push git checkout -b master git merge TINKERPOP-1234 ``` -------------------------------- ### Find Vertices with Specific Edge Relationships Source: https://tinkerpop.apache.org/docs/3.7.1/recipes This snippet finds vertices that have a specific edge relationship, ensuring that the other vertex involved in the edge is not the same as the starting vertex, and that there are other edges connecting back to the starting vertex. ```gremlin g.V().where(without("x")).as("a"). outE().as("e").inV().as("b"). filter(bothE().where(neq("e")).otherV().where(eq("a"))).aggregate(local, "x"). select("a","b").dedup() ``` -------------------------------- ### Match Step Behavior - Basic Source: https://tinkerpop.apache.org/docs/3.7.1/upgrade Illustrates the basic behavior of the `match()` step without explicit label selection. The output includes all matched labels by default. ```gremlin gremlin> g.V().match(__.as("a").out("knows").as("b")) ==>[a:v[1],b:v[2]] ==>[a:v[1],b:v[4]] ``` ```gremlin gremlin> g.V().match(__.as("a").out("knows").as("b")).unfold() ``` ```gremlin gremlin> g.V().match(__.as("a").out("knows").as("b")).identity() ==>[] ==>[] ``` -------------------------------- ### Configure withStrategies in Groovy Source: https://tinkerpop.apache.org/docs/3.7.1/upgrade Demonstrates the transition from standard builder syntax to the more succinct Groovy-native syntax for defining traversal strategies. ```groovy g.withStrategies(ReadOnlyStrategy.instance(), SubgraphStrategy.build().vertexProperties(hasNot('endTime')).create()) ``` ```groovy g.withStrategies(ReadOnlyStrategy, new SubgraphStrategy(vertexProperties: __.hasNot('endTime'))) ``` -------------------------------- ### Get or Create Vertex with fold() and coalesce() Source: https://tinkerpop.apache.org/docs/3.7.1/recipes Implement the 'get or create' pattern for vertices. `fold()` collects any existing vertex into a list, and `coalesce()` either unfolds the existing vertex or adds a new one if the list is empty. ```groovy gremlin> g.V().has('person','name','marko'). fold(). coalesce(unfold(), addV('person'). property('name','marko'). property('age',29)) gremlin> g.V().has('person','name','stephen'). fold(). coalesce(unfold(), addV('person'). property('name','stephen'). property('age',34)) ``` ```groovy g.V().has('person','name','marko'). fold(). coalesce(unfold(), addV('person'). property('name','marko'). property('age',29)) g.V().has('person','name','stephen'). fold(). coalesce(unfold(), addV('person'). property('name','stephen'). property('age',34)) ``` -------------------------------- ### Authentication RequestMessage Source: https://tinkerpop.apache.org/docs/3.7.1/dev/io Example of a RequestMessage for SASL-based authentication. ```APIDOC ## POST /gremlin ### Description Sends an authentication request to the Gremlin Server using SASL. ### Method POST ### Endpoint /gremlin ### Request Body - **requestId** (string) - Required - A unique identifier for the request. - **op** (string) - Required - The operation type, should be "authentication". - **processor** (string) - Optional - The processor to use, typically empty for authentication. - **args** (object) - Required - Arguments for the authentication operation. - **saslMechanism** (string) - Required - The SASL mechanism to use (e.g., "PLAIN"). - **sasl** (string) - Required - The base64 encoded SASL authentication data. ### Request Example ```json { "requestId" : "cb682578-9d92-4499-9ebc-5c6aa73c5397", "op" : "authentication", "processor" : "", "args" : { "saslMechanism" : "PLAIN", "sasl" : "AHN0ZXBocGhlbgBwYXNzd29yZA==" } } ``` ### Response #### Success Response (200) - **requestId** (string) - The ID of the request. - **status** (object) - The status of the operation. - **message** (string) - A message associated with the status. - **code** (integer) - The HTTP status code. - **attributes** (object) - Additional attributes for the status. - **result** (object) - The result of the operation. - **data** (any) - The data returned by the operation. - **meta** (object) - Metadata associated with the result. #### Response Example (Authentication Challenge) ```json { "requestId" : "41d2e28a-20a4-4ab0-b379-d810dede3786", "status" : { "message" : "", "code" : 407, "attributes" : { } }, "result" : { "data" : null, "meta" : { } } } ``` ``` -------------------------------- ### Initialize and use Gremlin-Python Client Source: https://tinkerpop.apache.org/docs/3.7.1/upgrade Instantiate a Client directly to submit Gremlin queries asynchronously. Ensure the connection is closed after use to release resources. ```python from gremlin_python.driver import client client = client.Client('ws://localhost:8182/gremlin', 'g') result_set = client.submit('1 + 1') future_results = result_set.all() # returns a concurrent.futures.Future results = future_results.result() # returns a list assert results == [2] client.close() # don't forget to close underlying connections ``` -------------------------------- ### Publish Documentation Snapshot Source: https://tinkerpop.apache.org/docs/3.7.1/dev/developer Deploy a SNAPSHOT version of the documentation to validate the generation process. ```bash bin/publish-docs.sh ``` -------------------------------- ### Authentication Challenge Source: https://tinkerpop.apache.org/docs/3.7.1/dev/io Example of an authentication challenge response when authentication is enabled. ```APIDOC ## Response Message - Authentication Challenge ### Description This response is returned when authentication is enabled and the server challenges the client for credentials. ### Status Code 407 (Proxy Authentication Required) ### Response Body Example ```json { "requestId" : "41d2e28a-20a4-4ab0-b379-d810dede3786", "status" : { "message" : "", "code" : 407, "attributes" : { "@type" : "g:Map", "@value" : [ ] } }, "result" : { "data" : null, "meta" : { "@type" : "g:Map", "@value" : [ ] } } } ``` ### Notes - The handling of this challenge can vary based on the SASL implementation. - Some SASL implementations might request multiple challenges. ``` -------------------------------- ### Sessionless Eval Source: https://tinkerpop.apache.org/docs/3.7.1/dev/io Example of a sessionless request for script evaluation with parameters. ```APIDOC ## POST /gremlin ### Description Evaluates a Gremlin script sessionlessly with provided parameters. ### Method POST ### Endpoint /gremlin ### Request Body - **requestId** (string) - Required - Unique identifier for the request. - **op** (string) - Required - Operation type, should be 'eval'. - **processor** (string) - Optional - Processor to use for the request. - **args** (object) - Required - Arguments for the evaluation, including the script, language, and bindings. - **@type** (string) - Required - Type indicator, typically 'g:Map'. - **@value** (array) - Required - Array containing script, language, and bindings. - **gremlin** (string) - The Gremlin script to evaluate. - **language** (string) - The language of the script (e.g., 'gremlin-groovy'). - **bindings** (object) - Map of variable bindings for the script. - **@type** (string) - Required - Type indicator, typically 'g:Map'. - **@value** (array) - Required - Array of key-value pairs for bindings. - **x** (string) - Variable name. - **@type** (string) - Type indicator for the value (e.g., 'g:Int32'). - **@value** (any) - The value of the binding. ### Request Example ```json { "requestId" : "cb682578-9d92-4499-9ebc-5c6aa73c5397", "op" : "eval", "processor" : "", "args" : { "@type" : "g:Map", "@value" : [ "gremlin", "g.V(x)", "language", "gremlin-groovy", "bindings", { "@type" : "g:Map", "@value" : [ "x", { "@type" : "g:Int32", "@value" : 1 } ] } ] } } ``` ### Response #### Success Response (200) - **requestId** (string) - The ID of the request. - **status** (object) - The status of the operation. - **result** (object) - The result of the script evaluation. #### Response Example ```json { "requestId": "cb682578-9d92-4499-9ebc-5c6aa73c5397", "status": { "message": "", "code": 200, "attributes": { "@type": "g:Map", "@value": [] } }, "result": { "data": [ { "@type": "g:Vertex", "@value": { "id": { "@type": "g:Int64", "@value": 1 }, "label": "person" } } ], "meta": { "@type": "g:Map", "@value": [] } } } ``` ``` -------------------------------- ### Run GLV tests with minimal dependencies Source: https://tinkerpop.apache.org/docs/3.7.1/dev/developer Executes integration and standard tests for Python and Go modules using the build script. ```bash ./docker/build.sh --tests --integration-tests --python --golang ```