ostore.update
Class UpdateTuple

java.lang.Object
  |
  +--ostore.update.UpdateTuple
All Implemented Interfaces:
QuickSerializable

public class UpdateTuple
extends Object
implements QuickSerializable

The UpdateTuple, or tuple for short, is a container for a Predicate and an Action. If the Predicate of the tuple evaluates to true, all of the Actions in the tuple will be executed. Tuples are stored in an ordered list in an Update.

Version:
$Id: UpdateTuple.java,v 1.34 2004/05/13 20:17:22 hweather Exp $
Author:
Patrick R. Eaton

Constructor Summary
UpdateTuple()
           
UpdateTuple(InputBuffer buffer)
           
UpdateTuple(Predicate predicate, Action action)
          Create an UpdateTuple with the specified Predicate and Action.
 
Method Summary
 void appendAction(Action action)
          Adds an action to the end of the list of actions for this tuple.
 boolean evaluate(UpdateRequest update_request, UpdateContinuation continuation, DataCache cache)
          Evaluate the predicate of this tuple.
 UpdateResult execute(UpdateRequest update_request, UpdateContinuation continuation, DataCache cache)
          Perform the actions in this tuple.
 Action getActionAt(int index)
          Returns the action at the given index in this tuple.
 Vector getActions()
          Returns the actions in this tuple.
 Predicate getPredicate()
          Return the predicate of this tuple.
 Set getTargets()
          Returns a set containing all of the potential targets of this tuple.
 void insertAction(Action action, int index)
          Adds an action to this tuple at the specified location in the list of tuples.
 void prependAction(Action action)
          Adds an action to the beginning of the list of actions for this tuple.
 void serialize(OutputBuffer buffer)
          Add the object to the buffer.
 void setPredicate(Predicate predicate)
          Sets the predicate of this tuple.
 String toString()
          Return the String representation of the tuple.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UpdateTuple

public UpdateTuple()

UpdateTuple

public UpdateTuple(Predicate predicate,
                   Action action)
Create an UpdateTuple with the specified Predicate and Action.

Parameters:
predicate - the predicate of the tuple
action - the action of the tuple

UpdateTuple

public UpdateTuple(InputBuffer buffer)
            throws QSException
Method Detail

serialize

public void serialize(OutputBuffer buffer)
Description copied from interface: QuickSerializable
Add the object to the buffer.

Specified by:
serialize in interface QuickSerializable
Parameters:
buffer - the output buffer to add the object to

setPredicate

public void setPredicate(Predicate predicate)
Sets the predicate of this tuple.

Parameters:
predicate - the predicate of this tuple

getPredicate

public Predicate getPredicate()
Return the predicate of this tuple.

Returns:
the predicate of this tuple

appendAction

public void appendAction(Action action)
Adds an action to the end of the list of actions for this tuple.

Parameters:
action - the action to add to this tuple

prependAction

public void prependAction(Action action)
Adds an action to the beginning of the list of actions for this tuple. All other actions are shifted one spot in the list.

Parameters:
action - the action to add to this tuple

insertAction

public void insertAction(Action action,
                         int index)
Adds an action to this tuple at the specified location in the list of tuples. All tuples after the insertion index are shifted one spot in the list.

Parameters:
action - the action to add to this tuple
index - the index at which to insert the action

getActions

public Vector getActions()
Returns the actions in this tuple.

Returns:
a vector of actions for this tuple

getActionAt

public Action getActionAt(int index)
Returns the action at the given index in this tuple.

Parameters:
index - the index of the action to return
Returns:
the action at the given index, or null if such action exists

getTargets

public Set getTargets()
Returns a set containing all of the potential targets of this tuple. A potential target is an data object that may be referenced or modified.

Returns:
a set of all of the potential targets of this tuple

evaluate

public boolean evaluate(UpdateRequest update_request,
                        UpdateContinuation continuation,
                        DataCache cache)
                 throws ostore.update.UpdateException
Evaluate the predicate of this tuple.

Parameters:
update_request - the update request currently being serviced
continuation - the state of update so that it may be restarted
Returns:
true iff the predicate evaluates to true; false otherwise
Throws:
ostore.update.UpdateException - if the evaluation of the predicate is interrupted

execute

public UpdateResult execute(UpdateRequest update_request,
                            UpdateContinuation continuation,
                            DataCache cache)
                     throws ostore.update.UpdateException
Perform the actions in this tuple.

Parameters:
update_request - the update request currently being serviced
continuation - an object representing the state of an update needed for restartability
Returns:
a map from Aguid to Vhash for all modified data objects
Throws:
ostore.update.UpdateException - if the execution of the actions is interrupted

toString

public String toString()
Return the String representation of the tuple.

Overrides:
toString in class Object
Returns:
the String representation of the tuple