org.neo4j.kernel.impl.nioneo.xa
Class WriteTransaction

java.lang.Object
  extended by org.neo4j.kernel.impl.transaction.xaframework.XaTransaction
      extended by org.neo4j.kernel.impl.nioneo.xa.WriteTransaction
All Implemented Interfaces:
NeoStoreTransaction
Direct Known Subclasses:
InterceptingWriteTransaction

public class WriteTransaction
extends XaTransaction
implements NeoStoreTransaction

Transaction containing commands reflecting the operations performed in the transaction.


Method Summary
 void createPropertyIndex(String key, int id)
          Creates a property index entry out of the given id and string.
 void createRelationshipType(int id, String name)
          Creates a new RelationshipType record with the given id that has the given name.
 void destroy()
          Destroy this transaction.
 void doAddCommand(XaCommand command)
          When a command is added to transaction it will be passed via this method.
 void doCommit()
          Commits the transaction, loop through all commands and invoke execute().
protected  void doPrepare()
          Called when transaction is beeing prepared.
 void doRollback()
          Rollbacks the transaction, loop through all commands and invoke rollback().
 RelIdArray getCreatedNodes()
          Returns an array view of the ids of the nodes that have been created in this transaction.
 int getKeyIdForProperty(PropertyData property)
          Returns the index key ids that are contained within the property record with the specified id.
 Pair<Map<RelIdArray.DirectionWrapper,Iterable<RelationshipRecord>>,Long> getMoreRelationships(long nodeId, long position)
           
 long getRelationshipChainPosition(long nodeId)
           
 XAResource getXAResource()
          Returns the XAResource that represents this connection.
protected  void injectCommand(XaCommand xaCommand)
          Used during recovery, calls XaTransaction.doAddCommand(org.neo4j.kernel.impl.transaction.xaframework.XaCommand).
protected  void intercept(List<Command> commands)
           
 boolean isNodeCreated(long nodeId)
          Check if the node with the given id was created in this transaction.
 boolean isReadOnly()
          Returns true if read only transaction, that is no modifications will be made once the transaction commits.
 boolean isRelationshipCreated(long relId)
          Check if the node with the given id was created in this transaction.
 String loadIndex(int id)
          Loads the value object for the given property index record id if the record is light.
 PropertyIndexData[] loadPropertyIndexes(int count)
          Tries to load as heavy records as many property index records as specified in the argument.
 Object loadPropertyValue(PropertyData propertyData)
          Attempts to load the value off the store forthe given PropertyData object.
 RelationshipTypeData[] loadRelationshipTypes()
          Loads and returns all the available RelationshipTypes that are stored.
 PropertyData nodeAddProperty(long nodeId, PropertyIndex index, Object value)
          Adds a property to the given node, with the given index and value.
 PropertyData nodeChangeProperty(long nodeId, PropertyData propertyData, Object value)
          Changes an existing property of the given node, with the given index to the passed value
 void nodeCreate(long nodeId)
          Creates a node for the given id
 ArrayMap<Integer,PropertyData> nodeDelete(long nodeId)
          Deletes a node by its id, returning its properties which are now removed.
 boolean nodeLoadLight(long nodeId)
          Tries to load the light node with the given id, returns true on success.
 ArrayMap<Integer,PropertyData> nodeLoadProperties(long nodeId, boolean light)
          Loads the complete property chain for the given node and returns it as a map from property index id to property data.
 void nodeRemoveProperty(long nodeId, PropertyData propertyData)
          Removes the given property identified by indexKeyId of the node with the given id.
 Object propertyGetValueOrNull(PropertyBlock block)
           
 PropertyData relAddProperty(long relId, PropertyIndex index, Object value)
          Adds a property to the given relationship, with the given index and value.
 void relationshipCreate(long id, int type, long firstNodeId, long secondNodeId)
          Creates a relationship with the given id, from the nodes identified by id and of type typeId
 PropertyData relChangeProperty(long relId, PropertyData propertyData, Object value)
          Changes an existing property's value of the given relationship, with the given index to the passed value
 ArrayMap<Integer,PropertyData> relDelete(long id)
          Deletes a relationship by its id, returning its properties which are now removed.
 RelationshipRecord relLoadLight(long id)
          Tries to load the light relationship with the given id, returns the record on success.
 ArrayMap<Integer,PropertyData> relLoadProperties(long relId, boolean light)
          Loads the complete property chain for the given relationship and returns it as a map from property index id to property data.
 void relRemoveProperty(long relId, PropertyData propertyData)
          Removes the given property identified by its index from the relationship with the given id.
 void setXaConnection(XaConnection connection)
           
 
Methods inherited from class org.neo4j.kernel.impl.transaction.xaframework.XaTransaction
addCommand, commit, getCommitTxId, getIdentifier, isRecovered, prepare, rollback, setCommitTxId, setRecovered
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isReadOnly

public boolean isReadOnly()
Description copied from class: XaTransaction
Returns true if read only transaction, that is no modifications will be made once the transaction commits.

Specified by:
isReadOnly in class XaTransaction
Returns:
true if read only transaction

doAddCommand

public void doAddCommand(XaCommand command)
Description copied from class: XaTransaction
When a command is added to transaction it will be passed via this method. The XaTransaction needs to hold all the commands in memory until it receives the doCommit or doRollback call.

Specified by:
doAddCommand in class XaTransaction
Parameters:
command - The command to be added to transaction

doPrepare

protected void doPrepare()
                  throws XAException
Description copied from class: XaTransaction
Called when transaction is beeing prepared.

Specified by:
doPrepare in class XaTransaction
Throws:
XAException - If unable to prepare

intercept

protected void intercept(List<Command> commands)

injectCommand

protected void injectCommand(XaCommand xaCommand)
Description copied from class: XaTransaction
Used during recovery, calls XaTransaction.doAddCommand(org.neo4j.kernel.impl.transaction.xaframework.XaCommand). Injects the command into the transaction without writing to the logical log.

Overrides:
injectCommand in class XaTransaction
Parameters:
xaCommand - The command that will be injected

doRollback

public void doRollback()
                throws XAException
Description copied from class: XaTransaction
Rollbacks the transaction, loop through all commands and invoke rollback().

Specified by:
doRollback in class XaTransaction
Throws:
XAException - If unable to rollback

doCommit

public void doCommit()
              throws XAException
Description copied from class: XaTransaction
Commits the transaction, loop through all commands and invoke execute().

Specified by:
doCommit in class XaTransaction
Throws:
XAException

nodeLoadLight

public boolean nodeLoadLight(long nodeId)
Description copied from interface: NeoStoreTransaction
Tries to load the light node with the given id, returns true on success.

Specified by:
nodeLoadLight in interface NeoStoreTransaction
Parameters:
nodeId - The id of the node to load.
Returns:
True iff the node record can be found.

relLoadLight

public RelationshipRecord relLoadLight(long id)
Description copied from interface: NeoStoreTransaction
Tries to load the light relationship with the given id, returns the record on success.

Specified by:
relLoadLight in interface NeoStoreTransaction
Parameters:
id - The id of the relationship to load.
Returns:
The light RelationshipRecord if it was found, null otherwise.

nodeDelete

public ArrayMap<Integer,PropertyData> nodeDelete(long nodeId)
Description copied from interface: NeoStoreTransaction
Deletes a node by its id, returning its properties which are now removed.

Specified by:
nodeDelete in interface NeoStoreTransaction
Parameters:
nodeId - The id of the node to delete.
Returns:
The properties of the node that were removed during the delete.

relDelete

public ArrayMap<Integer,PropertyData> relDelete(long id)
Description copied from interface: NeoStoreTransaction
Deletes a relationship by its id, returning its properties which are now removed. It is assumed that the nodes it connects have already been deleted in this transaction.

Specified by:
relDelete in interface NeoStoreTransaction
Parameters:
id - The id of the relationship to delete.
Returns:
The properties of the relationship that were removed during the delete.

getRelationshipChainPosition

public long getRelationshipChainPosition(long nodeId)
Specified by:
getRelationshipChainPosition in interface NeoStoreTransaction

getMoreRelationships

public Pair<Map<RelIdArray.DirectionWrapper,Iterable<RelationshipRecord>>,Long> getMoreRelationships(long nodeId,
                                                                                                     long position)
Specified by:
getMoreRelationships in interface NeoStoreTransaction

relRemoveProperty

public void relRemoveProperty(long relId,
                              PropertyData propertyData)
Description copied from interface: NeoStoreTransaction
Removes the given property identified by its index from the relationship with the given id.

Specified by:
relRemoveProperty in interface NeoStoreTransaction
Parameters:
relId - The id of the relationship that is to have the property removed.
propertyData - The index key of the property.

relLoadProperties

public ArrayMap<Integer,PropertyData> relLoadProperties(long relId,
                                                        boolean light)
Description copied from interface: NeoStoreTransaction
Loads the complete property chain for the given relationship and returns it as a map from property index id to property data.

Specified by:
relLoadProperties in interface NeoStoreTransaction
Parameters:
relId - The id of the relationship whose properties to load.
light - If the properties should be loaded light or not.
Returns:
The properties loaded, as a map from property index id to property data.

nodeLoadProperties

public ArrayMap<Integer,PropertyData> nodeLoadProperties(long nodeId,
                                                         boolean light)
Description copied from interface: NeoStoreTransaction
Loads the complete property chain for the given node and returns it as a map from property index id to property data.

Specified by:
nodeLoadProperties in interface NeoStoreTransaction
Parameters:
nodeId - The id of the node whose properties to load.
light - If the properties should be loaded light or not.
Returns:
The properties loaded, as a map from property index id to property data.

propertyGetValueOrNull

public Object propertyGetValueOrNull(PropertyBlock block)

loadPropertyValue

public Object loadPropertyValue(PropertyData propertyData)
Description copied from interface: NeoStoreTransaction
Attempts to load the value off the store forthe given PropertyData object.

Specified by:
loadPropertyValue in interface NeoStoreTransaction
Parameters:
propertyData - The property to make heavy
Returns:
The property data

nodeRemoveProperty

public void nodeRemoveProperty(long nodeId,
                               PropertyData propertyData)
Description copied from interface: NeoStoreTransaction
Removes the given property identified by indexKeyId of the node with the given id.

Specified by:
nodeRemoveProperty in interface NeoStoreTransaction
Parameters:
nodeId - The id of the node that is to have the property removed.
propertyData - The index key of the property.

relChangeProperty

public PropertyData relChangeProperty(long relId,
                                      PropertyData propertyData,
                                      Object value)
Description copied from interface: NeoStoreTransaction
Changes an existing property's value of the given relationship, with the given index to the passed value

Specified by:
relChangeProperty in interface NeoStoreTransaction
Parameters:
relId - The id of the relationship which holds the property to change.
propertyData - The index of the key of the property to change.
value - The new value of the property.
Returns:
The changed property, as a PropertyData object.

nodeChangeProperty

public PropertyData nodeChangeProperty(long nodeId,
                                       PropertyData propertyData,
                                       Object value)
Description copied from interface: NeoStoreTransaction
Changes an existing property of the given node, with the given index to the passed value

Specified by:
nodeChangeProperty in interface NeoStoreTransaction
Parameters:
nodeId - The id of the node which holds the property to change.
propertyData - The index of the key of the property to change.
value - The new value of the property.
Returns:
The changed property, as a PropertyData object.

relAddProperty

public PropertyData relAddProperty(long relId,
                                   PropertyIndex index,
                                   Object value)
Description copied from interface: NeoStoreTransaction
Adds a property to the given relationship, with the given index and value.

Specified by:
relAddProperty in interface NeoStoreTransaction
Parameters:
relId - The id of the relationship to which to add the property.
index - The index of the key of the property to add.
value - The value of the property.
Returns:
The added property, as a PropertyData object.

nodeAddProperty

public PropertyData nodeAddProperty(long nodeId,
                                    PropertyIndex index,
                                    Object value)
Description copied from interface: NeoStoreTransaction
Adds a property to the given node, with the given index and value.

Specified by:
nodeAddProperty in interface NeoStoreTransaction
Parameters:
nodeId - The id of the node to which to add the property.
index - The index of the key of the property to add.
value - The value of the property.
Returns:
The added property, as a PropertyData object.

relationshipCreate

public void relationshipCreate(long id,
                               int type,
                               long firstNodeId,
                               long secondNodeId)
Description copied from interface: NeoStoreTransaction
Creates a relationship with the given id, from the nodes identified by id and of type typeId

Specified by:
relationshipCreate in interface NeoStoreTransaction
Parameters:
id - The id of the relationship to create.
type - The id of the relationship type this relationship will have.
firstNodeId - The id of the start node.
secondNodeId - The id of the end node.

nodeCreate

public void nodeCreate(long nodeId)
Description copied from interface: NeoStoreTransaction
Creates a node for the given id

Specified by:
nodeCreate in interface NeoStoreTransaction
Parameters:
nodeId - The id of the node to create.

loadIndex

public String loadIndex(int id)
Description copied from interface: NeoStoreTransaction
Loads the value object for the given property index record id if the record is light.

Specified by:
loadIndex in interface NeoStoreTransaction
Parameters:
id - The id of the property index record to make heavy
Returns:
The property index value

loadPropertyIndexes

public PropertyIndexData[] loadPropertyIndexes(int count)
Description copied from interface: NeoStoreTransaction
Tries to load as heavy records as many property index records as specified in the argument.

Specified by:
loadPropertyIndexes in interface NeoStoreTransaction
Parameters:
count - The maximum number of property index records to load.
Returns:
An array of the PropertyIndexData that were loaded - can be less than the number requested.

createPropertyIndex

public void createPropertyIndex(String key,
                                int id)
Description copied from interface: NeoStoreTransaction
Creates a property index entry out of the given id and string.

Specified by:
createPropertyIndex in interface NeoStoreTransaction
Parameters:
key - The key of the property index, as a string.
id - The property index record id.

createRelationshipType

public void createRelationshipType(int id,
                                   String name)
Description copied from interface: NeoStoreTransaction
Creates a new RelationshipType record with the given id that has the given name.

Specified by:
createRelationshipType in interface NeoStoreTransaction
Parameters:
id - The id of the new relationship type record.
name - The name of the relationship type.

getCreatedNodes

public RelIdArray getCreatedNodes()
Description copied from interface: NeoStoreTransaction
Returns an array view of the ids of the nodes that have been created in this transaction.

Specified by:
getCreatedNodes in interface NeoStoreTransaction
Returns:
An array of the ids of the nodes created in this transaction.

isNodeCreated

public boolean isNodeCreated(long nodeId)
Description copied from interface: NeoStoreTransaction
Check if the node with the given id was created in this transaction.

Specified by:
isNodeCreated in interface NeoStoreTransaction
Parameters:
nodeId - The node id to check.
Returns:
True iff a node with the given id was created in this transaction.

isRelationshipCreated

public boolean isRelationshipCreated(long relId)
Description copied from interface: NeoStoreTransaction
Check if the node with the given id was created in this transaction.

Specified by:
isRelationshipCreated in interface NeoStoreTransaction
Returns:
True iff a node with the given id was created in this transaction.

getKeyIdForProperty

public int getKeyIdForProperty(PropertyData property)
Description copied from interface: NeoStoreTransaction
Returns the index key ids that are contained within the property record with the specified id.

Specified by:
getKeyIdForProperty in interface NeoStoreTransaction
Parameters:
property - The PropertyData of the property record.
Returns:
an array that contains all the property index ids of the blocks in the record.

getXAResource

public XAResource getXAResource()
Description copied from interface: NeoStoreTransaction
Returns the XAResource that represents this connection.

Specified by:
getXAResource in interface NeoStoreTransaction
Returns:
the XAResource for this connection

destroy

public void destroy()
Description copied from interface: NeoStoreTransaction
Destroy this transaction. Makes it not known to anyone.

Specified by:
destroy in interface NeoStoreTransaction

setXaConnection

public void setXaConnection(XaConnection connection)
Specified by:
setXaConnection in interface NeoStoreTransaction

loadRelationshipTypes

public RelationshipTypeData[] loadRelationshipTypes()
Description copied from interface: NeoStoreTransaction
Loads and returns all the available RelationshipTypes that are stored.

Specified by:
loadRelationshipTypes in interface NeoStoreTransaction
Returns:
All the stored RelationshipTypes, as a RelationshipTypeData array


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