Local clone of Cayley
Find a file
kortschak c618e556f4 Merge branch 'log_database' into b
Comparison of b against GoLLRB (as at d5f020).

$ benchcmp gollrb.bench b-gen.bench
benchmark                                   old ns/op       new ns/op	delta
BenchmarkNamePredicate                      1631932         1409531	-13.63%
BenchmarkLargeSetsNoIntersection            190792654       63748682	-66.59%
BenchmarkVeryLargeSetsSmallIntersection     896154437       373475843	-58.32%
BenchmarkHelplessContainsChecker            20719182678     14078301640	-32.05%
BenchmarkNetAndSpeed                        32519019        20188665	-37.92%
BenchmarkKeanuAndNet                        18319247        15224988	-16.89%
BenchmarkKeanuAndSpeed                      30849568        18744134	-39.24%
BenchmarkKeanuOther                         105552525       107620648	+1.96%
BenchmarkKeanuBullockOther                  295395338       115193002	-61.00%

benchmark                                   old allocs     new allocs	delta
BenchmarkNamePredicate                      1339           1341	+0.15%
BenchmarkLargeSetsNoIntersection            22585          23632	+4.64%
BenchmarkVeryLargeSetsSmallIntersection     65776          69396	+5.50%
BenchmarkHelplessContainsChecker            1713541        2036316	+18.84%
BenchmarkNetAndSpeed                        17104          17240	+0.80%
BenchmarkKeanuAndNet                        15816          15855	+0.25%
BenchmarkKeanuAndSpeed                      16368          16493	+0.76%
BenchmarkKeanuOther                         30134          30634	+1.66%
BenchmarkKeanuBullockOther                  35510          36454	+2.66%

benchmark                                   old bytes     new bytes	delta
BenchmarkNamePredicate                      96162         96294	+0.14%
BenchmarkLargeSetsNoIntersection            1172356       1249872	+6.61%
BenchmarkVeryLargeSetsSmallIntersection     2810080       2992409	+6.49%
BenchmarkHelplessContainsChecker            89233264      104999088	+17.67%
BenchmarkNetAndSpeed                        1388793       1428110	+2.83%
BenchmarkKeanuAndNet                        1263145       1250079	-1.03%
BenchmarkKeanuAndSpeed                      1246956       1281546	+2.77%
BenchmarkKeanuOther                         2021312       2024727	+0.17%
BenchmarkKeanuBullockOther                  2671448       2742968	+2.68%

Conflicts:
	graph/memstore/triplestore.go
2014-08-15 10:17:52 +09:30
config add config options and graph.Handle 2014-08-10 18:17:38 -04:00
db test clean 2014-08-10 20:10:00 -04:00
docs Rename GremlinTimeout -> Timeout 2014-08-02 23:28:24 +09:30
graph Merge branch 'log_database' into b 2014-08-15 10:17:52 +09:30
http test clean 2014-08-10 20:10:00 -04:00
quad Clean up residual changes 2014-08-05 23:27:13 +09:30
query test clean 2014-08-10 20:10:00 -04:00
static Rename Provenance -> Label 2014-07-29 08:44:39 +09:30
svg Initial Commit 2014-06-20 18:34:31 -04:00
templates Rename Provenance -> Label 2014-07-29 08:44:39 +09:30
writer comments and concretized deltas 2014-08-14 01:24:39 -04:00
.gitignore Use github.com/peterh/liner for REPL lines 2014-08-07 15:02:30 +09:30
.goxc.json Add version numbers and ARM build 2014-07-30 17:47:10 -04:00
.travis.yml up to go 1.3 2014-08-14 02:31:00 -04:00
30kmoviedata.nq.gz Fix missed case in quadfix... and re-run 2014-07-25 23:10:04 +09:30
app.yaml Use build constraints for appengine 2014-07-23 10:02:11 +09:30
appengine.go Use build constraints for appengine 2014-07-23 10:02:11 +09:30
AUTHORS adding to A+C 2014-07-18 11:46:36 -04:00
cayley.cfg.example Initial Commit 2014-06-20 18:34:31 -04:00
cayley.go merge with master 2014-08-13 23:03:07 -04:00
cayley_appengine.cfg Rename GremlinTimeout -> Timeout 2014-08-02 23:28:24 +09:30
cayley_test.go merge with master 2014-08-13 23:03:07 -04:00
CONTRIBUTING.md Initial Commit 2014-06-20 18:34:31 -04:00
CONTRIBUTORS adding to A+C 2014-07-18 11:46:36 -04:00
LICENSE Initial Commit 2014-06-20 18:34:31 -04:00
README.md update readme 2014-08-06 17:18:12 -04:00
testdata.nq Replace nt with nq in various places throughout 2014-07-25 14:56:08 +09:30
TODO.md Rename NextResult -> NextPath 2014-08-01 07:27:16 +09:30

Cayley

Cayley is an open-source graph inspired by the graph database behind [Freebase](http://freebase.com) and Google's [Knowledge Graph](http://www.google.com/insidesearch/features/search/knowledge.html).

Its goal is to be a part of the developer's toolbox where Linked Data and graph-shaped data (semantic webs, social networks, etc) in general are concerned.

Build Status

What's new?

  • 2014-08-06:
    • 0.3.1 Binary Release including:
      • New Quad Parser (more strictly passing the W3C spec and test suite)
      • Automatic decompression of quad files
    • Ruby and a Node.JS client libraries from the community.
    • Benchmarks
    • Large speedups on HEAD (in for the next binary release)

Features

  • Written in Go
  • Easy to get running (3 or 4 commands, below)
  • RESTful API
    • or a REPL if you prefer
  • Built-in query editor and visualizer
  • Multiple query languages:
    • JavaScript, with a Gremlin-inspired* graph object.
    • (simplified) MQL, for Freebase fans
  • Plays well with multiple backend stores:
  • Modular design; easy to extend with new languages and backends
  • Good test coverage
  • Speed, where possible.

Rough performance testing shows that, on consumer hardware and an average disk, 134m triples in LevelDB is no problem and a multi-hop intersection query -- films starring X and Y -- takes ~150ms.

* Note that while it's not exactly Gremlin, it certainly takes inspiration from that API. For this flavor, see the documentation.

Getting Started

Grab the latest release binary and extract it wherever you like.

If you prefer to build from source, see the documentation on the wiki at How to start hacking on Cayley

cd to the directory and give it a quick test with:

./cayley repl --dbpath=testdata.nq

You should see a cayley> REPL prompt. Go ahead and give it a try:

// Simple math
cayley> 2 + 2

// JavaScript syntax
cayley> x = 2 * 8
cayley> x

// See all the entities in this small follow graph.
cayley> graph.Vertex().All()

// See only dani.
cayley> graph.Vertex("dani").All()

// See who dani follows.
cayley> graph.Vertex("dani").Out("follows").All()

Sample Data

For somewhat more interesting data, a sample of 30k movies from Freebase comes in the checkout.

./cayley repl --dbpath=30kmoviedata.nq.gz

To run the web frontend, replace the "repl" command with "http"

./cayley http --dbpath=30kmoviedata.nq.gz

And visit port 64210 on your machine, commonly http://localhost:64210

Running queries

The default environment is based on Gremlin and is simply a JavaScript environment. If you can write jQuery, you can query a graph.

You'll notice we have a special object, graph or g, which is how you can interact with the graph.

The simplest query is merely to return a single vertex. Using the 30kmoviedata.nq dataset from above, let's walk through some simple queries:

// Query all vertices in the graph, limit to the first 5 vertices found.
graph.Vertex().GetLimit(5)

// Start with only one vertex, the literal name "Humphrey Bogart", and retrieve all of them.
graph.Vertex("Humphrey Bogart").All()

// `g` and `V` are synonyms for `graph` and `Vertex` respectively, as they are quite common.
g.V("Humphrey Bogart").All()

// "Humphrey Bogart" is a name, but not an entity. Let's find the entities with this name in our dataset.
// Follow links that are pointing In to our "Humphrey Bogart" node with the predicate "name".
g.V("Humphrey Bogart").In("name").All()

// Notice that "name" is a generic predicate in our dataset.
// Starting with a movie gives a similar effect.
g.V("Casablanca").In("name").All()

// Relatedly, we can ask the reverse; all ids with the name "Casablanca"
g.V().Has("name", "Casablanca").All()

You may start to notice a pattern here: with Gremlin, the query lines tend to:

Start somewhere in the graph | Follow a path | Run the query with "All" or "GetLimit"

g.V("Casablanca") | .In("name") | .All()

And these pipelines continue...

// Let's get the list of actors in the film
g.V().Has("name","Casablanca")
  .Out("/film/film/starring").Out("/film/performance/actor")
  .Out("name").All()

// But this is starting to get long. Let's use a morphism -- a pre-defined path stored in a variable -- as our linkage

var filmToActor = g.Morphism().Out("/film/film/starring").Out("/film/performance/actor")

g.V().Has("name", "Casablanca").Follow(filmToActor).Out("name").All()

There's more in the JavaScript API Documentation, but that should give you a feel for how to walk around the graph.

Disclaimer

Not a Google project, but created and maintained by a Googler, with permission from and assignment to Google, under the Apache License, version 2.0.

Contact