de.zib.scalaris.operations
Class ReadRandomFromListOp

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

public class ReadRandomFromListOp
extends PartialReadOp

Operation reading a random entry from a (non-empty) list value.

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

Nested Class Summary
static class ReadRandomFromListOp.Result
          Result type of random_from_list operations.
 
Constructor Summary
ReadRandomFromListOp(OtpErlangString key)
          Constructor
ReadRandomFromListOp(String key)
          Constructor
 
Method Summary
 OtpErlangObject getErlang(boolean compressed)
          Gets the erlang representation of the operation.
 ReadRandomFromListOp.Result processResult()
          Processes the result set by Operation.setResult(OtpErlangObject, boolean).
 ReadRandomFromListOp.Result processResultSingle()
          Processes the result set by Operation.setResult(OtpErlangObject, boolean) assuming that operation was committed.
 String toString()
           
 
Methods inherited from class de.zib.scalaris.operations.PartialReadOp
getKey, getResult, getResultCompressed, setResult
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReadRandomFromListOp

public ReadRandomFromListOp(OtpErlangString key)
Constructor

Parameters:
key - the key to read

ReadRandomFromListOp

public ReadRandomFromListOp(String key)
Constructor

Parameters:
key - the key to read
Method Detail

getErlang

public OtpErlangObject getErlang(boolean compressed)
Description copied from interface: Operation
Gets the erlang representation of the 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

processResult

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

Returns:
a (potentially) read value (may be null)
Throws:
NotFoundException - if the requested key does not exist
EmptyListException - if the stored value is an empty list but the op requires a non-empty list
NotAListException - if the previously stored value was no list
UnknownException - if any other error occurs

processResultSingle

public ReadRandomFromListOp.Result processResultSingle()
                                                throws NotFoundException,
                                                       EmptyListException,
                                                       NotAListException,
                                                       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!

Returns:
a (potentially) read value (may be null)
Throws:
NotFoundException - if the requested key does not exist
EmptyListException - if the stored value is an empty list but the op requires a non-empty list
NotAListException - if the previously stored value was no list
UnknownException - if any other error occurs

toString

public String toString()
Overrides:
toString in class Object