com.tinkerpop.blueprints.impls.neo4j
Class Neo4jGraph

java.lang.Object
  extended by com.tinkerpop.blueprints.impls.neo4j.Neo4jGraph
All Implemented Interfaces:
Graph, IndexableGraph, KeyIndexableGraph, MetaGraph<org.neo4j.graphdb.GraphDatabaseService>, TransactionalGraph
Direct Known Subclasses:
Neo4jHaGraph

public class Neo4jGraph
extends Object
implements TransactionalGraph, IndexableGraph, KeyIndexableGraph, MetaGraph<org.neo4j.graphdb.GraphDatabaseService>

A Blueprints implementation of the graph database Neo4j (http://neo4j.org)

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

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.tinkerpop.blueprints.TransactionalGraph
TransactionalGraph.Conclusion
 
Field Summary
protected  ThreadLocal<org.neo4j.graphdb.Transaction> tx
           
 
Constructor Summary
  Neo4jGraph(org.neo4j.graphdb.GraphDatabaseService rawGraph)
           
  Neo4jGraph(org.neo4j.graphdb.GraphDatabaseService rawGraph, boolean fresh)
           
  Neo4jGraph(String directory)
           
  Neo4jGraph(String directory, Map<String,String> configuration)
           
protected Neo4jGraph(String directory, Map<String,String> configuration, boolean highAvailabilityMode)
           
 
Method Summary
 Edge addEdge(Object id, Vertex outVertex, Vertex inVertex, String label)
           
 Vertex addVertex(Object id)
           
protected  void autoStartTransaction()
           
<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)
          

Note that this method will force a successful closing of the current thread's transaction.

<T extends Element>
void
dropKeyIndex(String key, Class<T> elementClass)
           
 Edge getEdge(Object id)
           
 Iterable<Edge> getEdges()
          

The underlying Neo4j graph does not natively support this method within a transaction.

 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()
           
<T extends Element>
Set<String>
getInternalIndexKeys(Class<T> elementClass)
           
 org.neo4j.graphdb.GraphDatabaseService getRawGraph()
           
 Vertex getVertex(Object id)
           
 Iterable<Vertex> getVertices()
          

The underlying Neo4j graph does not natively support this method within a transaction.

 Iterable<Vertex> getVertices(String key, Object value)
           
 void removeEdge(Edge edge)
           
 void removeVertex(Vertex vertex)
           
 void shutdown()
           
 void startTransaction()
           
 void stopTransaction(TransactionalGraph.Conclusion conclusion)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tx

protected final ThreadLocal<org.neo4j.graphdb.Transaction> tx
Constructor Detail

Neo4jGraph

public Neo4jGraph(String directory)

Neo4jGraph

public Neo4jGraph(String directory,
                  Map<String,String> configuration)

Neo4jGraph

public Neo4jGraph(org.neo4j.graphdb.GraphDatabaseService rawGraph)

Neo4jGraph

public Neo4jGraph(org.neo4j.graphdb.GraphDatabaseService rawGraph,
                  boolean fresh)

Neo4jGraph

protected Neo4jGraph(String directory,
                     Map<String,String> configuration,
                     boolean highAvailabilityMode)
Method Detail

getInternalIndexKeys

public <T extends Element> Set<String> getInternalIndexKeys(Class<T> elementClass)

createIndex

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

getIndex

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

dropIndex

public void dropIndex(String indexName)

Note that this method will force a successful closing of the current thread's transaction. As such, once the index is dropped, the operation is committed.

Specified by:
dropIndex in interface IndexableGraph
Parameters:
indexName - the name of the index to drop

getIndices

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

addVertex

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

getVertex

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

getVertices

public Iterable<Vertex> getVertices()

The underlying Neo4j graph does not natively support this method within a transaction. If the graph is not currently in a transaction, then the operation runs efficiently. If the graph is in a transaction, then, for every vertex, a try/catch is used to determine if its in the current transaction.

Specified by:
getVertices in interface Graph
Returns:
all the vertices in the graph

getVertices

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

getEdges

public Iterable<Edge> getEdges()

The underlying Neo4j graph does not natively support this method within a transaction. If the graph is not currently in a transaction, then the operation runs efficiently. If the graph is in a transaction, then, for every edge, a try/catch is used to determine if its in the current transaction.

Specified by:
getEdges in interface Graph
Returns:
all the edges in the graph

getEdges

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

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

removeVertex

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

addEdge

public Edge addEdge(Object id,
                    Vertex outVertex,
                    Vertex inVertex,
                    String label)
Specified by:
addEdge in interface Graph

getEdge

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

removeEdge

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

startTransaction

public void startTransaction()
                      throws IllegalStateException
Specified by:
startTransaction in interface TransactionalGraph
Throws:
IllegalStateException

stopTransaction

public void stopTransaction(TransactionalGraph.Conclusion conclusion)
Specified by:
stopTransaction in interface TransactionalGraph

shutdown

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

autoStartTransaction

protected void autoStartTransaction()

getRawGraph

public org.neo4j.graphdb.GraphDatabaseService getRawGraph()
Specified by:
getRawGraph in interface MetaGraph<org.neo4j.graphdb.GraphDatabaseService>

getFeatures

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

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2010-2012. All Rights Reserved.