Skip to content

Instantly share code, notes, and snippets.

View spmallette's full-sized avatar

stephen mallette spmallette

View GitHub Profile
gremlin> g.addV().property('s',[1,2,3] as Set)
==>v[0]
gremlin> g.addV().property(set,'m',1).property(set,'m',2).property(set,'m',3)
==>v[2]
gremlin> g.V().map(union(id(), properties().count()).fold())
==>[0,1]
==>[2,3]
gremlin> v = g.V(2).next()
==>v[2]
gremlin> g.V().is(v)
==>v[2]
gremlin> g.V().is(new ReferenceVertex(2, 'person'))
==>v[2]
gremlin> g.V(2).fold().is([new ReferenceVertex(2, 'person')])
==>[v[2]]
gremlin> tx = g.tx()
==>org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteTransaction@2a04ab05
gremlin> gtx = tx.begin()
==>graphtraversalsource[emptygraph[empty], standard]
gremlin> gtx.V().count()
==>1
gremlin> gtx.addV('person')
==>v[a8c21f2a-4a1a-6220-e702-ed65df4e290a]
gremlin> // wait 10 minutes
==>true
g.withSack(0).
V().has('airport','code', frm).
repeat(__.outE('route').sack(sum).by('dist').inV().simplePath()).
until(__.has("code",to).or_().loops().is_(maxstops)).
has('code', to).
limit(sample).
order().
by(__.sack()).
local(__.union(__.path().by('code').by('dist'),__.sack()).unfold().fold()).
limit(limit).
@spmallette
spmallette / Client.java
Created October 25, 2022 13:38
remove fast NHA
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
2002-05-30T02:00:00.000-07:00
private static final DateTimeFormatter datetimeFormatter = new DateTimeFormatterBuilder()
.parseCaseInsensitive()
.append(ISO_LOCAL_DATE_TIME)
.optionalStart()
.appendOffset("+HHMMss", "Z")
.optionalEnd()
.optionalStart()
.appendOffset("+HH:MM:ss", "")
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
gremlin> g = TinkerGraph.open().traversal()
==>graphtraversalsource[tinkergraph[vertices:0 edges:0], standard]
gremlin> g.addV().property(id, 'j1')
==>v[j1]
gremlin> g.addV().property(id, 'j2')
==>v[j2]
gremlin> g.addV().property(id, 'j3')
==>v[j3]
gremlin> m = ['j1': 'j2', 'j2': 'j3']
==>j1=j2