com.tinkerpop.blueprints.impls.neo4jbatch
Class Neo4jBatchGraph

java.lang.Object
  extended by com.tinkerpop.blueprints.impls.neo4jbatch.Neo4jBatchGraph
All Implemented Interfaces:
Graph, IndexableGraph, KeyIndexableGraph, MetaGraph<org.neo4j.unsafe.batchinsert.BatchInserter>

public class Neo4jBatchGraph
extends Object
implements KeyIndexableGraph, IndexableGraph, MetaGraph<org.neo4j.unsafe.batchinsert.BatchInserter>

A Blueprints implementation of the Neo4j batch inserter for bulk loading data into a Neo4j graph. This is a single threaded, non-transactional bulk loader and should not be used for any other reason than for massive initial data loads.

Neo4jBatchGraph is not a completely faithful Blueprints implementation. Many methods throw UnsupportedOperationExceptions and take unique arguments. Be sure to review each method's JavaDoc. The Neo4j "reference node" (vertex 0) is automatically created and is not removed until the database is shutdown() (do not add edges to the reference node). Key indices are not available until after the graph has been shutdown.

Author:
Marko A. Rodriguez (http://markorodriguez.com)

Field Summary
protected  Set<String> edgeIndexKeys
           
protected  Set<String> vertexIndexKeys
           
 
Constructor Summary
Neo4jBatchGraph(org.neo4j.unsafe.batchinsert.BatchInserter rawGraph, org.neo4j.unsafe.batchinsert.BatchInserterIndexProvider indexProvider)
           
Neo4jBatchGraph(String directory)
           
Neo4jBatchGraph(String directory, Map<String,String> parameters)
           
 
Method Summary
 Edge addEdge(Object id, Vertex outVertex, Vertex inVertex, String label)
          

The object id must be a Map<String,Object> or null.

 Vertex addVertex(Object id)
          

The object id can either be null, a long id, or a Map<String,Object>.

<T extends Element>
Index<T>
createIndex(String indexName, Class<T> indexClass, Parameter... indexParameters)
           
<T extends Element>
void
createKeyIndex(String key, Class<T> elementClass)
           
 void dropIndex(String indexName)
           
<T extends Element>
void
dropKeyIndex(String key, Class<T> elementClass)
           
 void flushIndices()
          This is necessary prior to using indices to ensure that indexed data is available to index queries.
 Edge getEdge(Object id)
           
 Iterable<Edge> getEdges()
           
 Iterable<Edge> getEdges(String key, Object value)
           
 Features getFeatures()
           
<T extends Element>
Index<T>
getIndex(String indexName, Class<T> indexClass)
           
<T extends Element>
Set<String>
getIndexedKeys(Class<T> elementClass)
           
 Iterable<Index<? extends Element>> getIndices()
           
 org.neo4j.unsafe.batchinsert.BatchInserter getRawGraph()
           
 Vertex getVertex(Object id)
           
 Iterable<Vertex> getVertices()
           
 Iterable<Vertex> getVertices(String key, Object value)
           
 void removeEdge(Edge edge)
           
 void removeVertex(Vertex vertex)
           
 void shutdown()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

vertexIndexKeys

protected final Set<String> vertexIndexKeys

edgeIndexKeys

protected final Set<String> edgeIndexKeys
Constructor Detail

Neo4jBatchGraph

public Neo4jBatchGraph(String directory)

Neo4jBatchGraph

public Neo4jBatchGraph(String directory,
                       Map<String,String> parameters)

Neo4jBatchGraph

public Neo4jBatchGraph(org.neo4j.unsafe.batchinsert.BatchInserter rawGraph,
                       org.neo4j.unsafe.batchinsert.BatchInserterIndexProvider indexProvider)
Method Detail

shutdown

public void shutdown()
Specified by:
shutdown in interface Graph

flushIndices

public void flushIndices()
This is necessary prior to using indices to ensure that indexed data is available to index queries. This method is not part of the Blueprints Graph or IndexableGraph API. Therefore, be sure to typecast your graph to a Neo4jBatchGraph to use this necessary index-based method. Note that key indices are not usable until the Neo4jBatchGraph has been shutdown.


toString

public String toString()
Overrides:
toString in class Object

getRawGraph

public org.neo4j.unsafe.batchinsert.BatchInserter getRawGraph()
Specified by:
getRawGraph in interface MetaGraph<org.neo4j.unsafe.batchinsert.BatchInserter>

addVertex

public Vertex addVertex(Object id)

The object id can either be null, a long id, or a Map<String,Object>. If null, then an internal long is provided on the construction of the vertex. If a long id is provided, then the vertex is constructed with that long id. If a map is provided, then the map serves as the properties of the vertex. Moreover, if the map contains an _id key, then the value is a user provided long vertex id.

Specified by:
addVertex in interface Graph
Parameters:
id - a id of properties which can be null
Returns:
the newly created vertex

getVertex

public Vertex getVertex(Object id)
Specified by:
getVertex in interface Graph

getVertices

public Iterable<Vertex> getVertices()
                             throws UnsupportedOperationException
Specified by:
getVertices in interface Graph
Throws:
UnsupportedOperationException

getVertices

public Iterable<Vertex> getVertices(String key,
                                    Object value)
                             throws UnsupportedOperationException
Specified by:
getVertices in interface Graph
Throws:
UnsupportedOperationException

removeVertex

public void removeVertex(Vertex vertex)
                  throws UnsupportedOperationException
Specified by:
removeVertex in interface Graph
Throws:
UnsupportedOperationException

addEdge

public Edge addEdge(Object id,
                    Vertex outVertex,
                    Vertex inVertex,
                    String label)

The object id must be a Map<String,Object> or null. The id is the properties written when the vertex is created. While it is possible to Edge.setProperty(), this method is faster.

Specified by:
addEdge in interface Graph
Parameters:
id - a id of properties which can be null
Returns:
the newly created vertex

getEdge

public Edge getEdge(Object id)
             throws UnsupportedOperationException
Specified by:
getEdge in interface Graph
Throws:
UnsupportedOperationException

getEdges

public Iterable<Edge> getEdges()
                        throws UnsupportedOperationException
Specified by:
getEdges in interface Graph
Throws:
UnsupportedOperationException

getEdges

public Iterable<Edge> getEdges(String key,
                               Object value)
                        throws UnsupportedOperationException
Specified by:
getEdges in interface Graph
Throws:
UnsupportedOperationException

removeEdge

public void removeEdge(Edge edge)
                throws UnsupportedOperationException
Specified by:
removeEdge in interface Graph
Throws:
UnsupportedOperationException

getIndex

public <T extends Element> Index<T> getIndex(String indexName,
                                             Class<T> indexClass)
Specified by:
getIndex in interface IndexableGraph

createIndex

public <T extends Element> Index<T> createIndex(String indexName,
                                                Class<T> indexClass,
                                                Parameter... indexParameters)
Specified by:
createIndex in interface IndexableGraph

getIndices

public Iterable<Index<? extends Element>> getIndices()
Specified by:
getIndices in interface IndexableGraph

dropIndex

public void dropIndex(String indexName)
               throws UnsupportedOperationException
Specified by:
dropIndex in interface IndexableGraph
Throws:
UnsupportedOperationException

dropKeyIndex

public <T extends Element> void dropKeyIndex(String key,
                                             Class<T> elementClass)
Specified by:
dropKeyIndex in interface KeyIndexableGraph

createKeyIndex

public <T extends Element> void createKeyIndex(String key,
                                               Class<T> elementClass)
Specified by:
createKeyIndex in interface KeyIndexableGraph

getIndexedKeys

public <T extends Element> Set<String> getIndexedKeys(Class<T> elementClass)
Specified by:
getIndexedKeys in interface KeyIndexableGraph

getFeatures

public Features getFeatures()
Specified by:
getFeatures in interface Graph


Copyright © 2010-2012. All Rights Reserved.