This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# start GremlinServer | |
# bin/gremlin-server.sh -i org.apache.tinkerpop gremlin-python 3.2.2-SNAPSHOT | |
# bin/gremlin-server.sh conf/gremlin-server-modern-py.yaml | |
from gremlin_python.process.graph_traversal import GraphTraversal | |
from gremlin_python.process.graph_traversal import GraphTraversalSource | |
from gremlin_python.process.graph_traversal import __ | |
from gremlin_python.process.traversal import Operator | |
from gremlin_python.structure.io.graphson import GraphSONReader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static JsonObject toJson(const byte *payload, const uint32_t length) { | |
char *json = (char *)malloc(length); | |
memcpy(json, payload, length); | |
if (json[0] == NULL) { | |
json = json + 2; | |
} | |
json[length - 1] = NULL; | |
StaticJsonDocument<256> doc; | |
DeserializationError error = deserializeJson(doc, json); | |
if (error) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mmlang> 5 => int+2-<(nat;nat+10)=(vertex;vertex)=>edge | |
==>edge:('outV'->vertex:('id'->nat:7),'inV'->vertex:('id'->nat:17)) | |
mmlang> int => int+2-<(nat;nat+10)=(vertex;vertex)=>edge | |
==>edge<=int[plus,2] | |
[split,(nat{?}<=int[is,bool<=int[gt,0]];nat{?}<=int[is,bool<=int[gt,0]][plus,10])] | |
[combine,(vertex;vertex)] | |
[as,edge<=(vertex;vertex) | |
[split,('outV'->vertex<=(vertex;vertex)[get,0,_], | |
'inV'->vertex<=(vertex;vertex)[get,1,_])]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mmlang> int => vertex | |
==>vertex<=int[is,bool<=int[gt,0]] | |
[coerce,vertex{?}<=nat{?}[split,('id'->nat)]] | |
mmlang> int => vertex => -<(_;_) | |
==>(vertex:('id'->nat);vertex:('id'->nat))<=int[is,bool<=int[gt,0]] | |
[coerce,vertex{?}<=nat{?}[split,('id'->nat)]] | |
[split,(vertex:('id'->nat);vertex:('id'->nat))] | |
mmlang> int => vertex => -<(_;_) => edge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mmlang> [1,2,3] // a stream of 3 ints | |
==>1 | |
==>2 | |
==>3 | |
mmlang> [1,2,3][id] // passing the stream through the [id] instruction (ring *) | |
==>1 | |
==>2 | |
==>3 | |
mmlang> [1,2,3][[id],[id]] // passing the stream across two branches with [id] instructions (ring +) | |
==>1{2} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// all cascading coercion is completely determined within the obj graph and thus, realized as instructions. | |
mmlang> :[model,digraph] | |
==>_ | |
mmlang> int | |
==>int | |
mmlang> int => nat | |
==>nat<=int[is,bool<=int[gt,0]] | |
mmlang> int => nat => vertex | |
==>vertex<=int[is,bool<=int[gt,0]][split,('id'->nat)] | |
mmlang> int => nat => vertex -<(_;_) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int => nat[plus,1] => vertex => -<(_;_) => edge | |
nat <=int[is>0][plus,1] | |
vertex <=int[is>0][plus,1][split,('id'->nat)] | |
(vertex;vertex) <=int[is>0][plus,1][split,('id'->nat)][split,(vertex;vertex)] | |
edge <=int[is>0][plus,1][split,('id'->nat)][split,(vertex;vertex)][combine,[split,('outV'->[get,0],'inV'->[get,1])]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mmlang> :[model,pg_2] // load property graph demo model #2 | |
==>_ | |
mmlang> 4 ~~> int // what is the path from 4 to int? simply int. | |
==>((int))<=4[walk,int] | |
mmlang> 4 ~~> str // what is the path from 4 to str? this is none. no ".toString()" | |
==>( ) | |
mmlang> :[model,pg_2][define,str<=int] // lets define ".toString()" | |
==>_[define,str<=int] | |
mmlang> 4 ~~> str // what is the path from 4 to str? int then str | |
==>((int;str))<=4[walk,str] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(int;int) => (nat;nat) | |
..yields: | |
(nat;nat)<=(int;int)[combine,(nat<=int[is,bool<=int[gt,0]];nat<=int[is,bool<=int[gt,0]])] | |
(nat;nat)<=(int;int)[combine,(nat<=int[is,bool<=int[gt,0]];nat<=int[is,bool<=int[gt,0]])] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Given [model,tp3], a graph traversal can be expressed as: | |
vertex[get,outE][is,[get,label][eq,'knows']][get,inV] | |
or w/ corresponding mmlang sugar syntax: | |
vertex.outE[is.label=='knows'].inV | |
or using auto-coercion over the following type definition: |
NewerOlder