com.bigdata.sparse
Class AbstractAtomicRowReadOrWrite

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

public abstract class AbstractAtomicRowReadOrWrite
extends AbstractIndexProcedure
implements ISimpleIndexProcedure, IRowStoreConstants, Externalizable

Abstract class implements the atomic read operation. However, it does NOT declare itself to be a read-only operation since this class is extended by both AtomicRowRead and AtomicRowWriteRead.

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

Field Summary
protected static boolean DEBUG
          True iff the log level is DEBUG or less.
protected  INameFilter filter
           
protected  long fromTime
           
protected static boolean INFO
          True iff the log level is INFO or less.
protected static org.apache.log4j.Logger log
           
protected  Object primaryKey
           
protected  Schema schema
           
protected  long toTime
           
 
Fields inherited from interface com.bigdata.sparse.IRowStoreConstants
AUTO_TIMESTAMP, AUTO_TIMESTAMP_UNIQUE, CURRENT_ROW, MAX_TIMESTAMP, MIN_TIMESTAMP
 
Constructor Summary
protected AbstractAtomicRowReadOrWrite()
          De-serialization ctor.
protected AbstractAtomicRowReadOrWrite(Schema schema, Object primaryKey, long fromTime, long toTime, INameFilter filter)
          Constructor for an atomic write/read operation.
 
Method Summary
protected static TPS atomicRead(IIndex ndx, byte[] fromKey, Schema schema, long fromTime, long toTime, INameFilter filter, TPS tps)
          Alternative form useful when you have the raw key (unsigned byte[]) rather than a primary key (application object).
protected static TPS atomicRead(IIndex ndx, Schema schema, Object primaryKey, long fromTime, long toTime, long writeTime, INameFilter filter)
          Atomic read on the index.
protected static ITPV getCurrentValue(IIndex ndx, Schema schema, Object primaryKey, String name)
          Return the current binding for the named property.
 void readExternal(ObjectInput in)
           
 void writeExternal(ObjectOutput out)
           
 
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
 
Methods inherited from interface com.bigdata.btree.proc.IIndexProcedure
apply, isReadOnly
 

Field Detail

log

protected static final org.apache.log4j.Logger log

INFO

protected static final boolean INFO
True iff the log level is INFO or less.


DEBUG

protected static final boolean DEBUG
True iff the log level is DEBUG or less.


schema

protected Schema schema

primaryKey

protected Object primaryKey

fromTime

protected long fromTime

toTime

protected long toTime

filter

protected INameFilter filter
Constructor Detail

AbstractAtomicRowReadOrWrite

protected AbstractAtomicRowReadOrWrite()
De-serialization ctor.


AbstractAtomicRowReadOrWrite

protected AbstractAtomicRowReadOrWrite(Schema schema,
                                       Object primaryKey,
                                       long fromTime,
                                       long toTime,
                                       INameFilter filter)
Constructor for an atomic write/read operation.

Parameters:
schema - The schema governing the property set.
primaryKey - The value of the primary key (identifies the logical row to be read).
fromTime - The first timestamp for which timestamped property values will be accepted.
toTime - 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.
filter - An optional filter used to restrict the property values that will be returned.
Method Detail

atomicRead

protected static TPS atomicRead(IIndex ndx,
                                Schema schema,
                                Object primaryKey,
                                long fromTime,
                                long toTime,
                                long writeTime,
                                INameFilter filter)
Atomic read on the index.

Parameters:
ndx - The index on which the data are stored.
schema - The schema governing the row.
primaryKey - The primary key identifies the logical row of interest.
fromTime - The first timestamp for which timestamped property values will be accepted.
toTime - 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 resolved timestamp for an atomic write operation -or- ZERO (0L) IFF the operation is NOT a write.
filter - An optional filter used to select the values for property names accepted by that filter.
Returns:
The logical row for that primary key -or- null iff there is no data for the primaryKey.

atomicRead

protected static TPS atomicRead(IIndex ndx,
                                byte[] fromKey,
                                Schema schema,
                                long fromTime,
                                long toTime,
                                INameFilter filter,
                                TPS tps)
Alternative form useful when you have the raw key (unsigned byte[]) rather than a primary key (application object).

Parameters:
tps -
fromKey -
ndx -
schema -
fromTime -
toTime -
filter -
tps - The object into which the timestamped property values will be read.
Returns:
The TPS -or- null iff there is no data for the logical row which satisified the various criteria (the schema, fromTime, toTime, and filter).

getCurrentValue

protected static ITPV getCurrentValue(IIndex ndx,
                                      Schema schema,
                                      Object primaryKey,
                                      String name)
Return the current binding for the named property.

Parameters:
schema - The schema.
primaryKey - The primary key.
name - The property name.
Returns:
The current binding -or- null iff there is no current binding.
TODO:
this can be optimized by including the encoded column name in the generated [fromKey] and [toKey] so that we scan less data from the index and by using a reverse traversal iterator to read the most recent value in the key range first. This is especially important if timeseries data are being stored.

readExternal

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

writeExternal

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


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