├── .gitignore
├── .travis.yml
├── CHANGELOG.textile
├── LICENSE.txt
├── README.textile
├── bin
├── gremlin.bat
└── gremlin.sh
├── data
├── graph-example-1.json
├── graph-example-1.ntriple
├── graph-example-1.xml
└── graph-example-2.xml
├── doc
├── Acknowledgments.textile
├── Backtrack-Pattern.textile
├── Basic-Graph-Traversals.textile
├── Defining-a-More-Complex-Property-Graph.textile
├── Defining-a-Property-Graph.textile
├── Depth-First-vs.-Breadth-First.textile
├── Downloads.textile
├── Except-Retain-Pattern.textile
├── Flow-Rank-Pattern.textile
├── Getting-Started.textile
├── Gremlin-Groovy-Path-Optimizations.textile
├── Gremlin-Methods.textile
├── Gremlin-Steps.textile
├── Home.textile
├── JVM-Language-Implementations.textile
├── Learning-Dependencies.textile
├── LinkedData-Sail.textile
├── Loop-Pattern.textile
├── MapReduce-Pattern.textile
├── Path-Pattern.textile
├── Pattern-Match-Pattern.textile
├── Release-Notes.textile
├── SPARQL-vs.-Gremlin.textile
├── Split-Merge-Pattern.textile
├── Step-Closures.textile
├── The-Benefits-of-Gremlin.textile
├── Traversal-Optimization.textile
├── Tree-Pattern.textile
├── Troubleshooting.textile
├── Updating-a-Graph.textile
├── User-Defined-Steps.textile
├── Using-Gremlin-through-Groovy.textile
├── Using-Gremlin-through-Java.textile
├── Using-JUNG.textile
├── Writing-Gremlin-REPL-Plugins.textile
└── images
│ ├── co-followed_by-example.jpg
│ ├── co-followed_by.graffle
│ ├── dbpedia-logo.png
│ ├── depth-vs-breadth.gif
│ ├── favicon.ico
│ ├── grammar-example-1.graffle
│ ├── grammar-example-1.jpg
│ ├── grammar-map-example-1.jpg
│ ├── grammar-map-rewrite.graffle
│ ├── grammar-map-rewrite.jpg
│ ├── graph-example-1-codeveloper.graffle
│ ├── graph-example-1-rdf.graffle
│ ├── graph-example-1-rdf.jpg
│ ├── graph-example-1.graffle
│ ├── graph-example-1.jpg
│ ├── graph-example-2.jpg
│ ├── graph-model.graffle
│ ├── graph-model.jpg
│ ├── grateful-dead-concert.jpg
│ ├── grateful-dead-concert2.jpg
│ ├── gremlin-2.png
│ ├── gremlin-character-2.png
│ ├── gremlin-character-3.png
│ ├── gremlin-characters.pdf
│ ├── gremlin-chickenwing.png
│ ├── gremlin-clownin-around.png
│ ├── gremlin-grad.png
│ ├── gremlin-gremalicious.png
│ ├── gremlin-gremicide.png
│ ├── gremlin-gremlin-the-grouch.png
│ ├── gremlin-gremlin.png
│ ├── gremlin-gremlivich.png
│ ├── gremlin-gremopoly.png
│ ├── gremlin-gremreaper.png
│ ├── gremlin-gremstefani.png
│ ├── gremlin-hardhat.png
│ ├── gremlin-inthewild.png
│ ├── gremlin-kilt.png
│ ├── gremlin-lab-coat.pdf
│ ├── gremlin-lab-coat.png
│ ├── gremlin-logo.graffle
│ ├── gremlin-logo.png
│ ├── gremlin-logo_inv.png
│ ├── gremlin-new-sheriff-in-town.png
│ ├── gremlin-no-more-mr-nice-guy.png
│ ├── gremlin-on-the-case.png
│ ├── gremlin-painting.png
│ ├── gremlin-pipe.png
│ ├── gremlin-running.png
│ ├── gremlin-standing-small.png
│ ├── gremlin-standing.png
│ ├── gremlin-without-a-cause.pdf
│ ├── gremlin-without-a-cause.png
│ ├── gremlin-xmas-alpha.png
│ ├── gremlindocs-logo.graffle
│ ├── gremlindocs-logo.png
│ ├── gremlindocs.pdf
│ ├── gremlindocs.png
│ ├── jerry-followed_by-example.graffle
│ ├── jerry-followed_by-example.jpg
│ ├── jerry-garcia.jpg
│ ├── ldsail-arch.graffle
│ ├── ldsail-arch.jpg
│ ├── lod-cloud.png
│ ├── rdf-graph-model.graffle
│ ├── rdf-graph-model.jpg
│ ├── rdf-logo.gif
│ ├── sql2gremlin-logo.pdf
│ ├── sql2gremlin-logo.png
│ ├── structures-processes.graffle
│ ├── structures-processes.jpg
│ └── tinkerpop-logo-small.jpg
├── gremlin-groovy
├── bin
│ ├── gremlin.bat
│ └── gremlin.sh
├── pom.xml
└── src
│ ├── assembly
│ ├── distribution.xml
│ └── standalone.xml
│ ├── main
│ ├── bin
│ │ ├── README.txt
│ │ ├── gremlin.bat
│ │ └── gremlin.sh
│ ├── groovy
│ │ └── com
│ │ │ └── tinkerpop
│ │ │ └── gremlin
│ │ │ └── groovy
│ │ │ ├── Gremlin.groovy
│ │ │ └── loaders
│ │ │ ├── ElementLoader.groovy
│ │ │ ├── GraphLoader.groovy
│ │ │ ├── IndexLoader.groovy
│ │ │ ├── ObjectLoader.groovy
│ │ │ ├── PipeLoader.groovy
│ │ │ └── SailGraphLoader.groovy
│ ├── java
│ │ └── com
│ │ │ └── tinkerpop
│ │ │ └── gremlin
│ │ │ └── groovy
│ │ │ ├── GremlinGroovyPipeline.java
│ │ │ ├── GroovyPipeFunction.java
│ │ │ ├── console
│ │ │ ├── Console.java
│ │ │ ├── ConsoleGroovy.java
│ │ │ ├── ConsoleIO.java
│ │ │ ├── ConsolePlugin.java
│ │ │ ├── ErrorHookClosure.java
│ │ │ ├── NullResultHookClosure.java
│ │ │ ├── PromptClosure.java
│ │ │ └── ResultHookClosure.java
│ │ │ └── jsr223
│ │ │ ├── AbstractImportCustomizerProvider.java
│ │ │ ├── DefaultImportCustomizerProvider.java
│ │ │ ├── GremlinGroovyScriptEngine.java
│ │ │ ├── GremlinGroovyScriptEngineFactory.java
│ │ │ ├── ImportCustomizerProvider.java
│ │ │ └── ScriptExecutor.java
│ └── resources
│ │ ├── META-INF
│ │ └── services
│ │ │ └── javax.script.ScriptEngineFactory
│ │ └── log4j.properties
│ └── test
│ ├── groovy
│ └── com
│ │ └── tinkerpop
│ │ └── gremlin
│ │ └── groovy
│ │ ├── FunctionStepTest.groovy
│ │ ├── GremlinTest.groovy
│ │ ├── UtilitiesTest.groovy
│ │ ├── basescript
│ │ ├── GremlinGroovyPipelineInterceptor.groovy
│ │ └── GremlinGroovyScriptBaseClassForTest.groovy
│ │ ├── branch
│ │ ├── IfThenElseStepTest.groovy
│ │ ├── LoopStepTest.groovy
│ │ └── SplitMergeStepsTest.groovy
│ │ ├── filter
│ │ ├── BackStepTest.groovy
│ │ ├── DedupStepTest.groovy
│ │ ├── ExceptStepTest.groovy
│ │ ├── FilterStepTest.groovy
│ │ ├── HasNotStepTest.groovy
│ │ ├── HasStepTest.groovy
│ │ ├── IntervalStepTest.groovy
│ │ ├── RangeStepTest.groovy
│ │ └── RetainStepTest.groovy
│ │ ├── loaders
│ │ ├── ElementLoaderTest.groovy
│ │ ├── GraphLoaderTest.groovy
│ │ ├── IndexLoaderTest.groovy
│ │ ├── ObjectLoaderTest.groovy
│ │ ├── PipeLoaderTest.groovy
│ │ └── SailGraphLoaderTest.groovy
│ │ ├── sideeffect
│ │ ├── AggregateStepTest.groovy
│ │ ├── GroupByStepTest.groovy
│ │ ├── GroupCountStepTest.groovy
│ │ ├── LinkedStepTest.groovy
│ │ ├── SideEffectStepTest.groovy
│ │ ├── StoreStepTest.groovy
│ │ ├── TableStepTest.groovy
│ │ └── TreeStepTest.groovy
│ │ └── transform
│ │ ├── GatherStepTest.groovy
│ │ ├── MapStepTest.groovy
│ │ ├── OrderStepTest.groovy
│ │ ├── PathStepTest.groovy
│ │ ├── SelectStepTest.groovy
│ │ ├── TransformStepTest.groovy
│ │ └── TraversalStepsTest.groovy
│ ├── java
│ └── com
│ │ └── tinkerpop
│ │ └── gremlin
│ │ ├── BaseTest.java
│ │ └── groovy
│ │ └── jsr223
│ │ ├── GremlinGroovyScriptEngineTest.java
│ │ └── ScriptExecutorTest.java
│ └── resources
│ └── com
│ └── tinkerpop
│ └── gremlin
│ └── groovy
│ └── jsr223
│ └── GremlinScript.groovy
├── gremlin-java
├── pom.xml
└── src
│ ├── assembly
│ └── distribution.xml
│ ├── main
│ └── java
│ │ └── com
│ │ └── tinkerpop
│ │ └── gremlin
│ │ ├── Imports.java
│ │ ├── Tokens.java
│ │ ├── Version.java
│ │ └── java
│ │ ├── GremlinFluentPipeline.java
│ │ ├── GremlinFluentUtility.java
│ │ ├── GremlinPipeline.java
│ │ └── GremlinStartPipe.java
│ └── test
│ └── java
│ └── com
│ └── tinkerpop
│ └── gremlin
│ └── java
│ ├── FunctionStepTest.java
│ ├── GremlinFluentUtilityTest.java
│ ├── GremlinPipelineTest.java
│ ├── GremlinStartPipeTest.java
│ ├── UtilitiesTest.java
│ ├── branch
│ ├── IfThenElseStepTest.java
│ ├── LoopStepTest.java
│ └── SplitMergeStepsTest.java
│ ├── filter
│ ├── BackStepTest.java
│ ├── DedupStepTest.java
│ ├── ExceptStepTest.java
│ ├── FilterStepTest.java
│ ├── HasNotStepTest.java
│ ├── HasStepTest.java
│ ├── IntervalStepTest.java
│ ├── RangeStepTest.java
│ └── RetainStepTest.java
│ ├── sideeffect
│ ├── AggregateStepTest.java
│ ├── GroupByStepTest.java
│ ├── GroupCountStepTest.java
│ ├── LinkedStepTest.java
│ ├── SideEffectStepTest.java
│ ├── StoreStepTest.java
│ ├── TableStepTest.java
│ └── TreeStepTest.java
│ └── transform
│ ├── GatherStepTest.java
│ ├── MapStepTest.java
│ ├── OrderStepTest.java
│ ├── PathStepTest.java
│ ├── SelectStepTest.java
│ ├── TransformStepTest.java
│ └── TraversalStepsTest.java
├── gremlin-test
├── pom.xml
└── src
│ ├── assembly
│ └── distribution.xml
│ └── main
│ └── java
│ └── com
│ └── tinkerpop
│ └── gremlin
│ └── test
│ ├── ComplianceTest.java
│ ├── FunctionStepTest.java
│ ├── UtilitiesTest.java
│ ├── branch
│ ├── IfThenElseStepTest.java
│ ├── LoopStepTest.java
│ └── SplitMergeStepsTest.java
│ ├── filter
│ ├── BackStepTest.java
│ ├── DedupStepTest.java
│ ├── ExceptStepTest.java
│ ├── FilterStepTest.java
│ ├── HasNotStepTest.java
│ ├── HasStepTest.java
│ ├── IntervalStepTest.java
│ ├── RangeStepTest.java
│ └── RetainStepTest.java
│ ├── sideeffect
│ ├── AggregateStepTest.java
│ ├── GroupByStepTest.java
│ ├── GroupCountStepTest.java
│ ├── LinkStepTest.java
│ ├── SideEffectStepTest.java
│ ├── StoreStepTest.java
│ ├── TableStepTest.java
│ └── TreeStepTest.java
│ └── transform
│ ├── GatherStepTest.java
│ ├── MapStepTest.java
│ ├── OrderStepTest.java
│ ├── PathStepTest.java
│ ├── SelectStepTest.java
│ ├── TransformStepTest.java
│ └── TraversalStepsTest.java
└── pom.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | *.log
2 | .gremlin_history
3 | target/
4 | .idea/
5 | *.iml
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 | jdk:
3 | - oraclejdk7
4 | - openjdk7
5 | - openjdk6
6 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2009-Infinity, TinkerPop [http://tinkerpop.com]
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 | * Redistributions of source code must retain the above copyright
7 | notice, this list of conditions and the following disclaimer.
8 | * Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | * Neither the name of the TinkerPop nor the
12 | names of its contributors may be used to endorse or promote products
13 | derived from this software without specific prior written permission.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | DISCLAIMED. IN NO EVENT SHALL TINKERPOP BE LIABLE FOR ANY
19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
--------------------------------------------------------------------------------
/README.textile:
--------------------------------------------------------------------------------
1 | !https://github.com/tinkerpop/gremlin/raw/master/doc/images/gremlin-logo.png!
2 |
3 |
4 |
5 | *IMPORTANT* - TinkerPop is now a part of the Apache Software Foundation and "TinkerPop 3.x":http://tinkerpop.apache.org/ is the latest incarnation of The TinkerPop. This project is TinkerPop 2.x and is no longer active.
6 |
7 | Gremlin is a domain specific language for traversing property "graphs":http://en.wikipedia.org/wiki/Graph_%28mathematics%29. Gremlin makes use of "Pipes":http://pipes.tinkerpop.com to perform complex graph traversals. This language has application in the areas of graph query, analysis, and manipulation. Connectors, provided by "Blueprints":http://blueprints.tinkerpop.com, exist for the following graph management systems:
8 |
9 | * Graph database connectivity:
10 | ** "TinkerGraph":https://github.com/tinkerpop/blueprints/wiki/TinkerGraph in-memory graph
11 | ** "Neo4j":http://neo4j.org/ graph database
12 | ** "OrientDB":http://www.orientechnologies.com/ graph database
13 | ** "Sparksee":http://www.sparsity-technologies.com/#sparksee graph database
14 | ** "Titan":http://thinkaurelius.github.com/titan/ graph database
15 | ** "Faunus":http://thinkaurelius.github.com/faunus/ graph analytics engine
16 | ** "InfiniteGraph":http://www.objectivity.com/products/infinitegraph/ graph database
17 | ** "Rexster":http://rexster.tinkerpop.com graph server
18 | ** "Sesame 2.x":http://www.openrdf.org compliant RDF stores
19 | ** Many "third-party":https://github.com/tinkerpop/blueprints/wiki Blueprints implementations
20 |
21 | * JVM language connectivity:
22 | ** "Java":http://java.com/: Gremlin in the Java Language
23 | ** "Groovy":http://groovy.codehaus.org/: Gremlin in the Groovy Language
24 | ** Easy to connect to other "JVM languages":http://en.wikipedia.org/wiki/List_of_JVM_languages
25 |
26 | The documentation for Gremlin can be found at this "location":http://gremlin.tinkerpop.com. Finally, please visit "TinkerPop":http://tinkerpop.com for other software products.
27 |
--------------------------------------------------------------------------------
/bin/gremlin.bat:
--------------------------------------------------------------------------------
1 | :: Windows launcher script for Gremlin
2 | @echo off
3 |
4 | cd %CD%\..\gremlin-groovy\target\
5 |
6 | set TARGET=
7 |
8 | for /f "tokens=*" %%a in ('dir /b /ad') do (
9 | if exist "%%a\bin\gremlin.bat" set TARGET=%%a
10 | )
11 |
12 | cd %TARGET%\bin\
13 | call gremlin.bat %*
--------------------------------------------------------------------------------
/bin/gremlin.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | `dirname $0`/../gremlin-groovy/bin/gremlin.sh $@
4 |
--------------------------------------------------------------------------------
/data/graph-example-1.json:
--------------------------------------------------------------------------------
1 | {
2 | "vertices":[
3 | {"name":"marko","age":29,"_id":1,"_type":"vertex"},
4 | {"name":"vadas","age":27,"_id":2,"_type":"vertex"},
5 | {"name":"lop","lang":"java","_id":3,"_type":"vertex"},
6 | {"name":"josh","age":32,"_id":4,"_type":"vertex"},
7 | {"name":"ripple","lang":"java","_id":5,"_type":"vertex"},
8 | {"name":"peter","age":35,"_id":6,"_type":"vertex"}
9 | ],
10 | "edges":[
11 | {"weight":0.5,"_id":7,"_type":"edge","_outV":1,"_inV":2,"_label":"knows"},
12 | {"weight":1.0,"_id":8,"_type":"edge","_outV":1,"_inV":4,"_label":"knows"},
13 | {"weight":0.4,"_id":9,"_type":"edge","_outV":1,"_inV":3,"_label":"created"},
14 | {"weight":1.0,"_id":10,"_type":"edge","_outV":4,"_inV":5,"_label":"created"},
15 | {"weight":0.4,"_id":11,"_type":"edge","_outV":4,"_inV":3,"_label":"created"},
16 | {"weight":0.2,"_id":12,"_type":"edge","_outV":6,"_inV":3,"_label":"created"}
17 | ]
18 | }
--------------------------------------------------------------------------------
/data/graph-example-1.ntriple:
--------------------------------------------------------------------------------
1 | .
2 | .
3 | .
4 |
5 | .
6 | .
7 |
8 | .
9 |
10 | "marko"^^ .
11 | "29"^^ .
12 |
13 | "vadas"^^ .
14 | "27"^^ .
15 |
16 | "lop"^^ .
17 | "java"^^ .
18 |
19 | "josh"^^ .
20 | "32"^^ .
21 |
22 | "ripple"^^ .
23 | "java"^^ .
24 |
25 | "peter"^^ .
26 | "35"^^ .
--------------------------------------------------------------------------------
/data/graph-example-1.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | marko
13 | 29
14 |
15 |
16 | vadas
17 | 27
18 |
19 |
20 | lop
21 | java
22 |
23 |
24 | josh
25 | 32
26 |
27 |
28 | ripple
29 | java
30 |
31 |
32 | peter
33 | 35
34 |
35 |
36 | 0.5
37 |
38 |
39 | 1.0
40 |
41 |
42 | 0.4
43 |
44 |
45 | 1.0
46 |
47 |
48 | 0.4
49 |
50 |
51 | 0.2
52 |
53 |
54 |
--------------------------------------------------------------------------------
/doc/Acknowledgments.textile:
--------------------------------------------------------------------------------
1 | [[https://github.com/tinkerpop/gremlin/raw/master/doc/images/gremlin-standing-small.png]]
2 |
3 | This section provides a list of the people that have contributed in some way to the creation of Gremlin.
4 |
5 | # "Marko A. Rodriguez":http://markorodriguez.com -- designed, developed, tested, and documented Gremlin.
6 | # "Pavel Yaskevich":http://github.com/xedin -- designed and developed Gremlin 0.5 compiler and virtual machine.
7 | # "Darrick Wiebe":http://ofallpossibleworlds.wordpress.com/ -- inspired many of Gremlin 0.7+ developments.
8 | # "Peter Neubauer":http://www.linkedin.com/in/neubauer -- aided in the design and the evangelizing of Gremlin.
9 | # "Joshua Shinavier":http://fortytwo.net -- inspired early design choices.
10 | # "Ketrina Yim":http://www.ketrinayim.com/ -- designed the Gremlin logo.
11 | # "Pierre De Wilde":http://www.linkedin.com/in/pierredewilde -- designs and tests new features.
12 |
13 | Please review Gremlin's "pom.xml":http://github.com/tinkerpop/gremlin/blob/master/pom.xml. Gremlin would not be possible without the work done by others to create these useful packages.
14 |
15 | Join the Gremlin users group at "http://groups.google.com/group/gremlin-users":http://groups.google.com/group/gremlin-users.
--------------------------------------------------------------------------------
/doc/Defining-a-More-Complex-Property-Graph.textile:
--------------------------------------------------------------------------------
1 | The documentation up to this point has been using examples from a simple toy graph of 6 vertices and 6 edges. For this section, a more complicated graph structure is used in the examples. A clipped representation (i.e. low weighted edges removed) of this graph is diagrammed below. This graph is a representation of the American band, the "Grateful Dead":http://en.wikipedia.org/wiki/Grateful_Dead.
2 |
3 | !https://github.com/tinkerpop/gremlin/raw/master/doc/images/graph-example-2.jpg!
4 |
5 | More information about this data set can be found in the following article.
6 |
7 | Rodriguez, M.A., Gintautas, V., Pepe, A., "A Grateful Dead Analysis: The Relationship Between Concert and Listening Behavior":http://arxiv.org/abs/0807.2466, First Monday, volume 14, number 1, University of Illinois at Chicago Library, January 2009.
8 |
9 | ```text
10 | g = new TinkerGraph()
11 | g.loadGraphML('data/graph-example-2.xml')
12 | ```
13 |
14 | In the above Grateful Dead graph, there are vertices and there are edges. The vertices are broken into two sets: songs (e.g. "Dark Star":http://en.wikipedia.org/wiki/Dark_Star_%28song%29, "China Cat Sunflower":http://en.wikipedia.org/wiki/China_Cat_Sunflower) and artists (e.g. "Jerry Garcia":http://en.wikipedia.org/wiki/Jerry_Garcia, "Robert Hunter":http://en.wikipedia.org/wiki/Robert_Hunter_%28lyricist%29). The following itemization describes the properties associated with vertices and edges.
15 |
16 | # vertices
17 | ** song vertices
18 | **** type (string): always 'song' for song vertices.
19 | **** name (string): the name of the song.
20 | **** performances (integer): the number of times the song was played in concert.
21 | **** song_type (string): whether the song is a 'cover' song or an 'original'.
22 | ** artist vertices
23 | **** type (string): always 'artist' for artist vertices.
24 | **** name (string): the name of the artist.
25 | # edges
26 | ** followed_by (song -> song): if the tail song was followed by the head song in concert.
27 | **** weight (integer): the number of times these two songs were paired in concert.
28 | ** sung_by (song -> artist): if the tail song was primarily sung by the head artist.
29 | ** written_by (song -> artist): if the tail song was written by the head artist.
30 |
--------------------------------------------------------------------------------
/doc/Defining-a-Property-Graph.textile:
--------------------------------------------------------------------------------
1 | Gremlin was designed specifically for the analysis and manipulation of key/value-based, directed, multi-relational graphs. This long term refers to a type of graph data structure that has certain features. These features are described as follows. The first term, key/value, refers to the fact that both vertices and edges can have any number of properties associated with them. The second term, directed, refers to the fact that the edges in the graph have a directionality -- that is, there is a tail and head to each edge. Finally, the third term, multi-relational, refers to the fact that there can many types of edges and thus, many types of relationships can exist between the vertices. For the remainder of this documentation, and for the sake of brevity, these types of graphs will be called *property graphs*. A property graph is demonstrated in the following example. This diagrammed property graph comes with the Gremlin distribution in "GraphML":http://graphml.graphdrawing.org/ format at @data/graph-example-1.xml@ (see "graph-example-1.xml":https://github.com/tinkerpop/gremlin/blob/master/data/graph-example-1.xml) or GraphSON at @data/graph-example-1.json@ (see "graph-example-1.json":https://github.com/tinkerpop/gremlin/blob/master/data/graph-example-1.json)
2 |
3 | !https://github.com/tinkerpop/gremlin/raw/master/doc/images/graph-example-1.jpg!
4 |
5 | A property graph has these elements:
6 | # a set of vertices
7 | ** each vertex has a unique identifier.
8 | ** each vertex has a set of outgoing edges.
9 | ** each vertex has a set of incoming edges.
10 | ** each vertex has a collection of properties defined by a map from key to value.
11 | # a set of edges
12 | ** each edge has a unique identifier.
13 | ** each edge has an outgoing tail vertex.
14 | ** each edge has an incoming head vertex.
15 | ** each edge has a label that denotes the type of relationship between its two vertices.
16 | ** each edge has a collection of properties defined by a map from key to value.
17 |
18 | Learn more about the property graph data model from "Blueprints":http://blueprints.tinkerpop.com.
19 |
20 | !https://github.com/tinkerpop/blueprints/raw/master/doc/images/blueprints-logo.png!:http://blueprints.tinkerpop.com
--------------------------------------------------------------------------------
/doc/Downloads.textile:
--------------------------------------------------------------------------------
1 | !https://github.com/tinkerpop/gremlin/raw/master/doc/images/gremlin-logo.png!
2 | [[Release Notes]] for all versions
3 | ==
==
4 | * *Gremlin 2.x*
5 | ** "Gremlin 2.4.0":http://tinkerpop.com/downloads/gremlin/gremlin-groovy-2.4.0.zip
6 | ** "Gremlin 2.3.0":http://tinkerpop.com/downloads/gremlin/gremlin-groovy-2.3.0.zip
7 | ** "Gremlin 2.2.0":http://tinkerpop.com/downloads/gremlin/gremlin-groovy-2.2.0.zip
8 | ** "Gremlin 2.1.0":http://tinkerpop.com/downloads/gremlin/gremlin-groovy-2.1.0.zip
9 | ** "Gremlin 2.0.0":http://tinkerpop.com/downloads/gremlin/gremlin-groovy-2.0.0.zip
10 |
11 | * *Gremlin 1.x*
12 | ** "Gremlin 1.5":http://tinkerpop.com/downloads/gremlin/gremlin-groovy-1.5.zip
13 | ** "Gremlin 1.4":http://tinkerpop.com/downloads/gremlin/gremlin-groovy-1.4.zip
14 | ** "Gremlin 1.3":http://tinkerpop.com/downloads/gremlin/gremlin-1.3.zip
15 | ** "Gremlin 1.2":http://tinkerpop.com/downloads/gremlin/gremlin-1.2.zip
16 | ** "Gremlin 1.1":http://tinkerpop.com/downloads/gremlin/gremlin-1.1.zip
17 | ** "Gremlin 1.0":http://tinkerpop.com/downloads/gremlin/gremlin-1.0.zip
18 |
19 | * *Gremlin 0.x*
20 | ** "Gremlin 0.9":http://tinkerpop.com/downloads/gremlin/gremlin-0.9.zip
21 | ** "Gremlin 0.8":http://tinkerpop.com/downloads/gremlin/gremlin-0.8.zip
22 | ** "Gremlin 0.7":http://tinkerpop.com/downloads/gremlin/gremlin-0.7.zip
23 | ** "Gremlin 0.6":http://tinkerpop.com/downloads/gremlin/gremlin-0.6.zip
24 | ** "Gremlin 0.5.5":http://tinkerpop.com/downloads/gremlin/gremlin-0.5.5.zip
25 | ** "Gremlin 0.5":http://tinkerpop.com/downloads/gremlin/gremlin-0.5.zip
26 | ** "Gremlin 0.2.2":http://tinkerpop.com/downloads/gremlin/gremlin-0.2.2.zip
27 | ** "Gremlin 0.2.1":http://tinkerpop.com/downloads/gremlin/gremlin-0.2.1.zip
28 | ** "Gremlin 0.2":http://tinkerpop.com/downloads/gremlin/gremlin-0.2.zip
29 | ** "Gremlin 0.1":http://tinkerpop.com/downloads/gremlin/gremlin-0.1.zip
--------------------------------------------------------------------------------
/doc/Except-Retain-Pattern.textile:
--------------------------------------------------------------------------------
1 | [[https://github.com/tinkerpop/gremlin/raw/master/doc/images/gremlin-kilt.png]]
2 |
3 | In many instances its desirable to traverse to only those elements that have not been seen in a previous step. Specific use cases are:
4 |
5 | * "Who are my friends friends that are not already my friends?"
6 | * "What is liked by the people that like the same things as me that I don't already like?"
7 |
8 | The solution to these types of problems is provided by the except pattern. Its opposite is the retain pattern--only traverse to those vertices that have been seen in a previous step.
9 |
10 | ```text
11 | gremlin> g = TinkerGraphFactory.createTinkerGraph()
12 | ==>tinkergraph[vertices:6 edges:6]
13 | gremlin> g.v(1).out
14 | ==>v[2]
15 | ==>v[3]
16 | ==>v[4]
17 | gremlin> g.v(1).out.out
18 | ==>v[5]
19 | ==>v[3]
20 | ```
21 |
22 | Both the first and the second emit @v[3]@. To ensure that @v[3]@ is not traversed to on the second step, its necessary to save the results seen after the first @out@. There are three high-level pipes called @aggregate@, @except@, and @retain@. In the examples below, @x@ stores all the values seen up to the @aggregate@ step. Note that, everything in @out@ is "drained" into @x@ before going to the next @out@.
23 |
24 | ```text
25 | gremlin> x = []
26 | gremlin> g.v(1).out.aggregate(x).out.except(x)
27 | ==>v[5]
28 | ```
29 |
30 | ```text
31 | gremlin> x = []
32 | gremlin> g.v(1).out.aggregate(x).out.retain(x)
33 | ==>v[3]
34 | ```
35 |
36 | With named steps it is possible to @except@ and @retain@ previously (and actually forward) objects in the pipeline.
37 |
38 | ```text
39 | gremlin> g.v(1).as('x').out('created').in('created').except('x')
40 | ==>v[4]
41 | ==>v[6]
42 | ```
--------------------------------------------------------------------------------
/doc/Split-Merge-Pattern.textile:
--------------------------------------------------------------------------------
1 | !https://github.com/tinkerpop/gremlin/raw/master/doc/images/gremlin-kilt.png!
2 |
3 | Most Gremlin pipelines are serial in that one step feeds to the next, so on and so forth. There are situations where it is desirable to split a pipeline and thus, have @n@-parallel steps that are later merged back into a serial flow. To support this type of traversal, there are split and merge steps.
4 |
5 | * Split
6 | ** @copySplit@: copy the incoming object to each pipeline
7 | * Merge
8 | ** @fairMerge@: merge the parallel traversals in a round-robin fashion
9 | ** @exhaustMerge@: merge the parallel traversals by exhaustively getting the objects of the first, then the second, etc.
10 |
11 | ```text
12 | gremlin> g.v(1).out('knows').copySplit(_().out('created').name, _().age).fairMerge
13 | ==>ripple
14 | ==>27
15 | ==>lop
16 | ==>32
17 | gremlin> g.v(1).out('knows').copySplit(_().out('created').name, _().age).exhaustMerge
18 | ==>ripple
19 | ==>lop
20 | ==>27
21 | ==>32
22 | ```
23 |
24 | A useful representation of the the split/merge pattern is as follows.
25 |
26 | ```text
27 | g.v(1).out('knows').copySplit(
28 | _().out('created').name,
29 | _().age
30 | ).fairMerge
31 | ```
--------------------------------------------------------------------------------
/doc/Step-Closures.textile:
--------------------------------------------------------------------------------
1 | !http://upload.wikimedia.org/wikipedia/commons/thumb/e/ee/Lambda_uc_lc.svg/150px-Lambda_uc_lc.svg.png!
2 |
3 | Many Gremlin steps take a user-defined function (or functions). These steps have the form:
4 |
5 | ```
6 | step{ // some function }
7 | ```
8 |
9 | A Gremlin closure/function can take either one or two arguments. If passed one argument, then the argument references the current object passing through the step. For instance:
10 |
11 | ```
12 | gremlin> g.v(1).out.transform{it.name}
13 | ==>vadas
14 | ==>josh
15 | ==>lop
16 | ```
17 |
18 | The variable @it@ is a shorthand for naming the argument as follows:
19 |
20 | ```
21 | gremlin> g.v(1).out.transform{v -> v.name}
22 | ==>vadas
23 | ==>josh
24 | ==>lop
25 | ```
26 |
27 | If two arguments are passed to the closure, then the second argument represents the variable map of the Gremlin pipeline. When a step is named using @as@, then the last object that has passed through that named step can be accessed in the step closure. For instance:
28 |
29 | ```
30 | gremlin> g.v(1).out.as('x').out.transform{v,m -> m.x.name + ' ' + v.name}
31 | ==>josh ripple
32 | ==>josh lop
33 | ```
34 |
35 | The variable @m@ has a @get(String name)@ method which allows getting the value last seen at the particular named step.
--------------------------------------------------------------------------------
/doc/Troubleshooting.textile:
--------------------------------------------------------------------------------
1 | When working with Gremlin, there may be issues that arise. This section hopes to articulate common problems users have an how to resolve them.
2 |
3 | h2. Nearly everything is an iterator
4 |
5 | The expression @g.V[0]@ seems like it is returning the first vertex in the graph. However, this statement is in fact creating an iterator/iterable (i.e. a "Pipe":http://pipes.tinkerpop.com) that will return the first vertex in the graph when @next()@ is called on it. Thus, use @g.V[0].next()@ to return the first vertex in the graph. Better yet, just use @g.V.next()@.
6 |
7 | In general, when using the "Gremlin console":https://github.com/tinkerpop/gremlin/wiki/Using-Gremlin-from-the-Command-Line, it is not necessary to call @next()@ as the console will automatically iterate it and @==>@ print the objects of the iterator. However, when using Gremlin in, for example, "Java":https://github.com/tinkerpop/gremlin/wiki/Using-Gremlin-through-Java or "Groovy":https://github.com/tinkerpop/gremlin/wiki/Using-Gremlin-through-Groovy, be sure to iterate the pipe. Note that the [[Gremlin methods]] provide various shorthand mechanisms for this. For example, @iterate()@ will "@while(hasNext())@" and tends to be use consistently.
8 |
9 | h2. When the Gremlin Groovy console is stuck, use clear
10 |
11 | Many times you will misplace a @(@ or a @{@ and your console terminal will be "stuck." To get out of this situation, just type @clear@ to reset the parser.
12 |
13 | ```text
14 | gremlin> if(true) {
15 | gremlin> 1+2
16 | gremlin> {
17 | gremlin> }
18 | gremlin> 1
19 | groovysh_parse: 24: Ambiguous expression could be a parameterless ...
20 | 1 error
21 | gremlin> 1
22 | groovysh_parse: 24: Ambiguous expression could be a parameterless ...
23 | 1 error
24 | gremlin> clear
25 | gremlin> 1
26 | ==>1
27 | ```
--------------------------------------------------------------------------------
/doc/Writing-Gremlin-REPL-Plugins.textile:
--------------------------------------------------------------------------------
1 | Developers who wish to extend the features of the Gremlin REPL can do so by writing a plugin. Common use cases for plugin development include:
2 |
3 | * Not all Blueprints implementations are distributed via the Gremlin distribution. A plugin provides a common way for any Blueprints implementations to be accessible in the REPL.
4 | * Third-party developers who implement Blueprints, may wish to extend the Gremlin language with new features specific to their database.
5 | * Extend the Gremlin language to include a convenient overload to an existing step or include entirely new functions to the language itself.
6 |
7 | Users can load plugins with the @Gremlin.use()@ function which is described in greater detail "here":Using-Gremlin-through-Groovy#use-of-external-jars.
8 |
9 | h2. Writing a Plugin
10 |
11 | To write a plugin, first implement the @com.tinkerpop.gremlin.groovy.console.ConsolePlugin@ interface. It has two methods to implement: @getName@ and @pluginTo@. The @getName@ method simply returns the "name" of the plugin. This name must be unique within the list of plugins loaded to the REPL at any given point. If a naming conflict occurs, the second plugin to be loaded with that name will be ignored.
12 |
13 | The @pluginTo@ method has the following signature:
14 |
15 | ```java
16 | void pluginTo(final ConsoleGroovy groovy, final ConsoleIO io, final Map args);
17 | ```
18 |
19 | This method gets called when the @Gremlin.use()@ function is called and after all dependencies have been loaded by "Grape":http://groovy.codehaus.org/Grape. The reference to @ConsoleGroovy@ allows the execution of arbitrary Groovy within the context of the REPL. For example, a common function of a plugin would be to auto-import classes for users that are relevant to the plugin:
20 |
21 | ```java
22 | groovy.execute("import org.apache.commons.math3.util.FastMath");
23 | ```
24 |
25 | The @ConsoleIO@ argument allows the plugin to write something to the console for the caller to see and the @Map@ argument contains any arguments that were passed to @Gremlin.use()@.
26 |
27 | Once the implementation of the @ConsolePlugin@ has been written, it must be made available such that the @Gremlin.use()@ function can find it at runtime. Gremlin uses "ServiceLoader":http://docs.oracle.com/javase/6/docs/api/java/util/ServiceLoader.html to lookup plugin implementations at runtime. Therefore, to make the implementation known, add a @com.tinkerpop.gremlin.groovy.console.ConsolePlugin@ file to the @META-INF/services@ of the package plugin. The file should list the fully qualified name of the @ConsolePlugin@ class.
--------------------------------------------------------------------------------
/doc/images/co-followed_by-example.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/co-followed_by-example.jpg
--------------------------------------------------------------------------------
/doc/images/co-followed_by.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/co-followed_by.graffle
--------------------------------------------------------------------------------
/doc/images/dbpedia-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/dbpedia-logo.png
--------------------------------------------------------------------------------
/doc/images/depth-vs-breadth.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/depth-vs-breadth.gif
--------------------------------------------------------------------------------
/doc/images/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/favicon.ico
--------------------------------------------------------------------------------
/doc/images/grammar-example-1.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/grammar-example-1.graffle
--------------------------------------------------------------------------------
/doc/images/grammar-example-1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/grammar-example-1.jpg
--------------------------------------------------------------------------------
/doc/images/grammar-map-example-1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/grammar-map-example-1.jpg
--------------------------------------------------------------------------------
/doc/images/grammar-map-rewrite.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/grammar-map-rewrite.graffle
--------------------------------------------------------------------------------
/doc/images/grammar-map-rewrite.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/grammar-map-rewrite.jpg
--------------------------------------------------------------------------------
/doc/images/graph-example-1-codeveloper.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/graph-example-1-codeveloper.graffle
--------------------------------------------------------------------------------
/doc/images/graph-example-1-rdf.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/graph-example-1-rdf.graffle
--------------------------------------------------------------------------------
/doc/images/graph-example-1-rdf.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/graph-example-1-rdf.jpg
--------------------------------------------------------------------------------
/doc/images/graph-example-1.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/graph-example-1.graffle
--------------------------------------------------------------------------------
/doc/images/graph-example-1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/graph-example-1.jpg
--------------------------------------------------------------------------------
/doc/images/graph-example-2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/graph-example-2.jpg
--------------------------------------------------------------------------------
/doc/images/graph-model.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/graph-model.graffle
--------------------------------------------------------------------------------
/doc/images/graph-model.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/graph-model.jpg
--------------------------------------------------------------------------------
/doc/images/grateful-dead-concert.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/grateful-dead-concert.jpg
--------------------------------------------------------------------------------
/doc/images/grateful-dead-concert2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/grateful-dead-concert2.jpg
--------------------------------------------------------------------------------
/doc/images/gremlin-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-2.png
--------------------------------------------------------------------------------
/doc/images/gremlin-character-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-character-2.png
--------------------------------------------------------------------------------
/doc/images/gremlin-character-3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-character-3.png
--------------------------------------------------------------------------------
/doc/images/gremlin-characters.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-characters.pdf
--------------------------------------------------------------------------------
/doc/images/gremlin-chickenwing.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-chickenwing.png
--------------------------------------------------------------------------------
/doc/images/gremlin-clownin-around.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-clownin-around.png
--------------------------------------------------------------------------------
/doc/images/gremlin-grad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-grad.png
--------------------------------------------------------------------------------
/doc/images/gremlin-gremalicious.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-gremalicious.png
--------------------------------------------------------------------------------
/doc/images/gremlin-gremicide.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-gremicide.png
--------------------------------------------------------------------------------
/doc/images/gremlin-gremlin-the-grouch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-gremlin-the-grouch.png
--------------------------------------------------------------------------------
/doc/images/gremlin-gremlin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-gremlin.png
--------------------------------------------------------------------------------
/doc/images/gremlin-gremlivich.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-gremlivich.png
--------------------------------------------------------------------------------
/doc/images/gremlin-gremopoly.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-gremopoly.png
--------------------------------------------------------------------------------
/doc/images/gremlin-gremreaper.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-gremreaper.png
--------------------------------------------------------------------------------
/doc/images/gremlin-gremstefani.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-gremstefani.png
--------------------------------------------------------------------------------
/doc/images/gremlin-hardhat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-hardhat.png
--------------------------------------------------------------------------------
/doc/images/gremlin-inthewild.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-inthewild.png
--------------------------------------------------------------------------------
/doc/images/gremlin-kilt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-kilt.png
--------------------------------------------------------------------------------
/doc/images/gremlin-lab-coat.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-lab-coat.pdf
--------------------------------------------------------------------------------
/doc/images/gremlin-lab-coat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-lab-coat.png
--------------------------------------------------------------------------------
/doc/images/gremlin-logo.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-logo.graffle
--------------------------------------------------------------------------------
/doc/images/gremlin-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-logo.png
--------------------------------------------------------------------------------
/doc/images/gremlin-logo_inv.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-logo_inv.png
--------------------------------------------------------------------------------
/doc/images/gremlin-new-sheriff-in-town.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-new-sheriff-in-town.png
--------------------------------------------------------------------------------
/doc/images/gremlin-no-more-mr-nice-guy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-no-more-mr-nice-guy.png
--------------------------------------------------------------------------------
/doc/images/gremlin-on-the-case.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-on-the-case.png
--------------------------------------------------------------------------------
/doc/images/gremlin-painting.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-painting.png
--------------------------------------------------------------------------------
/doc/images/gremlin-pipe.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-pipe.png
--------------------------------------------------------------------------------
/doc/images/gremlin-running.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-running.png
--------------------------------------------------------------------------------
/doc/images/gremlin-standing-small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-standing-small.png
--------------------------------------------------------------------------------
/doc/images/gremlin-standing.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-standing.png
--------------------------------------------------------------------------------
/doc/images/gremlin-without-a-cause.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-without-a-cause.pdf
--------------------------------------------------------------------------------
/doc/images/gremlin-without-a-cause.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-without-a-cause.png
--------------------------------------------------------------------------------
/doc/images/gremlin-xmas-alpha.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlin-xmas-alpha.png
--------------------------------------------------------------------------------
/doc/images/gremlindocs-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlindocs-logo.png
--------------------------------------------------------------------------------
/doc/images/gremlindocs.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlindocs.pdf
--------------------------------------------------------------------------------
/doc/images/gremlindocs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/gremlindocs.png
--------------------------------------------------------------------------------
/doc/images/jerry-followed_by-example.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/jerry-followed_by-example.graffle
--------------------------------------------------------------------------------
/doc/images/jerry-followed_by-example.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/jerry-followed_by-example.jpg
--------------------------------------------------------------------------------
/doc/images/jerry-garcia.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/jerry-garcia.jpg
--------------------------------------------------------------------------------
/doc/images/ldsail-arch.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/ldsail-arch.graffle
--------------------------------------------------------------------------------
/doc/images/ldsail-arch.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/ldsail-arch.jpg
--------------------------------------------------------------------------------
/doc/images/lod-cloud.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/lod-cloud.png
--------------------------------------------------------------------------------
/doc/images/rdf-graph-model.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/rdf-graph-model.graffle
--------------------------------------------------------------------------------
/doc/images/rdf-graph-model.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/rdf-graph-model.jpg
--------------------------------------------------------------------------------
/doc/images/rdf-logo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/rdf-logo.gif
--------------------------------------------------------------------------------
/doc/images/sql2gremlin-logo.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/sql2gremlin-logo.pdf
--------------------------------------------------------------------------------
/doc/images/sql2gremlin-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/sql2gremlin-logo.png
--------------------------------------------------------------------------------
/doc/images/structures-processes.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/structures-processes.graffle
--------------------------------------------------------------------------------
/doc/images/structures-processes.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/structures-processes.jpg
--------------------------------------------------------------------------------
/doc/images/tinkerpop-logo-small.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tinkerpop/gremlin/b0eb5575c4ecb241a87805e2dc51d5142510018f/doc/images/tinkerpop-logo-small.jpg
--------------------------------------------------------------------------------
/gremlin-groovy/bin/gremlin.bat:
--------------------------------------------------------------------------------
1 | :: Windows launcher script for Gremlin
2 | @echo off
3 |
4 | cd %CD%\..\target\
5 |
6 | set TARGET=
7 |
8 | for /f "tokens=*" %%a in ('dir /b /ad') do (
9 | if exist "%%a\bin\gremlin.bat" set TARGET=%%a
10 | )
11 |
12 | cd %TARGET%\bin\
13 | call gremlin.bat %*
14 |
--------------------------------------------------------------------------------
/gremlin-groovy/bin/gremlin.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | `dirname $0`/../target/gremlin-*-standalone/bin/gremlin.sh $@
--------------------------------------------------------------------------------
/gremlin-groovy/src/assembly/distribution.xml:
--------------------------------------------------------------------------------
1 |
2 | distribution
3 |
4 | zip
5 |
6 |
7 |
8 | 0775
9 | target/${project.artifactId}-${project.version}-standalone/bin
10 | bin
11 |
12 | *.sh
13 | *.bat
14 |
15 |
16 |
17 | src
18 |
19 |
20 | ../doc
21 |
22 |
26 |
27 | target/${project.artifactId}-${project.version}-standalone/lib
28 | lib
29 |
30 |
31 |
32 |
33 | pom.xml
34 | src
35 |
36 |
37 | ../data/graph-example-1.json
38 | data
39 |
40 |
41 | ../data/graph-example-1.ntriple
42 | data
43 |
44 |
45 | ../data/graph-example-1.xml
46 | data
47 |
48 |
49 | ../data/graph-example-2.xml
50 | data
51 |
52 |
53 | ../LICENSE.txt
54 | /
55 |
56 |
57 | ../CHANGELOG.textile
58 | /
59 |
60 |
61 | src/main/bin/README.txt
62 | /
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/gremlin-groovy/src/assembly/standalone.xml:
--------------------------------------------------------------------------------
1 |
2 | standalone
3 |
4 | dir
5 |
6 | false
7 |
8 |
9 |
10 | src/main/bin
11 | /bin
12 | 0755
13 |
14 |
15 | target/*.jar
16 | /lib
17 |
18 |
19 |
20 |
21 |
22 | /lib
23 | false
24 | compile
25 |
26 |
27 | /lib
28 | false
29 | provided
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/gremlin-groovy/src/main/bin/README.txt:
--------------------------------------------------------------------------------
1 | -= Gremlin: A Graph Traversal Language =-
2 |
3 | Gremlin is a domain specific language for traversing property graphs.
4 | Gremlin makes use of a path-based syntax to support complex graph traversals.
5 | Gremlin has application in the areas of graph query, analysis, and manipulation.
6 |
7 | Gremlin connects to various graph databases including:
8 | * TinkerGraph
9 | * Neo4j
10 | * OrientDB
11 | * DEX
12 | * InfiniteGraph
13 | * Titan
14 | * Rexster
15 | * Sail RDF Stores
16 |
17 | Gremlin documentation can be found online at:
18 | http://gremlin.tinkerpop.com
19 |
20 | --------------- RUNNING GREMLIN ---------------
21 |
22 | gremlin$ bin/gremlin.sh
23 |
24 | \,,,/
25 | (o o)
26 | -----oOOo-(_)-oOOo-----
27 | gremlin> g = TinkerGraphFactory.createTinkerGraph()
28 | ==>tinkergraph[vertices:6 edges:6]
29 | gremlin> g.v(1)
30 | ==>v[1]
31 | gremlin> g.v(1).name
32 | ==>marko
33 | gremlin> g.v(1).out('knows').name
34 | ==>vadas
35 | ==>josh
36 |
37 | NOTE: TinkerGraphFactory.createTinkerGraph() returns a hardcoded toy graph for the purposes of demonstration.
38 |
39 | -----------------------------------------------
40 |
41 | Gremlin is provided by TinkerPop [http://tinkerpop.com]
42 | "Open Source Software Products in the Graph Space"
--------------------------------------------------------------------------------
/gremlin-groovy/src/main/bin/gremlin.bat:
--------------------------------------------------------------------------------
1 | :: Windows launcher script for Gremlin Groovy
2 |
3 | @echo off
4 |
5 | ::cd ..\lib
6 |
7 | ::set LIBDIR=%CD%
8 |
9 | set LIBDIR=..\lib
10 |
11 | set OLD_CLASSPATH=%CLASSPATH%
12 | set CP=
13 |
14 | for %%i in (%LIBDIR%\*.jar) do call :concatsep %%i
15 |
16 | :: cd ..\..\..\
17 |
18 | set JAVA_OPTIONS=-Xms32m -Xmx512m
19 |
20 | :: Launch the application
21 |
22 | if "%1" == "" goto console
23 | if "%1" == "-e" goto script
24 | if "%1" == "-v" goto version
25 |
26 | :console
27 |
28 | set CLASSPATH=%CP%;%OLD_CLASSPATH%
29 | java %JAVA_OPTIONS% %JAVA_ARGS% com.tinkerpop.gremlin.groovy.console.Console %*
30 |
31 | set CLASSPATH=%OLD_CLASSPATH%
32 | goto :eof
33 |
34 | :script
35 |
36 | set strg=
37 |
38 | FOR %%X IN (%*) DO (
39 | CALL :concat %%X %1 %2
40 | )
41 |
42 | set CLASSPATH=%CP%;%OLD_CLASSPATH%
43 | java %JAVA_OPTIONS% %JAVA_ARGS% com.tinkerpop.gremlin.groovy.jsr223.ScriptExecutor %strg%
44 | set CLASSPATH=%OLD_CLASSPATH%
45 | goto :eof
46 |
47 | :version
48 |
49 | set CLASSPATH=%CP%;%OLD_CLASSPATH%
50 | java %JAVA_OPTIONS% %JAVA_ARGS% com.tinkerpop.gremlin.Version
51 |
52 | set CLASSPATH=%OLD_CLASSPATH%
53 | goto :eof
54 |
55 | :concat
56 |
57 | if %1 == %2 goto skip
58 |
59 | SET strg=%strg% %1
60 |
61 | :concatsep
62 |
63 | if "%CP%" == "" (
64 | set CP=%LIBDIR%\%1
65 | )else (
66 | set CP=%CP%;%LIBDIR%\%1
67 | )
68 |
69 | :skip
70 |
--------------------------------------------------------------------------------
/gremlin-groovy/src/main/bin/gremlin.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | case `uname` in
4 | CYGWIN*)
5 | CP=$( echo `dirname $0`/../lib/*.jar . | sed 's/ /;/g')
6 | ;;
7 | *)
8 | CP=$( echo `dirname $0`/../lib/*.jar . | sed 's/ /:/g')
9 | esac
10 | #echo $CP
11 |
12 | # Find Java
13 | if [ "$JAVA_HOME" = "" ] ; then
14 | JAVA="java -server"
15 | else
16 | JAVA="$JAVA_HOME/bin/java -server"
17 | fi
18 |
19 | # Set Java options
20 | if [ "$JAVA_OPTIONS" = "" ] ; then
21 | JAVA_OPTIONS="-Xms32m -Xmx512m"
22 | fi
23 |
24 | # Launch the application
25 | if [ "$1" = "-e" ]; then
26 | k=$2
27 | if [ $# -gt 2 ]; then
28 | for (( i=3 ; i < $# + 1 ; i++ ))
29 | do
30 | eval a=\${${i}}
31 | k="$k \"$a\""
32 | done
33 | fi
34 |
35 | eval $JAVA $JAVA_OPTIONS -cp $CP:$CLASSPATH com.tinkerpop.gremlin.groovy.jsr223.ScriptExecutor $k
36 | else
37 | if [ "$1" = "-v" ]; then
38 | exec $JAVA $JAVA_OPTIONS -cp $CP:$CLASSPATH com.tinkerpop.gremlin.Version
39 | else
40 | exec $JAVA $JAVA_OPTIONS -cp $CP:$CLASSPATH com.tinkerpop.gremlin.groovy.console.Console $@
41 | fi
42 | fi
43 |
--------------------------------------------------------------------------------
/gremlin-groovy/src/main/groovy/com/tinkerpop/gremlin/groovy/loaders/ElementLoader.groovy:
--------------------------------------------------------------------------------
1 | package com.tinkerpop.gremlin.groovy.loaders
2 |
3 | import com.tinkerpop.blueprints.Edge
4 | import com.tinkerpop.blueprints.Element
5 | import com.tinkerpop.blueprints.Vertex
6 | import com.tinkerpop.gremlin.groovy.Gremlin
7 | import com.tinkerpop.gremlin.groovy.GremlinGroovyPipeline
8 |
9 | /**
10 | * @author Marko A. Rodriguez (http://markorodriguez.com)
11 | */
12 | class ElementLoader {
13 |
14 | public static void load() {
15 |
16 | Element.metaClass.propertyMissing = { final String name, final def value ->
17 | ((Element) delegate).setProperty(name, value)
18 | }
19 |
20 | Element.metaClass.methodMissing = { final String name, final def args ->
21 | if (Gremlin.isStep(name)) {
22 | return new GremlinGroovyPipeline(delegate)."$name"(* args)
23 | } else {
24 | throw new MissingMethodException(name, delegate.getClass());
25 | }
26 | }
27 |
28 | Element.metaClass.propertyMissing = { final String name ->
29 | if (Gremlin.isStep(name)) {
30 | return new GremlinGroovyPipeline(delegate)."$name"()
31 | } else {
32 | return ((Element) delegate).getProperty(name)
33 | }
34 | }
35 |
36 | Element.metaClass.map = {
37 | final Map map = new HashMap();
38 | for (final String key : ((Element) delegate).getPropertyKeys()) {
39 | map.put(key, ((Element) delegate).getProperty(key))
40 | }
41 | return map;
42 | }
43 |
44 | Element.metaClass.keys = {
45 | return ((Element) delegate).getPropertyKeys()
46 | }
47 |
48 | Element.metaClass.values = {
49 | final List values = new ArrayList();
50 | for (final String key : ((Element) delegate).getPropertyKeys()) {
51 | values.add(((Element) delegate).getProperty(key))
52 | }
53 | return values;
54 | }
55 |
56 | // for Vertex only
57 |
58 | Vertex.metaClass.addEdge = { final String label, final Vertex inVertex, final Map properties ->
59 | final Edge edge = ((Vertex) delegate).addEdge(label, inVertex);
60 | for (final Map.Entry entry : properties.entrySet()) {
61 | edge.setProperty(entry.getKey(), entry.getValue());
62 | }
63 | return edge;
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/gremlin-groovy/src/main/groovy/com/tinkerpop/gremlin/groovy/loaders/IndexLoader.groovy:
--------------------------------------------------------------------------------
1 | package com.tinkerpop.gremlin.groovy.loaders
2 |
3 | import com.tinkerpop.blueprints.Index
4 | import com.tinkerpop.blueprints.IndexableGraph
5 | import com.tinkerpop.gremlin.groovy.GremlinGroovyPipeline
6 |
7 | /**
8 | * @author Marko A. Rodriguez (http://markorodriguez.com)
9 | */
10 | class IndexLoader {
11 |
12 | public static void load() {
13 |
14 | IndexableGraph.metaClass.idx = { final Object indexName ->
15 | return ((IndexableGraph) delegate).getIndices().find { it.getIndexName().equals(indexName) }
16 | }
17 |
18 | Index.metaClass.getAt = { final Map query ->
19 | final Map.Entry entry = (Map.Entry) query.iterator().next();
20 | return new GremlinGroovyPipeline().start((((Index) delegate).get((String) entry.getKey(), entry.getValue())));
21 | }
22 |
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/gremlin-groovy/src/main/groovy/com/tinkerpop/gremlin/groovy/loaders/ObjectLoader.groovy:
--------------------------------------------------------------------------------
1 | package com.tinkerpop.gremlin.groovy.loaders
2 |
3 | import com.tinkerpop.gremlin.groovy.GremlinGroovyPipeline
4 | import com.tinkerpop.gremlin.groovy.GroovyPipeFunction
5 | import com.tinkerpop.pipes.util.structures.Row
6 | import com.tinkerpop.pipes.util.structures.Table
7 |
8 | /**
9 | * @author Marko A. Rodriguez (http://markorodriguez.com)
10 | */
11 | class ObjectLoader {
12 |
13 | public static void load() {
14 |
15 | Object.metaClass._ = { final Closure closure ->
16 | return new GremlinGroovyPipeline(delegate.iterator());
17 | }
18 |
19 | Map.metaClass.getAt = { final IntRange range ->
20 | final int size = delegate.size();
21 | int high = Math.min(size - 1, range.max());
22 | int low = Math.max(0, range.min());
23 |
24 | final Map tempMap = new LinkedHashMap();
25 | int c = 0;
26 | for (final Map.Entry entry : delegate.entrySet()) {
27 | if (c >= low && c <= high) {
28 | tempMap.put(entry.getKey(), entry.getValue());
29 | }
30 | if (c > high) {
31 | break;
32 | }
33 | c++;
34 |
35 | }
36 | return tempMap;
37 |
38 |
39 | }
40 |
41 | Table.metaClass.apply = { final Closure... closures ->
42 | return ((Table) delegate).apply(GroovyPipeFunction.generate(closures));
43 |
44 | }
45 |
46 | Table.metaClass.unique = { final Closure closure ->
47 | final Table temp = Table.cloneTableStructure((Table) delegate);
48 | for (final Row row : delegate.iterator().unique(closure)) {
49 | temp.addRow(row);
50 | }
51 | return temp;
52 | }
53 |
54 | Table.metaClass.sort = { final Closure closure ->
55 | final Table temp = Table.cloneTableStructure((Table) delegate);
56 | for (final Row row : delegate.iterator().sort(closure)) {
57 | temp.addRow(row);
58 | }
59 | return temp;
60 | }
61 |
62 | List.metaClass.isSimple = {
63 | return new HashSet(((List) delegate)).size() == ((List) delegate).size()
64 | }
65 | }
66 | }
--------------------------------------------------------------------------------
/gremlin-groovy/src/main/groovy/com/tinkerpop/gremlin/groovy/loaders/PipeLoader.groovy:
--------------------------------------------------------------------------------
1 | package com.tinkerpop.gremlin.groovy.loaders
2 |
3 | import com.tinkerpop.gremlin.groovy.Gremlin
4 | import com.tinkerpop.gremlin.groovy.GremlinGroovyPipeline
5 | import com.tinkerpop.pipes.util.PipeHelper
6 |
7 | /**
8 | * @author Marko A. Rodriguez (http://markorodriguez.com)
9 | */
10 | class PipeLoader {
11 |
12 | public static void load() {
13 |
14 | GremlinGroovyPipeline.metaClass.propertyMissing = { final String name ->
15 | if (Gremlin.isStep(name)) {
16 | return delegate."$name"();
17 | } else {
18 | return ((GremlinGroovyPipeline) delegate).property(name);
19 | }
20 | }
21 |
22 | [Iterable, Iterator].each {
23 | it.metaClass.count = {
24 | return PipeHelper.counter(delegate.iterator());
25 | }
26 | }
27 |
28 | [Iterable, Iterator].each {
29 | it.metaClass.mean = {
30 | double counter = 0;
31 | double sum = 0;
32 | delegate.each { counter++; sum += it; }
33 | return sum / counter;
34 | }
35 | }
36 |
37 | GremlinGroovyPipeline.metaClass.getAt = { final Integer index ->
38 | return ((GremlinGroovyPipeline) delegate).range(index, index);
39 | }
40 |
41 |
42 | GremlinGroovyPipeline.metaClass.getAt = { final Range range ->
43 | return ((GremlinGroovyPipeline) delegate).range(range.getFrom() as Integer, range.getTo() as Integer);
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/gremlin-groovy/src/main/groovy/com/tinkerpop/gremlin/groovy/loaders/SailGraphLoader.groovy:
--------------------------------------------------------------------------------
1 | package com.tinkerpop.gremlin.groovy.loaders
2 |
3 | import com.tinkerpop.blueprints.impls.sail.SailGraph
4 |
5 | /**
6 | * @author Marko A. Rodriguez (http://markorodriguez.com)
7 | */
8 | class SailGraphLoader {
9 |
10 | public static void load() {
11 |
12 | SailGraph.metaClass.uri { final String prefix ->
13 | return ((SailGraph) delegate).expandPrefix(prefix)
14 | }
15 |
16 | SailGraph.metaClass.qn { final String uri ->
17 | return ((SailGraph) delegate).prefixNamespace(uri)
18 | }
19 |
20 | SailGraph.metaClass.loadRDF = { final def fileObject, final String format ->
21 | try {
22 | ((SailGraph) delegate).loadRDF(new URL(fileObject).openStream(), "", format, null);
23 | } catch (MalformedURLException e) {
24 | ((SailGraph) delegate).loadRDF(new FileInputStream(fileObject), "", format, null);
25 | }
26 | }
27 |
28 | SailGraph.metaClass.saveRDF = { final def fileObject, final String format ->
29 | if (fileObject instanceof String) {
30 | ((SailGraph) delegate).saveRDF(new FileOutputStream(new File(fileObject)), format);
31 | } else if (fileObject instanceof File) {
32 | ((SailGraph) delegate).saveRDF(new FileOutputStream(fileObject), format);
33 | } else if (fileObject instanceof OutputStream) {
34 | ((SailGraph) delegate).saveRDF(fileObject, format);
35 | }
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/gremlin-groovy/src/main/java/com/tinkerpop/gremlin/groovy/GroovyPipeFunction.java:
--------------------------------------------------------------------------------
1 | package com.tinkerpop.gremlin.groovy;
2 |
3 | import com.tinkerpop.pipes.PipeFunction;
4 | import com.tinkerpop.pipes.util.PipesFunction;
5 | import com.tinkerpop.pipes.util.structures.AsMap;
6 | import groovy.lang.Closure;
7 |
8 | /**
9 | * GroovyPipeFunction wraps a Groovy Closure in a PipeFunction.
10 | * If used within the context of a GremlinGroovyPipeline, the AsMap is the second argument of the function.
11 | *
12 | * @author Marko A. Rodriguez (http://markorodriguez.com)
13 | */
14 | public class GroovyPipeFunction extends PipesFunction {
15 |
16 | private final Closure closure;
17 | private final boolean doAsMap;
18 |
19 | public GroovyPipeFunction(final AsMap asMap, final Closure closure) {
20 | this.closure = closure;
21 | this.setAsMap(asMap);
22 | this.doAsMap = null != this.asMap && this.closure.getParameterTypes().length > 1;
23 | }
24 |
25 | public GroovyPipeFunction(final Closure closure) {
26 | this(null, closure);
27 | }
28 |
29 | public B compute(final A argument) {
30 | return this.doAsMap ? (B) this.closure.call(argument, this.asMap) : (B) this.closure.call(argument);
31 | }
32 |
33 | public static PipeFunction[] generate(final AsMap asMap, final Closure... closures) {
34 | final PipeFunction[] pipeFunctions = new PipeFunction[closures.length];
35 | for (int i = 0; i < closures.length; i++) {
36 | pipeFunctions[i] = new GroovyPipeFunction(asMap, closures[i]);
37 | }
38 | return pipeFunctions;
39 | }
40 |
41 | public static PipeFunction[] generate(final Closure... closures) {
42 | final PipeFunction[] pipeFunctions = new PipeFunction[closures.length];
43 | for (int i = 0; i < closures.length; i++) {
44 | pipeFunctions[i] = new GroovyPipeFunction(null, closures[i]);
45 | }
46 | return pipeFunctions;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/gremlin-groovy/src/main/java/com/tinkerpop/gremlin/groovy/console/ConsoleGroovy.java:
--------------------------------------------------------------------------------
1 | package com.tinkerpop.gremlin.groovy.console;
2 |
3 | import org.codehaus.groovy.tools.shell.Groovysh;
4 |
5 | /**
6 | * Wrapper for the Groovysh class that gets passed to a plugin.
7 | *
8 | * @author Stephen Mallette (http://stephen.genoprime.com)
9 | */
10 | public class ConsoleGroovy {
11 | private final Groovysh groovysh;
12 |
13 | public ConsoleGroovy(final Groovysh groovysh) {
14 | this.groovysh = groovysh;
15 | }
16 |
17 | /**
18 | * Execute some groovy in the REPL. For plugin developers, this is typically use to execute import statements
19 | * for classes that should be available in the REPL so that the user does not need to type the entire
20 | * package name.
21 | */
22 | public Object execute(final String line) {
23 | return this.groovysh.execute(line);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/gremlin-groovy/src/main/java/com/tinkerpop/gremlin/groovy/console/ConsolePlugin.java:
--------------------------------------------------------------------------------
1 | package com.tinkerpop.gremlin.groovy.console;
2 |
3 | import java.util.Map;
4 |
5 | /**
6 | * Those wanting to extend the Gremlin Console can extend this class to provide custom imports and extension
7 | * methods to the language itself. Gremlin Console uses ServiceLoader to install plugins. It is necessary for
8 | * projects wishing to extend the Console to include a com.tinkerpop.gremlin.groovy.console.ConsolePlugin file in
9 | * META-INF/services of their packaged project which includes the full class names of the implementations of this
10 | * interface to install.
11 | *
12 | * @author Stephen Mallette (http://stephen.genoprime.com)
13 | */
14 | public interface ConsolePlugin {
15 |
16 | /**
17 | * The name of the plugin. This name should be unique as naming clashes will prevent proper plugin operations.
18 | */
19 | String getName();
20 |
21 | /**
22 | * Implementors will typically execute imports of classes within their project that they want available in the
23 | * console. They may use groovy meta programming to introduce new extensions to the Gremlin.
24 | *
25 | * @param args Arbitrary arguments passed from the caller of Gremlin.use() to be used as the plugin sees fit.
26 | */
27 | void pluginTo(final ConsoleGroovy groovy, final ConsoleIO io, final Map args);
28 | }
29 |
--------------------------------------------------------------------------------
/gremlin-groovy/src/main/java/com/tinkerpop/gremlin/groovy/console/ErrorHookClosure.java:
--------------------------------------------------------------------------------
1 | package com.tinkerpop.gremlin.groovy.console;
2 |
3 | import groovy.lang.Closure;
4 | import org.codehaus.groovy.tools.shell.IO;
5 |
6 | import java.io.BufferedReader;
7 |
8 | /**
9 | * @author Marko A. Rodriguez (http://markorodriguez.com)
10 | */
11 | public class ErrorHookClosure extends Closure {
12 |
13 | private final IO io;
14 |
15 | public ErrorHookClosure(final Object owner, final IO io) {
16 | super(owner);
17 | this.io = io;
18 | }
19 |
20 | public Object call(final Object[] args) {
21 | if (args.length > 0) {
22 | try {
23 | final Throwable e = (Throwable) args[0];
24 | String message = e.getMessage();
25 | if (null != message) {
26 | message = message.replace("startup failed:", "");
27 | io.err.println(message.trim());
28 | } else {
29 | io.err.println(e);
30 | }
31 |
32 | io.err.print("Display stack trace? [yN] ");
33 | io.err.flush();
34 | String line = new BufferedReader(io.in).readLine();
35 | if (null == line)
36 | line = "";
37 | io.err.print(line.trim());
38 | io.err.println();
39 | if (line.trim().equals("y") || line.trim().equals("Y")) {
40 | e.printStackTrace(io.err);
41 | }
42 |
43 | return null;
44 | } catch (Exception e) {
45 | io.err.println("An undefined error has occurred: " + args[0]);
46 | return null;
47 | }
48 | } else {
49 | io.err.println("An undefined error has occurred");
50 | return null;
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/gremlin-groovy/src/main/java/com/tinkerpop/gremlin/groovy/console/NullResultHookClosure.java:
--------------------------------------------------------------------------------
1 | package com.tinkerpop.gremlin.groovy.console;
2 |
3 | import groovy.lang.Closure;
4 |
5 | /**
6 | * @author Marko A. Rodriguez (http://markorodriguez.com)
7 | */
8 | public class NullResultHookClosure extends Closure {
9 | public NullResultHookClosure(final Object owner) {
10 | super(owner);
11 | }
12 |
13 | public Object call(final Object[] args) {
14 | return null;
15 | }
16 | }
--------------------------------------------------------------------------------
/gremlin-groovy/src/main/java/com/tinkerpop/gremlin/groovy/console/PromptClosure.java:
--------------------------------------------------------------------------------
1 | package com.tinkerpop.gremlin.groovy.console;
2 |
3 | import groovy.lang.Closure;
4 |
5 | /**
6 | * @author Marko A. Rodriguez (http://markorodriguez.com)
7 | */
8 | public class PromptClosure extends Closure {
9 |
10 | private final String inputPrompt;
11 |
12 | public PromptClosure(final Object owner, final String inputPrompt) {
13 | super(owner);
14 | this.inputPrompt = inputPrompt;
15 | }
16 |
17 | public Object call() {
18 | return this.inputPrompt;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/gremlin-groovy/src/main/java/com/tinkerpop/gremlin/groovy/console/ResultHookClosure.java:
--------------------------------------------------------------------------------
1 | package com.tinkerpop.gremlin.groovy.console;
2 |
3 | import com.tinkerpop.pipes.transform.ToStringPipe;
4 | import com.tinkerpop.pipes.util.iterators.SingleIterator;
5 | import groovy.lang.Closure;
6 | import org.codehaus.groovy.tools.shell.IO;
7 |
8 | /**
9 | * @author Marko A. Rodriguez (http://markorodriguez.com)
10 | */
11 | public class ResultHookClosure extends Closure {
12 | private final String resultPrompt;
13 | private final IO io;
14 |
15 | public ResultHookClosure(final Object owner, final IO io, final String resultPrompt) {
16 | super(owner);
17 | this.io = io;
18 | this.resultPrompt = resultPrompt;
19 | }
20 |
21 | public Object call(final Object[] args) {
22 | final Object result = args[0];
23 | ToStringPipe toStringPipe = new ToStringPipe();
24 | toStringPipe.setStarts(new SingleIterator