org.neo4j.kernel.impl.index
Class IndexCommand

java.lang.Object
  extended by org.neo4j.kernel.impl.transaction.xaframework.XaCommand
      extended by org.neo4j.kernel.impl.index.IndexCommand
Direct Known Subclasses:
IndexCommand.AddCommand, IndexCommand.AddRelationshipCommand, IndexCommand.CreateCommand, IndexCommand.DeleteCommand, IndexCommand.RemoveCommand

public abstract class IndexCommand
extends XaCommand

Created from IndexDefineCommand or read from a logical log. Contains all the different types of commands that an Index need to support.


Nested Class Summary
static class IndexCommand.AddCommand
           
static class IndexCommand.AddRelationshipCommand
           
static class IndexCommand.CreateCommand
           
static class IndexCommand.DeleteCommand
           
static class IndexCommand.RemoveCommand
           
 
Field Summary
static byte NODE
           
static byte RELATIONSHIP
           
 
Method Summary
protected  byte endNodeNeedsLong()
           
 boolean equals(Object obj)
           
 void execute()
          Executes the command and makes it persistent.
 long getEntityId()
           
 byte getEntityType()
           
 byte getIndexNameId()
           
 byte getKeyId()
           
 Object getValue()
           
 boolean isConsideredNormalWriteCommand()
           
protected static byte needsLong(long value)
           
protected static void putIntOrLong(LogBuffer buffer, long id)
           
static XaCommand readCommand(ReadableByteChannel channel, ByteBuffer buffer)
           
protected  byte startNodeNeedsLong()
           
protected  void writeHeader(LogBuffer buffer)
           
 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
 

Field Detail

NODE

public static final byte NODE
See Also:
Constant Field Values

RELATIONSHIP

public static final byte RELATIONSHIP
See Also:
Constant Field Values
Method Detail

getIndexNameId

public byte getIndexNameId()

getEntityType

public byte getEntityType()

getEntityId

public long getEntityId()

getKeyId

public byte getKeyId()

getValue

public Object getValue()

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

writeHeader

protected void writeHeader(LogBuffer buffer)
                    throws IOException
Throws:
IOException

putIntOrLong

protected static void putIntOrLong(LogBuffer buffer,
                                   long id)
                            throws IOException
Throws:
IOException

needsLong

protected static byte needsLong(long value)

startNodeNeedsLong

protected byte startNodeNeedsLong()

endNodeNeedsLong

protected byte endNodeNeedsLong()

isConsideredNormalWriteCommand

public boolean isConsideredNormalWriteCommand()

readCommand

public static XaCommand readCommand(ReadableByteChannel channel,
                                    ByteBuffer buffer)
                             throws IOException
Throws:
IOException

equals

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


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