com.bigdata.sparse
Class AtomicRowWriteRead

java.lang.Object
  extended by com.bigdata.btree.proc.AbstractIndexProcedure
      extended by com.bigdata.sparse.AbstractAtomicRowReadOrWrite
          extended by com.bigdata.sparse.AtomicRowWriteRead
All Implemented Interfaces:
IIndexProcedure, ISimpleIndexProcedure, IRowStoreConstants, Externalizable, Serializable

public class AtomicRowWriteRead
extends AbstractAtomicRowReadOrWrite

Atomic write on a logical row. All property values written will have the same timestamp. An atomic read is performed as part of the procedure so that the caller may obtain a consistent view of the post-update state of the logical row. The server-assigned timestamp written may be obtained from the returned ITPS object.

Version:
$Id: AtomicRowWriteRead.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.bigdata.sparse.AbstractAtomicRowReadOrWrite
DEBUG, filter, fromTime, INFO, log, primaryKey, schema, toTime
 
Fields inherited from interface com.bigdata.sparse.IRowStoreConstants
AUTO_TIMESTAMP, AUTO_TIMESTAMP_UNIQUE, CURRENT_ROW, MAX_TIMESTAMP, MIN_TIMESTAMP
 
Constructor Summary
AtomicRowWriteRead()
          De-serialization ctor.
AtomicRowWriteRead(Schema schema, Map<String,Object> propertySet, long fromTime, long toTime, long writeTime, INameFilter filter, IPrecondition precondition)
          Constructor for an atomic write/read operation.
 
Method Summary
 TPS apply(IIndex ndx)
          If a property set was specified then do an atomic write of the property set.
protected  void atomicWrite(IIndex ndx, Schema schema, Object primaryKey, Map<String,Object> propertySet, long writeTime)
           
protected  long inc(IIndex ndx, Schema schema, Object primaryKey, long timestamp, String col)
          Return the increment of the named property value.
 boolean isReadOnly()
          Return true iff the procedure asserts that it will not write on the index.
 void readExternal(ObjectInput in)
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class com.bigdata.sparse.AbstractAtomicRowReadOrWrite
atomicRead, atomicRead, getCurrentValue
 
Methods inherited from class com.bigdata.btree.proc.AbstractIndexProcedure
getKeyBuilder
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AtomicRowWriteRead

public AtomicRowWriteRead()
De-serialization ctor.


AtomicRowWriteRead

public AtomicRowWriteRead(Schema schema,
                          Map<String,Object> propertySet,
                          long fromTime,
                          long toTime,
                          long writeTime,
                          INameFilter filter,
                          IPrecondition precondition)
Constructor for an atomic write/read operation.

Parameters:
schema - The schema governing the property set.
propertySet - The property set. An entry bound to a null value will cause the corresponding binding to be "deleted" in the index.
fromTime - During pre-condition and post-condition reads, the first timestamp for which timestamped property values will be accepted.
toTime - During pre-condition and post-condition reads, the first timestamp for which timestamped property values will NOT be accepted -or- IRowStoreConstants.CURRENT_ROW to accept only the most current binding whose timestamp is GTE fromTime.
writeTime - The timestamp to be assigned to the property values by an atomic write -or- IRowStoreConstants.AUTO_TIMESTAMP if the timestamp will be assigned by the server -or- IRowStoreConstants.AUTO_TIMESTAMP_UNIQUE if a unique timestamp will be assigned by the server.
filter - An optional filter used to restrict the property values that will be returned.
precondition -
Method Detail

isReadOnly

public final boolean isReadOnly()
Description copied from interface: IIndexProcedure
Return true iff the procedure asserts that it will not write on the index. When true, the procedure may be run against a view of the index that is read-only or which allows concurrent processes to read on the same index object. When false the procedure will be run against a mutable view of the index (assuming that the procedure is executed in a context that has access to a mutable index view).


apply

public TPS apply(IIndex ndx)
If a property set was specified then do an atomic write of the property set. Regardless, an atomic read of the property set is then performed and the results of that atomic read are returned to the caller.

Parameters:
ndx - The index.
Returns:
The set of tuples for the primary key as a TPS instance -or- null iff there is no data for the primaryKey.

atomicWrite

protected void atomicWrite(IIndex ndx,
                           Schema schema,
                           Object primaryKey,
                           Map<String,Object> propertySet,
                           long writeTime)

inc

protected long inc(IIndex ndx,
                   Schema schema,
                   Object primaryKey,
                   long timestamp,
                   String col)
Return the increment of the named property value. Note that auto-increment is only defined for ValueType.Integer and ValueType.Long.

Throws:
UnsupportedOperationException - if a property has an auto-increment type and the ValueType of the property does not support auto-increment.
UnsupportedOperationException - if there is no successor for the property value.

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Overrides:
readExternal in class AbstractAtomicRowReadOrWrite
Throws:
IOException
ClassNotFoundException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Overrides:
writeExternal in class AbstractAtomicRowReadOrWrite
Throws:
IOException


Copyright © 2006-2009 SYSTAP, LLC. All Rights Reserved.