Skip to content

Instantly share code, notes, and snippets.

@martijndwars
Created July 1, 2019 07:06
Show Gist options
  • Save martijndwars/8e67cf902ad48f3b358610da43c7019c to your computer and use it in GitHub Desktop.
Save martijndwars/8e67cf902ad48f3b358610da43c7019c to your computer and use it in GitHub Desktop.
PGX JShell demo

Demo

Start shell

$ ./jshell/pgx.sh

Show predefined variables

pgx> instance
instance ==> ServerInstance[embedded=true,version=19.3.0-SNAPSHOT]
pgx> session
session ==> PgxSession[ID=7fc53571-0ab7-4b10-9e83-1728cc1ab63a,source=pgxShell]
pgx> analyst
analyst ==> NamedArgumentAnalyst[session=7fc53571-0ab7-4b10-9e83-1728cc1ab63a]

Show the println function and semicolon inference

pgx> println("Foo")
Foo
pgx> println("Foo");
Foo
pgx> println("Foo");
Foo

Load a graph

pgx> var g = session.readGraphWithProperties("release/files/data/sample.csv.json")
g ==> PgxGraph[name=sample.vertices,N=4,E=4,created=1561964495892]

Show no getter inference, Javac compiler error

pgx> g.numVertices
|  Error:
|  cannot find symbol
|    symbol:   variable numVertices
|  g.numVertices
|  ^-----------^

Show temporary variables

pgx> g.getNumVertices();
$8 ==> 4
pgx> g.getNumVertices()
$9 ==> 4
pgx> println($9)
4

Show list/map creation

pgx> List.of(1, 2, 3)
$11 ==> [1, 2, 3]
pgx> Map.of("a", "1", "b", "2")
$12 ==> {a=1, b=2}

Show getting edges

pgx> var edges = g.getEdges()
edges ==> EdgeSet[name=edge_collection_set_1,graph=sample.vertices]

Show for loop with var + our println

pgx> for (var e : edges) {
...>   println(e);
...> }
PgxEdge[ID=0]
PgxEdge[ID=1]
PgxEdge[ID=2]
PgxEdge[ID=3]

Too much logs. Show reducing loglevel

pgx> loglevel("ROOT", "INFO")
Log level of ROOT logger set to INFO
pgx> var edges = g.getEdges()
edges ==> EdgeSet[name=edge_collection_set_3,graph=sample.vertices]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment