Skip to content

Instantly share code, notes, and snippets.

@teeler
Created October 31, 2018 18:13
Show Gist options
  • Save teeler/f4083225a63141286426df52d1bba2c0 to your computer and use it in GitHub Desktop.
Save teeler/f4083225a63141286426df52d1bba2c0 to your computer and use it in GitHub Desktop.
graphd testingg
Graphd testing
First build it:
{•̃_•̃} bazel build graphd
Then, run it:
{•̃_•̃} bazel-bin/graphd/graphd -d /tmp/some-tmp-db -y
graphd> write (name="human" value="chris"
(<- name="left leg" value="green")
(<- name="right leg" value="blue"))
write (name="human" value="ann"
(<- name="left leg" value="green")
(<- name="right leg" value="blue")
(<- name="left arm" value="yellow")
(<- name="right arm" value="red"))
write (name="human" value="bob"
(<- name="left leg" value="green")
(<- name="right leg" value="blue")
(<- name="left arm" value="black"))
ok (00000000400045488000000000000000 (00000000400045488000000000000001) (00000000400045488000000000000002))
ok (00000000400045488000000000000003 (00000000400045488000000000000004) (00000000400045488000000000000005) (00000000400045488000000000000006) (00000000400045488000000000000007))
ok (00000000400045488000000000000008 (00000000400045488000000000000009) (0000000040004548800000000000000a) (0000000040004548800000000000000b))
(ctrl-D to quit)
OK, now you have some data. Btw, “write(…)” is a command, lines starting with “ok (…)” are results, so only paste the write lines. Also, I mentioned that graphd is line-oriented, thats partially true - it’s also
Query oriented - this means it will wait for the closing paren.
OK, so now you have a database with data, lets run one that you can connect to with your Go code - sort of like before:
{•̃_•̃} bazel-bin/graphd/graphd -d /tmp/some-tmp-db -l /tmp/graphd.logs -p /tmp/graphd.pid
nc[rtp-macbookpro2:~/github/graphd]
{•̃_•̃} nc localhost 8100
read()
ok ((00000000400045488000000000000000 null "human" string "chris" null true true 2018-10-31T18:05:23.0000Z) (-> 00000000400045488000000000000001 null "left leg" string "green" null true true 2018-10-31T18:05:23.0001Z 00000000400045488000000000000000 null) (-> 00000000400045488000000000000002 null "right leg" string "blue" null true true 2018-10-31T18:05:23.0002Z 00000000400045488000000000000000 null) (00000000400045488000000000000003 null "human" string "ann" null true true 2018-10-31T18:05:23.0003Z) (-> 00000000400045488000000000000004 null "left leg" string "green" null true true 2018-10-31T18:05:23.0004Z 00000000400045488000000000000003 null) (-> 00000000400045488000000000000005 null "right leg" string "blue" null true true 2018-10-31T18:05:23.0005Z 00000000400045488000000000000003 null) (-> 00000000400045488000000000000006 null "left arm" string "yellow" null true true 2018-10-31T18:05:23.0006Z 00000000400045488000000000000003 null) (-> 00000000400045488000000000000007 null "right arm" string "red" null true true 2018-10-31T18:05:23.0007Z 00000000400045488000000000000003 null) (00000000400045488000000000000008 null "human" string "bob" null true true 2018-10-31T18:05:23.0008Z) (-> 00000000400045488000000000000009 null "left leg" string "green" null true true 2018-10-31T18:05:23.0009Z 00000000400045488000000000000008 null) (-> 0000000040004548800000000000000a null "right leg" string "blue" null true true 2018-10-31T18:05:23.0010Z 00000000400045488000000000000008 null) (-> 0000000040004548800000000000000b null "left arm" string "black" null true true 2018-10-31T18:05:23.0011Z 00000000400045488000000000000008 null))
(ctrl-D again)
OK, so now you’ve got some data to play with.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment