de.zib.scalaris.operations
Class WriteOp

java.lang.Object
  extended by de.zib.scalaris.operations.WriteOp
All Implemented Interfaces:
Operation, TransactionOperation, TransactionSingleOpOperation

public class WriteOp
extends Object
implements TransactionOperation, TransactionSingleOpOperation

An operation writing a value.

Since:
3.14
Version:
3.14
Author:
Nico Kruber, kruber@zib.de

Constructor Summary
WriteOp(OtpErlangString key, OtpErlangObject value)
          Constructor
WriteOp(String key, T value)
          Constructor
 
Method Summary
 OtpErlangObject getErlang(boolean compressed)
          Gets the erlang representation of the operation.
 OtpErlangString getKey()
          Gets the key the operation is working on (if available)
 OtpErlangObject getResult()
          Gets the (raw Erlang) result set via Operation.setResult(OtpErlangObject, boolean).
 boolean getResultCompressed()
          Determines if the result set via Operation.setResult(OtpErlangObject, boolean) is compressed or not.
 Object processResult()
          Processes the result set by Operation.setResult(OtpErlangObject, boolean).
 Object processResultSingle()
          Processes the result set by Operation.setResult(OtpErlangObject, boolean) assuming that operation was committed.
 void setResult(OtpErlangObject resultRaw, boolean compressed)
          Sets the raw erlang result value.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WriteOp

public WriteOp(OtpErlangString key,
               OtpErlangObject value)
Constructor

Parameters:
key - the key to write the value to
value - the value to write

WriteOp

public WriteOp(String key,
               T value)
Constructor

Parameters:
key - the key to write the value to
value - the value to write
Method Detail

getErlang

public OtpErlangObject getErlang(boolean compressed)
Description copied from interface: Operation
Gets the erlang representation of the operation.

Specified by:
getErlang in interface Operation
Parameters:
compressed - whether the value part in the term should be encoded, i.e. compressed into an Erlang binary, or not
Returns:
erlang representation for api_tx:req_list

getKey

public OtpErlangString getKey()
Description copied from interface: Operation
Gets the key the operation is working on (if available)

Specified by:
getKey in interface Operation
Returns:
the key or null

setResult

public void setResult(OtpErlangObject resultRaw,
                      boolean compressed)
Description copied from interface: Operation
Sets the raw erlang result value. It can be processed using Operation.processResult().

Specified by:
setResult in interface Operation
Parameters:
resultRaw - the result
compressed - whether the value inside the result is compressed or not

getResult

public OtpErlangObject getResult()
Description copied from interface: Operation
Gets the (raw Erlang) result set via Operation.setResult(OtpErlangObject, boolean).

Specified by:
getResult in interface Operation
Returns:
the result object or null if not set

getResultCompressed

public boolean getResultCompressed()
Description copied from interface: Operation
Determines if the result set via Operation.setResult(OtpErlangObject, boolean) is compressed or not.

Specified by:
getResultCompressed in interface Operation
Returns:
true if compressed, false otherwise, undefined if no result was set

processResult

public Object processResult()
                     throws UnknownException
Description copied from interface: Operation
Processes the result set by Operation.setResult(OtpErlangObject, boolean). Note: the created value is not cached!

Specified by:
processResult in interface Operation
Returns:
a (potentially) read value (may be null)
Throws:
UnknownException - if any other error occurs

processResultSingle

public Object processResultSingle()
                           throws AbortException,
                                  UnknownException
Description copied from interface: TransactionSingleOpOperation
Processes the result set by Operation.setResult(OtpErlangObject, boolean) assuming that operation was committed. In contrast to Operation.processResult() operations like WriteOp will throw a proper AbortException for their commit part instead of an UnknownException. Note: the created value is not cached!

Specified by:
processResultSingle in interface TransactionSingleOpOperation
Returns:
a (potentially) read value (may be null)
Throws:
AbortException - if a commit failed
UnknownException - if any other error occurs

toString

public String toString()
Overrides:
toString in class Object