com.bigdata.rawstore
Class AbstractRawWormStore

java.lang.Object
  extended by com.bigdata.rawstore.AbstractRawStore
      extended by com.bigdata.rawstore.AbstractRawWormStore
All Implemented Interfaces:
IAddressManager, IRawStore, IStoreSerializer, IWORM
Direct Known Subclasses:
AbstractBufferStrategy, SimpleMemoryRawStore, TemporaryRawStore

public abstract class AbstractRawWormStore
extends AbstractRawStore
implements IWORM

An abstract base class for IRawStore implementations that use an append only (Write Once, Read Many) strategy. The IAddressManager interface is delegated to an WormAddressManager allowing flexible configuration of the use of bits to represent the byte offset of a record in the store and the bits used to represent the size of a record in the store.

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

Field Summary
protected  WormAddressManager am
          The object that knows how to encode, decode, and (de-)serialize addresses.
 
Fields inherited from class com.bigdata.rawstore.AbstractRawStore
serializer
 
Fields inherited from interface com.bigdata.rawstore.IAddressManager
NULL
 
Constructor Summary
AbstractRawWormStore(int offsetBits)
           
 
Method Summary
 WormAddressManager getAddressManager()
          The object that knows how to encode, decode, and (de-)serialize addresses.
 int getByteCount(long addr)
          The length of the datum in bytes.
 long getOffset(long addr)
          The offset on the store at which the datum is stored.
 int getOffsetBits()
          The #of bits out of a 64-bit long integer that are used to encode the byte offset as an unsigned integer.
 void packAddr(DataOutput out, long addr)
          Pack the address onto the output stream.
 long toAddr(int nbytes, long offset)
          Converts a byte count and offset into a long integer.
 String toString(long addr)
          A human readable representation of the address.
 long unpackAddr(DataInput in)
          Unpack the address from the input stream.
 
Methods inherited from class com.bigdata.rawstore.AbstractRawStore
deserialize, deserialize, deserialize, serialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.bigdata.rawstore.IRawStore
close, deleteResources, destroy, force, getCounters, getFile, getResourceMetadata, getUUID, isFullyBuffered, isOpen, isReadOnly, isStable, read, size, write
 

Field Detail

am

protected final WormAddressManager am
The object that knows how to encode, decode, and (de-)serialize addresses.

Constructor Detail

AbstractRawWormStore

public AbstractRawWormStore(int offsetBits)
Parameters:
offsetBits - The #of bits that will be used to represent the byte offset in the 64-bit long integer addresses for the store. See WormAddressManager.
Method Detail

getAddressManager

public final WormAddressManager getAddressManager()
The object that knows how to encode, decode, and (de-)serialize addresses.

Specified by:
getAddressManager in class AbstractRawStore

getOffsetBits

public final int getOffsetBits()
The #of bits out of a 64-bit long integer that are used to encode the byte offset as an unsigned integer. The remaining bits are used to encode the byte count (aka record length) as an unsigned integer.


toAddr

public final long toAddr(int nbytes,
                         long offset)
Description copied from interface: IAddressManager
Converts a byte count and offset into a long integer.

Specified by:
toAddr in interface IAddressManager
Parameters:
nbytes - The byte count.
offset - The byte offset.
Returns:
The long integer.

getOffset

public final long getOffset(long addr)
Description copied from interface: IAddressManager
The offset on the store at which the datum is stored. While this is often the offset of a byte into a file on disk, implementations MAY assign offsets using other strategies.

Specified by:
getOffset in interface IAddressManager
Parameters:
addr - The opaque identifier that is the within store locator for some datum.
Returns:
The offset of that datum.

getByteCount

public final int getByteCount(long addr)
Description copied from interface: IAddressManager
The length of the datum in bytes.

Specified by:
getByteCount in interface IAddressManager
Parameters:
addr - The opaque identifier that is the within store locator for some datum.
Returns:
The offset of that datum.

packAddr

public final void packAddr(DataOutput out,
                           long addr)
                    throws IOException
Description copied from interface: IAddressManager
Pack the address onto the output stream.

Specified by:
packAddr in interface IAddressManager
Parameters:
out - The output stream.
addr - The opaque identifier that is the within store locator for some datum.
Throws:
IOException

unpackAddr

public final long unpackAddr(DataInput in)
                      throws IOException
Description copied from interface: IAddressManager
Unpack the address from the input stream.

Specified by:
unpackAddr in interface IAddressManager
Parameters:
in - The input stream.
Returns:
The opaque identifier that is the within store locator for some datum.
Throws:
IOException

toString

public final String toString(long addr)
Description copied from interface: IAddressManager
A human readable representation of the address.

Specified by:
toString in interface IAddressManager
Parameters:
addr - The opaque identifier that is the within store locator for some datum.
Returns:
A human readable representation.


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