org.neo4j.unsafe.batchinsert
Class BatchInserterImpl

java.lang.Object
  extended by org.neo4j.unsafe.batchinsert.BatchInserterImpl
All Implemented Interfaces:
BatchInserter

public class BatchInserterImpl
extends Object
implements BatchInserter


Method Summary
 IndexCreator createDeferredSchemaIndex(Label label)
          Returns an IndexCreator where details about the index to create can be specified.
 void createIndexRule(Label label, String propertyKey)
           
 void createNode(long id, Map<String,Object> properties, Label... labels)
          Creates a node with supplied id and properties.
 long createNode(Map<String,Object> properties, Label... labels)
          Creates a node assigning next available id to id and also adds any properties supplied.
 long createRelationship(long node1, long node2, RelationshipType type, Map<String,Object> properties)
          Creates a relationship between two nodes of a specific type.
 GraphDatabaseService getBatchGraphDbService()
          Deprecated. as of Neo4j 1.7
 IdGeneratorFactory getIdGeneratorFactory()
           
 org.neo4j.kernel.impl.index.IndexStore getIndexStore()
           
 Iterable<Label> getNodeLabels(long node)
           
 Map<String,Object> getNodeProperties(long nodeId)
          Returns a map containing all the properties of this node.
 long getReferenceNode()
          Returns the reference node id or -1 if it doesn't exist.
 BatchRelationship getRelationshipById(long relId)
          Gets a relationship by id.
 Iterable<Long> getRelationshipIds(long nodeId)
          Returns an iterable over all the relationship ids connected to node with supplied id.
 Map<String,Object> getRelationshipProperties(long relId)
          Returns a map containing all the properties of the relationships.
 Iterable<BatchRelationship> getRelationships(long nodeId)
          Returns an iterable of relationships connected to the node with supplied id.
 String getStoreDir()
          Returns the path to this Neo4j store.
 boolean nodeExists(long nodeId)
          Checks if a node with the given id exists.
 boolean nodeHasLabel(long node, Label label)
           
 boolean nodeHasProperty(long node, String propertyName)
          Returns true iff the node with id node has a property with name propertyName.
 boolean relationshipHasProperty(long relationship, String propertyName)
          Returns true iff the relationship with id relationship has a property with name propertyName.
 void removeNodeProperty(long node, String propertyName)
          Removes the property named property from the node with id id, if present.
 void removeRelationshipProperty(long relationship, String propertyName)
          Removes the property named property from the relationship with id id, if present.
 void setNodeLabels(long node, Label... labels)
          Replaces any existing labels for the given node with the supplied list of labels.
 void setNodeProperties(long node, Map<String,Object> properties)
          Sets the properties of a node.
 void setNodeProperty(long node, String propertyName, Object newValue)
          Sets the property with name propertyName of node with id node to the value propertyValue.
 void setRelationshipProperties(long rel, Map<String,Object> properties)
          Sets the properties of a relationship.
 void setRelationshipProperty(long relationship, String propertyName, Object propertyValue)
          Sets the property with name propertyName of relationship with id relationship to the value propertyValue.
 void shutdown()
          Shuts down this batch inserter syncing all changes that are still only in memory to disk.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

nodeHasProperty

public boolean nodeHasProperty(long node,
                               String propertyName)
Description copied from interface: BatchInserter
Returns true iff the node with id node has a property with name propertyName.

Specified by:
nodeHasProperty in interface BatchInserter
Parameters:
node - The node id of the node to check.
propertyName - The property name to check for
Returns:
True if the node has the named property - false otherwise.

relationshipHasProperty

public boolean relationshipHasProperty(long relationship,
                                       String propertyName)
Description copied from interface: BatchInserter
Returns true iff the relationship with id relationship has a property with name propertyName.

Specified by:
relationshipHasProperty in interface BatchInserter
Parameters:
relationship - The relationship id of the relationship to check.
propertyName - The property name to check for
Returns:
True if the relationship has the named property - false otherwise.

setNodeProperty

public void setNodeProperty(long node,
                            String propertyName,
                            Object newValue)
Description copied from interface: BatchInserter
Sets the property with name propertyName of node with id node to the value propertyValue. If the property exists it is updated, otherwise created.

Specified by:
setNodeProperty in interface BatchInserter
Parameters:
node - The node id of the node whose property is to be set
propertyName - The name of the property to set
newValue - The value of the property to set

setRelationshipProperty

public void setRelationshipProperty(long relationship,
                                    String propertyName,
                                    Object propertyValue)
Description copied from interface: BatchInserter
Sets the property with name propertyName of relationship with id relationship to the value propertyValue. If the property exists it is updated, otherwise created.

Specified by:
setRelationshipProperty in interface BatchInserter
Parameters:
relationship - The node id of the relationship whose property is to be set
propertyName - The name of the property to set
propertyValue - The value of the property to set

removeNodeProperty

public void removeNodeProperty(long node,
                               String propertyName)
Description copied from interface: BatchInserter
Removes the property named property from the node with id id, if present.

Specified by:
removeNodeProperty in interface BatchInserter
Parameters:
node - The id of the node from which to remove the property
propertyName - The name of the property

removeRelationshipProperty

public void removeRelationshipProperty(long relationship,
                                       String propertyName)
Description copied from interface: BatchInserter
Removes the property named property from the relationship with id id, if present.

Specified by:
removeRelationshipProperty in interface BatchInserter
Parameters:
relationship - The id of the relationship from which to remove the property
propertyName - The name of the property

createDeferredSchemaIndex

public IndexCreator createDeferredSchemaIndex(Label label)
Description copied from interface: BatchInserter
Returns an IndexCreator where details about the index to create can be specified. When all details have been entered create must be called for it to actually be created. Creating an index enables indexing for nodes with the specified label. The index will have the details supplied to the returned index creator. Indexes created with the method are deferred until the batch inserter is shut down, at which point a background job will populate all indexes.

Specified by:
createDeferredSchemaIndex in interface BatchInserter
Parameters:
label - label on nodes to be indexed
Returns:
an IndexCreator capable of providing details for, as well as creating an index for the given label.

createIndexRule

public void createIndexRule(Label label,
                            String propertyKey)

createNode

public long createNode(Map<String,Object> properties,
                       Label... labels)
Description copied from interface: BatchInserter
Creates a node assigning next available id to id and also adds any properties supplied.

Specified by:
createNode in interface BatchInserter
Parameters:
properties - a map containing properties or null if no properties should be added.
labels - a list of labels to initially create the node with.
Returns:
The id of the created node.

createNode

public void createNode(long id,
                       Map<String,Object> properties,
                       Label... labels)
Description copied from interface: BatchInserter
Creates a node with supplied id and properties. If a node with the given id exist a runtime exception will be thrown.

Specified by:
createNode in interface BatchInserter
Parameters:
id - the id of the node to create.
properties - map containing properties or null if no properties should be added.
labels - a list of labels to initially create the node with.

setNodeLabels

public void setNodeLabels(long node,
                          Label... labels)
Description copied from interface: BatchInserter
Replaces any existing labels for the given node with the supplied list of labels.

Specified by:
setNodeLabels in interface BatchInserter
Parameters:
node - the node to set labels for.
labels - the labels to set for the node.

getNodeLabels

public Iterable<Label> getNodeLabels(long node)
Specified by:
getNodeLabels in interface BatchInserter
Parameters:
node - the node to get labels for.
Returns:
all labels for the given node.

nodeHasLabel

public boolean nodeHasLabel(long node,
                            Label label)
Specified by:
nodeHasLabel in interface BatchInserter
Parameters:
node - the node to check.
label - the label to check.
Returns:
true if a node has a given label, otherwise false.

createRelationship

public long createRelationship(long node1,
                               long node2,
                               RelationshipType type,
                               Map<String,Object> properties)
Description copied from interface: BatchInserter
Creates a relationship between two nodes of a specific type.

Specified by:
createRelationship in interface BatchInserter
Parameters:
node1 - the start node.
node2 - the end node.
type - relationship type.
properties - map containing properties or null if no properties should be added.
Returns:
the id of the created relationship.

setNodeProperties

public void setNodeProperties(long node,
                              Map<String,Object> properties)
Description copied from interface: BatchInserter
Sets the properties of a node. This method will remove any properties already existing and replace it with properties in the supplied map.

For best performance try supply all the nodes properties upon creation of the node. This method will delete any existing properties so using it together with BatchInserter.getNodeProperties(long) will have bad performance.

Specified by:
setNodeProperties in interface BatchInserter
Parameters:
node - the id of the node.
properties - map containing the properties or null to clear all properties.

setRelationshipProperties

public void setRelationshipProperties(long rel,
                                      Map<String,Object> properties)
Description copied from interface: BatchInserter
Sets the properties of a relationship. This method will remove any properties already existing and replace it with properties in the supplied map.

For best performance try supply all the relationship properties upon creation of the relationship. This method will delete any existing properties so using it together with BatchInserter.getRelationshipProperties(long) will have bad performance.

Specified by:
setRelationshipProperties in interface BatchInserter
Parameters:
rel - the id of the relationship.
properties - map containing the properties or null to clear all properties.

nodeExists

public boolean nodeExists(long nodeId)
Description copied from interface: BatchInserter
Checks if a node with the given id exists.

Specified by:
nodeExists in interface BatchInserter
Parameters:
nodeId - the id of the node.
Returns:
true if the node exists.

getNodeProperties

public Map<String,Object> getNodeProperties(long nodeId)
Description copied from interface: BatchInserter
Returns a map containing all the properties of this node.

Specified by:
getNodeProperties in interface BatchInserter
Parameters:
nodeId - the id of the node.
Returns:
map containing this node's properties.

getRelationshipIds

public Iterable<Long> getRelationshipIds(long nodeId)
Description copied from interface: BatchInserter
Returns an iterable over all the relationship ids connected to node with supplied id.

Specified by:
getRelationshipIds in interface BatchInserter
Parameters:
nodeId - the id of the node.
Returns:
iterable over the relationship ids connected to the node.

getRelationships

public Iterable<BatchRelationship> getRelationships(long nodeId)
Description copied from interface: BatchInserter
Returns an iterable of relationships connected to the node with supplied id.

Specified by:
getRelationships in interface BatchInserter
Parameters:
nodeId - the id of the node.
Returns:
iterable over the relationships connected to the node.

getRelationshipById

public BatchRelationship getRelationshipById(long relId)
Description copied from interface: BatchInserter
Gets a relationship by id.

Specified by:
getRelationshipById in interface BatchInserter
Parameters:
relId - the relationship id.
Returns:
a simple relationship wrapper for the relationship.

getRelationshipProperties

public Map<String,Object> getRelationshipProperties(long relId)
Description copied from interface: BatchInserter
Returns a map containing all the properties of the relationships.

Specified by:
getRelationshipProperties in interface BatchInserter
Parameters:
relId - the id of the relationship.
Returns:
map containing the relationship's properties.

shutdown

public void shutdown()
Description copied from interface: BatchInserter
Shuts down this batch inserter syncing all changes that are still only in memory to disk. Failing to invoke this method may leave the Neo4j store in a inconsistent state. Note that this method will trigger population of all schema indexes, both those created in the batch insertion session, as well as those that existed previously. This may take a long time, depending on data size.

After this method has been invoked any other method call to this batch inserter is illegal.

Specified by:
shutdown in interface BatchInserter

toString

public String toString()
Overrides:
toString in class Object

getStoreDir

public String getStoreDir()
Description copied from interface: BatchInserter
Returns the path to this Neo4j store.

Specified by:
getStoreDir in interface BatchInserter
Returns:
the path to this Neo4j store.

getReferenceNode

public long getReferenceNode()
Description copied from interface: BatchInserter
Returns the reference node id or -1 if it doesn't exist.

Specified by:
getReferenceNode in interface BatchInserter
Returns:
the reference node

getBatchGraphDbService

@Deprecated
public GraphDatabaseService getBatchGraphDbService()
Deprecated. as of Neo4j 1.7


getIndexStore

public org.neo4j.kernel.impl.index.IndexStore getIndexStore()

getIdGeneratorFactory

public IdGeneratorFactory getIdGeneratorFactory()


Copyright © 2002-2013 The Neo4j Graph Database Project. All Rights Reserved.