com.bigdata.btree
Class MutableNodeData

java.lang.Object
  extended by com.bigdata.btree.MutableNodeData
All Implemented Interfaces:
IAbstractNodeData, IChildData, IKeysData, INodeData, ISpannedTupleCountData, ITreeNodeData, IDataRecordAccess

public class MutableNodeData
extends Object
implements INodeData

Implementation maintains Java objects corresponding to the persistent data and defines methods for a variety of mutations on the INodeData record which operate by direct manipulation of the Java objects.

Note: package private fields are used so that they may be directly accessed by the Node class.

Version:
$Id: MutableNodeData.java 4523 2011-05-18 18:14:45Z thompsonbry $
Author:
Bryan Thompson

Constructor Summary
MutableNodeData(int branchingFactor, boolean hasVersionTimestamps)
          Create an empty mutable data record.
MutableNodeData(int branchingFactor, INodeData src)
          Makes a mutable copy of the source data record.
MutableNodeData(long nentries, IRaba keys, long[] childAddr, long[] childEntryCounts, boolean hasVersionTimestamps, long minimumVersionTimestamp, long maximumVersionTimestamp)
          Ctor based on just the "data" -- used by unit tests.
 
Method Summary
 AbstractFixedByteArrayBuffer data()
          The coded (aka compressed) data.
 long getChildAddr(int index)
          Return the persistent addresses of the specified child node.
 int getChildCount()
          The #of children of this node.
 long getChildEntryCount(int index)
          Return the #of tuples spanned by the indicated child of this node.
 int getKeyCount()
          Return the #of keys in the node or leaf.
 IRaba getKeys()
          The object used to contain and manage the keys.
 long getMaximumVersionTimestamp()
          The most recent tuple revision timestamp associated with any tuple spanned by this node or leaf.
 long getMinimumVersionTimestamp()
          The earliest tuple revision timestamp associated with any tuple spanned by this node or leaf.
 long getSpannedTupleCount()
          The #of tuples spanned by this node.
 boolean hasVersionTimestamps()
          Return true iff the leaves maintain tuple revision timestamps.
 boolean isCoded()
          No.
 boolean isLeaf()
          True iff this is a leaf node.
 boolean isReadOnly()
          No - this is a mutable data record.
protected  boolean rangeCheckChildIndex(int index)
          Range check a child index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MutableNodeData

public MutableNodeData(int branchingFactor,
                       boolean hasVersionTimestamps)
Create an empty mutable data record.

Parameters:
branchingFactor - The branching factor for the owning B+Tree. This is used to initialize the various arrays to the correct capacity.
hasVersionTimestamps - true iff the B+Tree is maintaining per tuple version timestamps.

MutableNodeData

public MutableNodeData(int branchingFactor,
                       INodeData src)
Makes a mutable copy of the source data record.

Parameters:
branchingFactor - The branching factor for the owning B+Tree. This is used to initialize the various arrays to the correct capacity.
src - The source data record.

MutableNodeData

public MutableNodeData(long nentries,
                       IRaba keys,
                       long[] childAddr,
                       long[] childEntryCounts,
                       boolean hasVersionTimestamps,
                       long minimumVersionTimestamp,
                       long maximumVersionTimestamp)
Ctor based on just the "data" -- used by unit tests.

Parameters:
nentries -
keys -
childAddr -
childEntryCounts -
Method Detail

isReadOnly

public final boolean isReadOnly()
No - this is a mutable data record.

Specified by:
isReadOnly in interface IAbstractNodeData

isCoded

public final boolean isCoded()
No.

Specified by:
isCoded in interface IAbstractNodeData

data

public final AbstractFixedByteArrayBuffer data()
Description copied from interface: IAbstractNodeData
The coded (aka compressed) data.

Specified by:
data in interface IAbstractNodeData
Specified by:
data in interface IDataRecordAccess

getSpannedTupleCount

public final long getSpannedTupleCount()
Description copied from interface: ISpannedTupleCountData
The #of tuples spanned by this node. For a leaf, the corresponding value is reported by IKeysData.getKeyCount() or ILeafData.getValueCount().

Specified by:
getSpannedTupleCount in interface ISpannedTupleCountData

rangeCheckChildIndex

protected final boolean rangeCheckChildIndex(int index)
Range check a child index.

Parameters:
index - The index of a child in [0:nkeys+1].
Returns:
true
Throws:
IndexOutOfBoundsException - if the index is not in the legal range.

getChildAddr

public final long getChildAddr(int index)
Description copied from interface: IChildData
Return the persistent addresses of the specified child node.

Specified by:
getChildAddr in interface IChildData
Parameters:
index - The index of the child in [0:nkeys].
Returns:
The persistent child address -or- zero(0L) if the child is not persistent.

getChildEntryCount

public final long getChildEntryCount(int index)
Description copied from interface: ISpannedTupleCountData
Return the #of tuples spanned by the indicated child of this node. The sum of the values returned by this method across the children of the node should always equal the value returned by ISpannedTupleCountData.getSpannedTupleCount() . These data are used to support fast computation of the index at which a key occurs and the #of entries in a given key range.

Specified by:
getChildEntryCount in interface ISpannedTupleCountData
Parameters:
index - The index of the child in [0:nkeys].
Returns:
The #of tuples spanned by that child.

getChildCount

public final int getChildCount()
Description copied from interface: IChildData
The #of children of this node. Either all children will be nodes or all children will be leaves. The #of children of a node MUST be IAbstractNodeData#getKeyCount()+1

Specified by:
getChildCount in interface IChildData
Returns:
The #of children of this node.

getKeyCount

public final int getKeyCount()
Description copied from interface: IKeysData
Return the #of keys in the node or leaf. A node has nkeys+1 children. A leaf has nkeys keys and values. The maximum #of keys for a node is one less than the branching factor of the B+Tree. The maximum #of keys for a leaf is the branching factor of the B+Tree. For a hash bucket, this is the #of entries in the bucket.

Specified by:
getKeyCount in interface IKeysData
Returns:
The #of defined keys.

getKeys

public final IRaba getKeys()
Description copied from interface: IKeysData
The object used to contain and manage the keys.

Specified by:
getKeys in interface IKeysData

isLeaf

public final boolean isLeaf()
Description copied from interface: IAbstractNodeData
True iff this is a leaf node.

Specified by:
isLeaf in interface IAbstractNodeData

hasVersionTimestamps

public final boolean hasVersionTimestamps()
Description copied from interface: IAbstractNodeData
Return true iff the leaves maintain tuple revision timestamps. When true, the minimum and maximum tuple revision timestamp for a node or leaf are available from IAbstractNodeData.getMinimumVersionTimestamp() and IAbstractNodeData.getMaximumVersionTimestamp().

Specified by:
hasVersionTimestamps in interface IAbstractNodeData

getMaximumVersionTimestamp

public final long getMaximumVersionTimestamp()
Description copied from interface: IAbstractNodeData
The most recent tuple revision timestamp associated with any tuple spanned by this node or leaf. If there are NO tuples for the leaf, then this MUST return Long.MIN_VALUE since the initial value of the maximum version timestamp is always the smallest possible long integer.

Specified by:
getMaximumVersionTimestamp in interface IAbstractNodeData

getMinimumVersionTimestamp

public final long getMinimumVersionTimestamp()
Description copied from interface: IAbstractNodeData
The earliest tuple revision timestamp associated with any tuple spanned by this node or leaf. If there are NO tuples for the leaf, then this MUST return Long.MAX_VALUE since the initial value of the minimum version timestamp is always the largest possible long integer.

Specified by:
getMinimumVersionTimestamp in interface IAbstractNodeData


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