Skip to content

Instantly share code, notes, and snippets.

@robinp
Created June 30, 2017 20:24
Show Gist options
  • Save robinp/b3f6057d7123ca19866b4fb28fbb50d1 to your computer and use it in GitHub Desktop.
Save robinp/b3f6057d7123ca19866b4fb28fbb50d1 to your computer and use it in GitHub Desktop.
Load Kythe data into Cayley
/opt/kythe/tools/triples --graphstore ~/dev/ghc-vagrant/entries/gs > entries.all
cayley init -db leveldb -dbpath cdb
cayley load -db leveldb -dbpath cdb -quads=entries.all -alsologtostderr
@robinp
Copy link
Author

robinp commented Sep 3, 2017

Adapted http://kythe.io/examples/#using-cayley-to-explore-a-graphstore.

$ cat /data/ron/indexing/Spock-0.12.0.0.entries | /opt/kythe/tools/entrystream --unique | /opt/kythe/tools/triples - | gzip > /tmp/triples.nq.gz
2017/09/01 22:36:15 Skipped 0 reverse edges
2017/09/01 22:36:15 Wrote 15871 triples

$ ./cayley http --dbpath /tmp/triples.nq.gz --host 0.0.0.0
Cayley now listening on 0.0.0.0:64210

var tops = g.M()
  .Out("/kythe/edge/childof").Has("/kythe/node/kind", "package")
  // Actually we want !Has(kind, file), but for now we can get away with:
  .In("/kythe/edge/childof").Has("/kythe/node/kind", "variable");

var src = g.V("kythe:?path=Spock-0.12.0.0/src/Web/Spock/Internal/SessionManager.hs");

src
  .Follow(tops).As("target")
  .In("/kythe/edge/ref").Out("/kythe/edge/childof").Has("/kythe/node/kind", "variable")
  .Intersect(src.Follow(tops))
  .As("source")
  .All()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment