org.neo4j.kernel.impl.index
Class IndexDefineCommand

java.lang.Object
  extended by org.neo4j.kernel.impl.transaction.xaframework.XaCommand
      extended by org.neo4j.kernel.impl.index.IndexDefineCommand

public class IndexDefineCommand
extends XaCommand

A command which have to be first in the transaction. It will map index names and keys to ids so that all other commands in that transaction only refer to ids instead of names. This reduced the number of bytes needed for commands roughly 50% for transaction with more than a couple of commands in it, depending on the size of the value. After this command has been created it will act as a factory for other commands so that it can spit out correct index name and key ids.


Constructor Summary
IndexDefineCommand()
           
IndexDefineCommand(Map<String,Byte> indexNames, Map<String,Byte> keys)
           
 
Method Summary
 IndexCommand add(String indexName, Class<?> entityType, long entityId, String key, Object value)
           
 IndexCommand addRelationship(String indexName, Class<?> entityType, long entityId, String key, Object value, long startNode, long endNode)
           
 IndexCommand create(String indexName, Class<?> entityType, Map<String,String> config)
           
 IndexCommand delete(String indexName, Class<?> entityType)
           
static Class<? extends PropertyContainer> entityType(byte id)
           
static byte entityTypeId(Class<?> entityType)
           
 boolean equals(Object obj)
           
 void execute()
          Executes the command and makes it persistent.
 String getIndexName(byte id)
           
 String getKey(byte id)
           
 IndexCommand remove(String indexName, Class<?> entityType, long entityId, String key, Object value)
           
 void writeToFile(LogBuffer buffer)
          When a command is added to a transaction (usually when it is created) it must be written to the XaLogicalLog.
 
Methods inherited from class org.neo4j.kernel.impl.transaction.xaframework.XaCommand
isRecovered, rollback, setRecovered
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndexDefineCommand

public IndexDefineCommand()

IndexDefineCommand

public IndexDefineCommand(Map<String,Byte> indexNames,
                          Map<String,Byte> keys)
Method Detail

create

public IndexCommand create(String indexName,
                           Class<?> entityType,
                           Map<String,String> config)

add

public IndexCommand add(String indexName,
                        Class<?> entityType,
                        long entityId,
                        String key,
                        Object value)

addRelationship

public IndexCommand addRelationship(String indexName,
                                    Class<?> entityType,
                                    long entityId,
                                    String key,
                                    Object value,
                                    long startNode,
                                    long endNode)

remove

public IndexCommand remove(String indexName,
                           Class<?> entityType,
                           long entityId,
                           String key,
                           Object value)

delete

public IndexCommand delete(String indexName,
                           Class<?> entityType)

getIndexName

public String getIndexName(byte id)

getKey

public String getKey(byte id)

entityTypeId

public static byte entityTypeId(Class<?> entityType)

entityType

public static Class<? extends PropertyContainer> entityType(byte id)

execute

public void execute()
Description copied from class: XaCommand
Executes the command and makes it persistent. This method must succeed, any protests about this command not being able to execute should be done before execution of any command within the transaction.

Specified by:
execute in class XaCommand

writeToFile

public void writeToFile(LogBuffer buffer)
                 throws IOException
Description copied from class: XaCommand
When a command is added to a transaction (usually when it is created) it must be written to the XaLogicalLog. This method should write all the data that is needed to re-create the command (see XaCommandFactory).

Write the data to the fileChannel, you can use the buffer supplied or create your own buffer since its capacity is very small (137 bytes or something). Acccess to writing commands is synchronized, only one command will be written at a time so if you need to write larger data sets the commands can share the same buffer.

Don't throw an IOException to imply something is wrong with the command. An exception should only be thrown here if there is a real IO failure. If something is wrong with this command it should have been detected when it was created.

Don't force, position or anything except normal forward write with the file channel.

Specified by:
writeToFile in class XaCommand
Parameters:
buffer - A small byte buffer that can be used to write command data
Throws:
IOException - In case of *real* IO failure

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


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