Fork me on GitHub

Kategorie: GraphQL

Today we added a plug-in to the 2.1 ver­sion of the com­mu­nity edi­tion of GraphDB which is called “FastIm­port”. It’s basi­cally a bulk import plug-in which takes a pro­pri­etary XML for­mat as input and imports ver­tices and edges into a run­ning GraphDB instance.

In order to use this new plug-in and import fea­ture you need to know that an import basi­cally splits into a two-stage process:

  1. scheme setup
  2. fast-import

So first you’ll have to define which ver­tex and edge types get imported by the fol­low­ing step 2 – you nor­mally do this using the GraphQL and spec­i­fy­ing sev­eral ver­tex types. For demon­stra­tion pur­poses we take a small social net­work with only one ver­tex type:

CREATE VERTEX TYPE User ATTRIBUTES (String Name, Int64 Age, Set<User> Friends)

After hav­ing set-up the scheme the only thing left is to actu­ally call the import plug-in using another short GraphQL query:

IMPORT FROM ‘file:\\100k_import.xml’ FORMAT FastImport

This will, for exam­ple, take the 100.000 user dataset and import it into the cur­rent GraphDB instance. Of course we did that already for you so here are the com­par­i­son results between a GraphQL and FastIm­port and the per­sis­tent and In-Memory ver­sion of GraphDB:

in-Memory_import

persistent_import

 

Of course you can also down­load the data-sets used in this small bench­mark here:

10.000 Users / 592.374 edges : GraphQL Import , FastIm­port

100.000 Users / 5.944.332 edges : GraphQL Import, FastIm­port

With ver­sion 2.0 of sones GraphDB we intro­duced an enhanced graph model we call Prop­erty Hyper­graph.


In this Prop­erty Hyper­graph model there are some stan­dard edge types:

  • single-edge: an edge between two vertices
  • multi-edge: an edge split­ting up into single-edges of the same edge type point­ing towards the same ver­tex type.
  • hyper-edge: an edge to a sub­graph made up by all pos­si­ble types of vertices

In order to cre­ate dif­fer­ent ver­tex types since ver­sion 1.0 of sones GraphDB the GraphQL com­mand “CREATE VERTEX TYPE” is avail­able to users. In ver­sion 2.0 we intro­duced edge types but those were only use­able if you would use the API to inter­act with the GraphDB instance.

In ver­sion 2.1 we’ve now added a full edge type man­age­ment to be used either through GraphDBs new edge-type API and of course through the new GraphQL exten­sions which add edge-type handling.

So for exam­ple let’s say you want to cre­ate an edge type “User” and insert a bunch of those. And you want those users to be con­nected by a spe­cific edge type which comes with it’s own attrib­utes – some­thing like this:

The GraphQL Queries to cre­ate the above scheme would be these:

CREATE EDGE TYPE User­Link ATTRIBUTES (Dou­ble weight, String pri­or­ity, LIST<String> tags) COMMENT = ‘This is my edge type named User­Link.’
CREATE VERTEX TYPE User ATTRIBUTES (String name, SET<User(UserLink)> friends)
INSERT INTO User VALUES (name = ‘UserA’)
INSERT INTO User VALUES (name = ‘UserB’, friends = SETOF(name = ‘UserA’ : (weight = 15.5, pri­or­ity = ‘high’, tags = LISTOF(‘best friend’, ‘mate’))))

As you can see it’s easy to actu­ally cre­ate edge types and add attrib­utes to the rela­tion­ships these edges rep­re­sent. It even gets bet­ter: you can also use the inher­i­tance mech­a­nisms you are already used to on ver­tex types as well as unde­fined (scheme­less) attributes.

If you want to dive deeper into edge types you won’t have to wait until the release of GraphDB 2.1 at the end of this year. You can just grab the cur­rent source code on github and get started.

Addi­tional doc­u­men­ta­tion and exam­ples are avail­able in our doc­u­men­ta­tion wiki. Here are some places you will find more information:

Not long ago we showed off the new capa­bil­i­ties of GraphDB 2.1 (to be released at the end of 2011) regard­ing the visu­al­iza­tion of data. Now we extended that capa­bil­i­ties and added another Out­put Plug-In to the Com­mu­nity Edi­tion. It’s called GraphVis.

And you can down­load it now with our source-code pack­age from our GitHub repos­i­tory.

The best way to show-off the new func­tion­al­ity is by lit­er­ally show­ing it:

A good start for the doc­u­men­ta­tion of the new visu­al­iza­tion options is our ever grow­ing wiki.

There is a new exam­ple avail­able for all the devel­op­ers out there who want to start using GraphDB.

This tuto­r­ial describes and shows the sim­plic­ity of set­ting up a GraphDB by using the sones GraphDB Com­mu­ni­tyEdi­tion. It shows  how to cre­ate your own data­base by using the sones GraphDB C# API and how to use GraphDB to cre­ate your own graph scheme (in not one but two dif­fer­ent approaches).

  1. by using GraphDB API Requests
  2. by using GraphQL queries

Beside the tuto­r­ial itself there is source code avail­able here.

If you are using the GraphQL please read our GraphQL Cheat­sheet there you can find the descrip­tion of all avail­able state­ments and some addi­tional examples.

The tuto­r­ial itself will show you how to:

  1. cre­ate user defined types, add struc­tured prop­er­ties, add unknown/schemeless properties
  2. cre­ate out­go­ing and incom­ing edges on a ver­tex type
  3. cre­ate an index on a spec­i­fied prop­erty in 3 dif­fer­ent ways
  4. set con­straints on prop­er­ties (like “unique” and “mandatory”)
  5. set up queries and ana­lyze them
  6. use func­tion and aggre­gates in a query

Source 1: C# TagEx­am­ple Tuto­r­ial
Source 2: C# TagEx­am­ple Source Code

As of now you can down­load a Quick Ref­er­ence doc­u­ment – or Cheat­sheet as we call it – from this web­site. It’s a com­piled and shorted version.

cheatsheet

Down­load here.