Revision dbae2d6d7a14ff16a108ab3f62e8f7233ed0ab50 authored by Matthias Broecheler on 18 April 2015, 01:58:14 UTC, committed by Matthias Broecheler on 18 April 2015, 01:58:14 UTC
1 parent 82d629f
Raw File
advblueprints.txt
[[advanced-blueprints]]
Advanced Blueprints
-------------------

//image:https://raw.github.com/tinkerpop/blueprints/master/doc/images/blueprints-character-3.png[]

http://blueprints.tinkerpop.com/[Blueprints] provides a set of common property graph interfaces by which any vendor can implement and leverage the http://tinkerpop.com[TinkerPop] stack of technologies. Within Blueprints, there are other utilities that are generally useful like import/export formats as well graph wrappers.

Using IdGraph
~~~~~~~~~~~~~

It is possible to use Blueprints' https://github.com/tinkerpop/blueprints/wiki/Id-Implementation[IdGraph] with Titan. IdGraph requires a property named `__id` that maps arbitrary user-provided identifiers to Titan's internally-assigned long identifiers.  This property name is also available programmatically as the public static string `IdGraph.ID`.

[IMPORTANT]
The `__id` property key must be created and covered by a unique index in Titan prior to using `IdGraph` with Titan.

To prepare Titan for IdGraph, first create the `__id` property key.  Set the `dataType` of the property key to match the custom IDs that you intend to use.  Second, build a unique composite index on the `__id` property key.  The following example shows how to define and index the `__id` property key to support IdGraph with string vertex IDs.

[source,gremlin]
g = TitanFactory.open("berkeleyje:/tmp/test")
// Define a property key and index for IdGraph-managed vertex IDs
mgmt = g.getManagementSystem();
id = mgmt.makePropertyKey(IdGraph.ID).dataType(String.class).make()
mgmt.buildIndex("byvid",Vertex.class).addKey(id).unique().buildCompositeIndex()
mgmt.commit()
// Create an IdGraph that manages vertex IDs but not edge IDs
ig = new IdGraph(g, true, false)
// Insert example vertex with custom identifier
hercules = ig.addVertex("hercules")
g.v("hercules")
zeus = ig.addVertex("zeus")

// If only user defined ids on vertices (or edges) is needed, then use one of the overloaded `IdGraph` constructors.  It is still helpful, although not strictly necessary, to define an index:
//
//[source,gremlin]
//ig = new IdGraph(g, true, false)  // true for vertices, false for edges
back to top