com.bigdata.btree
Class IndexSegmentAddressManager

java.lang.Object
  extended by com.bigdata.rawstore.WormAddressManager
      extended by com.bigdata.btree.IndexSegmentAddressManager
All Implemented Interfaces:
IAddressManager

public class IndexSegmentAddressManager
extends WormAddressManager

Address manager supporting offsets that are encoded for one of several regions in an IndexSegmentStore. The regions are identified by a IndexSegmentRegion, which gets encoded into the offset component of the address. The offsets are relative to the start of the identified regions. The IndexSegmentCheckpoint record gives the start of each region.

Together with IndexSegmentRegion, this class class provides a workaround for node offsets (which are relative to the start of the nodes block) in contrast to leaf offsets (which are relative to a known offset from the start of the index segment file). This condition arises as a side effect of serializing nodes at the same time that the IndexSegmentBuilder is serializing leaves such that we can not group the nodes and leaves into distinct regions and know the absolute offset to each node or leaf as it is serialized.

The offsets for blobs are likewise relative to the start of a IndexSegmentRegion.BLOB region. The requirement for a blob region arises in a similar manner: blobs are serialized during the IndexSegmentBuilder operation onto a buffer and then bulk copied onto the output file. This means that only the relative offset into the blob region is available at the time that the blob's address is written in an index entry's value.

Version:
$Id: IndexSegmentAddressManager.java 2572 2010-04-02 12:35:13Z thompsonbry $
Author:
Bryan Thompson

Field Summary
protected  long extentBlobs
          #of bytes in the blobs region.
protected  long extentLeaves
          #of bytes in the leaves region.
protected  long extentNodes
          #of bytes in the nodes region.
protected  long maxOffset
          The maximum offset (aka the #of bytes in the file).
protected  long offsetBlobs
          The offset within the file of the start of the blob region.
protected  long offsetLeaves
          The offset within the file of the start of the leaves region.
protected  long offsetNodes
          The offset within the file of the start of the node region.
 
Fields inherited from class com.bigdata.rawstore.WormAddressManager
_NULL_, MAX_OFFSET_BITS, MIN_OFFSET_BITS, SCALE_OUT_OFFSET_BITS, SCALE_UP_OFFSET_BITS
 
Fields inherited from interface com.bigdata.rawstore.IAddressManager
NULL
 
Constructor Summary
IndexSegmentAddressManager(IndexSegmentCheckpoint checkpoint)
           
 
Method Summary
 long getOffset(long addr)
          Decodes the offset to extract the IndexSegmentRegion and then applies the appropriate offset for that region in order to convert the offset into an absolute offset into the store.
 IndexSegmentRegion getRegion(long addr)
          Return the region relative to which this address was encoded.
 boolean isLeafAddr(long addr)
          Return true IFF the starting address lies entirely within the region dedicated to the B+Tree leaves.
 boolean isNodeAddr(long addr)
          Return true IFF the starting address lies entirely within the region dedicated to the B+Tree nodes.
 String toString(long addr)
          Returns a representation of the address with the decoded offset and the region to which that offset is relative.
 
Methods inherited from class com.bigdata.rawstore.WormAddressManager
assertByteCount, assertOffset, assertOffsetBits, getByteCount, getMaxByteCount, getMaxByteCount, getMaxOffset, getOffsetBits, getPhysicalAddress, main, toAddr, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

offsetLeaves

protected final long offsetLeaves
The offset within the file of the start of the leaves region. All leaves are written densely on the file beginning at this offset.


extentLeaves

protected final long extentLeaves
#of bytes in the leaves region.


offsetNodes

protected final long offsetNodes
The offset within the file of the start of the node region. All nodes are written densely on the file beginning at this offset. The child addresses for a node are relative to this offset and are automatically adjusted during decoding by this class.


extentNodes

protected final long extentNodes
#of bytes in the nodes region.


offsetBlobs

protected final long offsetBlobs
The offset within the file of the start of the blob region. All blob records are written densely on the file beginning at this offset. The blob addresses stored in a leaf are relative to this offset and are automatically adjusted during decoding by this class.


extentBlobs

protected final long extentBlobs
#of bytes in the blobs region.


maxOffset

protected final long maxOffset
The maximum offset (aka the #of bytes in the file).

Constructor Detail

IndexSegmentAddressManager

public IndexSegmentAddressManager(IndexSegmentCheckpoint checkpoint)
Parameters:
checkpoint -
Method Detail

getRegion

public final IndexSegmentRegion getRegion(long addr)
Return the region relative to which this address was encoded.

Note: ANY address MAY be encoded relative to the IndexSegmentRegion.BASE region. However, choosing IndexSegmentRegion.NODE or IndexSegmentRegion.BLOB regions does restrict the address to referencing a node (or blob) respectively.

Parameters:
addr - The address.
Returns:
The region relative to which this address was encoded.

getOffset

public final long getOffset(long addr)
Decodes the offset to extract the IndexSegmentRegion and then applies the appropriate offset for that region in order to convert the offset into an absolute offset into the store.

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

toString

public String toString(long addr)
Returns a representation of the address with the decoded offset and the region to which that offset is relative.

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

isNodeAddr

public boolean isNodeAddr(long addr)
Return true IFF the starting address lies entirely within the region dedicated to the B+Tree nodes.


isLeafAddr

public boolean isLeafAddr(long addr)
Return true IFF the starting address lies entirely within the region dedicated to the B+Tree leaves.



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