Skip to content

Instantly share code, notes, and snippets.

View spmallette's full-sized avatar

stephen mallette spmallette

View GitHub Profile
https://groups.google.com/g/gremlin-users/c/6EXYq2Howdo/m/hST6BW97AgAJ
The reason properties on properties makes sense for vertices and not for
edges is rooted in database design and not logical semantics.
A property on a vertex is a record as is an edge in the database sense.
Hence, we have use cases where we want to know who added a property on a
vertex (as a record).
For edges, the property on the edge is not a record and thinking about it
as such would make the data model really complex (because you could then
get recursively more complex). Hence, all properties of the edge are part
host = "localhost"
requests = 10000
cluster = Cluster.open()
g = traversal().withRemote(DriverRemoteConnection.using(cluster))
println("vertices at start: " + g.V().count().next())
println("edges at start: " + g.E().count().next())
start = System.currentTimeMillis()
(0..<50000).each{
@spmallette
spmallette / gremlin-merge.md
Last active July 12, 2023 13:50
Gremlin merge() API

Gremlin mergeV/E() API

mergeV/E(Map|Traversal search).
  option(Merge.onCreate, Map|Traversal).
  option(Merge.onMatch, Map|Traversal)

Examples

  1. git clone https://github.com/spmallette/rouge
  2. cd rouge
  3. git checkout mm-adt
  4. Build the gem: $ gem build rouge.gemspec
  5. Locally install the gem: $ gem install --local rouge-3.4.1.pre.mmadt.gem
  6. In the terminal where you are running asciidoctor set the ROUGE_VERSION environment variable: $ export ROUGE_VERSION=3.4.1.pre.mmadt
  7. Use mmadt as the "format" as in [source,mmadt] within asciidoc files.
  8. Set the source-highlighter to "rouge".
  9. $ asciidoctor -a source-highlighter=rouge -a rouge-style=thankful_eyes *.adoc -D html/
<?xml version="1.0" encoding="UTF-8"?>
<configuration version="1.0" name="AllocationProfiling" description="Low overhead configuration safe for continuous use in production environments, typically less than 1 % overhead." provider="Oracle">
<producer uri="http://www.oracle.com/hotspot/jvm/" label="Oracle JDK">
<control>
<selection name="gc-level" default="detailed" label="Garbage Collector">
<option label="Off" name="off">off</option>
<option label="Normal" name="detailed">normal</option>
@graben1437
graben1437 / hbase.properties
Last active October 23, 2015 12:30
Data Loader to load sample ratings movie data (movies, users, ratings) into a Titan Graph
# titan 1.0.0
storage.backend=hbase
storage.hostname=<zookeeper server ips here>
#IMPORTANT - must match zookeeper.znode.parent property
# of your hadoop cluster
storage.hbase.ext.zookeeper.znode.parent=/hbase-unsecure
cache.db-cache = true
cache.db-cache-clean-wait = 20
graph = TinkerGraph.open()
graph.createIndex("name", Vertex.class)
g = graph.traversal()
// Query 1
person1 = graph.addVertex(label, 'person', 'name', 'Michael Sherman')
person2 = graph.addVertex(label, 'person', 'name', 'Zoltan Varju')
person3 = graph.addVertex(label, 'person', 'name', 'Peter Neubauer')
person4 = graph.addVertex(label, 'person', 'name', 'Grace Andrews')
person5 = graph.addVertex(label, 'person', 'name', 'Michael Hunger')
---------------------------WARMUP CYCLE---------------------------
[warmup-1] requests: 1000 | time(s): 0.6018506 | req/sec: 1662 | too slow: 0
[warmup-2] requests: 1000 | time(s): 0.291263201 | req/sec: 3433 | too slow: 0
[warmup-3] requests: 1000 | time(s): 0.286894137 | req/sec: 3486 | too slow: 0
[warmup-4] requests: 1000 | time(s): 0.221449842 | req/sec: 4516 | too slow: 0
[warmup-5] requests: 1000 | time(s): 0.238359071 | req/sec: 4195 | too slow: 0
----------------------------TEST CYCLE----------------------------
[test-1] requests: 50000 | time(s): 4.774514652 | req/sec: 10472 | too slow: 0
[test-2] requests: 50000 | time(s): 4.031655607 | req/sec: 12402 | too slow: 0
[test-3] requests: 50000 | time(s): 4.034091315 | req/sec: 12394 | too slow: 0
#!upstart
description "Gremlin Server"
env GREMLIN_USER=ubuntu
env GREMLIN_GROUP=ubuntu
env GREMLIN_PID_FILE=/var/run/gremlin.pid
env GREMLIN_HOME=/usr/local/gremlin-server-3.0.0.M5
env GREMLIN_LOG=/var/log/gremlin/gremlin-server.log
# uncomment the next line if you want Gremlin Server to start automatically after system reboots
@spmallette
spmallette / groovy-script-from-code.groovy
Created September 30, 2014 19:41
Groovy Script From Code
public static String getClosureBody(final Closure closure) {
def node = closure.getMetaClass().getClassNode().getDeclaredMethods("doCall")[0].getCode();
def writer = new StringWriter()
node.visit(new AstNodeToGremlinScriptVisitor(writer))
return writer.toString()
}
class AstNodeToGremlinScriptVisitor extends AstNodeToScriptVisitor {
def AstNodeToGremlinScriptVisitor(Writer writer, boolean showScriptFreeForm = true, boolean showScriptClass = true) {
super(writer, showScriptFreeForm, showScriptClass)