ostore.dataobj
Class Btree.InteriorNode

java.lang.Object
  |
  +--ostore.dataobj.Btree.InteriorNode
All Implemented Interfaces:
BtreeNode, Cacheable, QuickSerializable, VerifiableBlock
Enclosing class:
Btree

public static class Btree.InteriorNode
extends Object
implements BtreeNode, QuickSerializable

The InteriorNode object is the interior node of the Btree. It holds a few fields of overhead and arrays of (2*degree - 1) keys and (2*degree) pointers to other nodes (interior nodes or data nodes).


Constructor Summary
Btree.InteriorNode(Btree.InteriorNode n)
           
Btree.InteriorNode(InputBuffer buffer)
           
Btree.InteriorNode(int btree_type, int degree)
           
 
Method Summary
 boolean childIsTemp(int index, HandleStore handle_store)
           
 SecureHash computeGuid()
          Compute and return the guid of the object.
 SecureHash computeVhash()
          Compute and return the verification hash of the object.
 void copyChild(int from, int to)
           
 void copyKey(int from, int to)
           
static Btree.InteriorNode fromGuidBytes(byte[] data, int[] offset)
           
static Btree.InteriorNode fromGuidBytes(InputBuffer buffer)
           
 CacheablePinned getChild(int index, HandleStore handle_store, DataCache cache)
           
 SecureHash getChildGuid(int index)
           
 SecureHash getChildVhash(int index)
           
 SecureHash getFhash()
          Return the secure hash at the root of the verification tree constructed from the erasure-encoded fragments of a block.
 BtreeKey getKey(int index)
           
static int getSerializedKeySize(int btree_type)
           
static int getSerializedOverhead(int btree_type)
           
static int getSerializedPointerSize(int btree_type)
           
static int getSizeInBytes(int btree_type, int degree)
           
 int getUsed()
           
 int incrementUsed()
           
 boolean isDataNode()
           
 boolean isFull()
           
 boolean isLeaf()
           
 void serialize(OutputBuffer buffer)
          Add the object to the buffer.
 void setChildGuid(int index, SecureHash guid)
           
 void setChildVhash(int index, SecureHash hash)
           
 void setFhash(SecureHash fhash)
          Record the secure hash at the root of the verification tree constructed from the erasure-encoded fragments of a block.
 void setKey(int index, BtreeKey key)
           
 void setLeaf(boolean leaf)
           
 void setUsed(int u)
           
 void toGuidBytes(byte[] data, int[] offset)
          Serialize the object in a form suitable for computing the block guid of the object.
 String toString()
           
 void toVhashBytes(byte[] data, int[] offset)
          Serialize the object in a form suitable for computing the verification hash of the object.
 boolean verifyGuid(SecureHash guid)
          Verify the contents of the object against its given guid.
 boolean verifyVhash(SecureHash vhash)
          Verify the contents of the object against its given verification hash.
 void voidChild(int i)
           
 void voidKey(int i)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Btree.InteriorNode

public Btree.InteriorNode(int btree_type,
                          int degree)

Btree.InteriorNode

public Btree.InteriorNode(Btree.InteriorNode n)

Btree.InteriorNode

public Btree.InteriorNode(InputBuffer buffer)
                   throws QSException
Method Detail

fromGuidBytes

public static Btree.InteriorNode fromGuidBytes(byte[] data,
                                               int[] offset)
                                        throws QSException
QSException

fromGuidBytes

public static Btree.InteriorNode fromGuidBytes(InputBuffer buffer)
                                        throws QSException
QSException

getSizeInBytes

public static int getSizeInBytes(int btree_type,
                                 int degree)

getSerializedOverhead

public static int getSerializedOverhead(int btree_type)

getSerializedKeySize

public static int getSerializedKeySize(int btree_type)

getSerializedPointerSize

public static int getSerializedPointerSize(int btree_type)

voidKey

public void voidKey(int i)

voidChild

public void voidChild(int i)

toString

public String toString()
Overrides:
toString in class Object

isFull

public boolean isFull()

isLeaf

public boolean isLeaf()
Specified by:
isLeaf in interface BtreeNode

setLeaf

public void setLeaf(boolean leaf)

getUsed

public int getUsed()

setUsed

public void setUsed(int u)

incrementUsed

public int incrementUsed()

setKey

public void setKey(int index,
                   BtreeKey key)

copyKey

public void copyKey(int from,
                    int to)

getKey

public BtreeKey getKey(int index)

childIsTemp

public boolean childIsTemp(int index,
                           HandleStore handle_store)

getChild

public CacheablePinned getChild(int index,
                                HandleStore handle_store,
                                DataCache cache)
                         throws CacheMissException
CacheMissException

setChildGuid

public void setChildGuid(int index,
                         SecureHash guid)

setChildVhash

public void setChildVhash(int index,
                          SecureHash hash)

getChildVhash

public SecureHash getChildVhash(int index)

getChildGuid

public SecureHash getChildGuid(int index)

copyChild

public void copyChild(int from,
                      int to)

getFhash

public SecureHash getFhash()
Description copied from interface: VerifiableBlock
Return the secure hash at the root of the verification tree constructed from the erasure-encoded fragments of a block. The root hash verifies the the fragments of the block and is a component in the computation of the block GUID.

Specified by:
getFhash in interface VerifiableBlock
Returns:
the secure hash at the root of the verification tree

setFhash

public void setFhash(SecureHash fhash)
Description copied from interface: VerifiableBlock
Record the secure hash at the root of the verification tree constructed from the erasure-encoded fragments of a block. The root hash verifies the the fragments of the block and is a component in the computation of the block GUID.

Specified by:
setFhash in interface VerifiableBlock
Parameters:
fhash - the secure hash at the root of the verification tree

isDataNode

public boolean isDataNode()
Specified by:
isDataNode in interface BtreeNode

computeVhash

public SecureHash computeVhash()
Description copied from interface: VerifiableBlock
Compute and return the verification hash of the object.

Specified by:
computeVhash in interface VerifiableBlock
Returns:
the vhash of the object

verifyVhash

public boolean verifyVhash(SecureHash vhash)
Description copied from interface: VerifiableBlock
Verify the contents of the object against its given verification hash. This method will compute the verification hash of the object and compare that hash against the alleged hash of the object to determine its validity.

Specified by:
verifyVhash in interface VerifiableBlock
Parameters:
vhash - the vhash against which to verify the object
Returns:
true iff the hash of the object matches vhash; false otherwise

toVhashBytes

public void toVhashBytes(byte[] data,
                         int[] offset)
Description copied from interface: VerifiableBlock
Serialize the object in a form suitable for computing the verification hash of the object. The parameters and their meaning mimic those of the QuickSerializable.to_bytes() method. @see ostore.util.QuickSerializable#to_bytes

Specified by:
toVhashBytes in interface VerifiableBlock
Parameters:
data - See ostore.util.QuickSerializable.to_bytes
offset - See ostore.util.QuickSerializable.to_bytes

computeGuid

public SecureHash computeGuid()
                       throws BlockNotGuidVerifiableException
Description copied from interface: VerifiableBlock
Compute and return the guid of the object. As a precondition, the secure hash of the root of the fragment verification tree must be set.

Specified by:
computeGuid in interface VerifiableBlock
Returns:
the guid of the object
BlockNotGuidVerifiableException
See Also:
VerifiableBlock.setFhash(ostore.util.SecureHash)

toGuidBytes

public void toGuidBytes(byte[] data,
                        int[] offset)
                 throws BlockNotGuidVerifiableException
Description copied from interface: VerifiableBlock
Serialize the object in a form suitable for computing the block guid of the object. The parameters and their meaning mimic those of the QuickSerializable.to_bytes() method. @see ostore.util.QuickSerializable#to_bytes As a precondition, the secure hash of the root of the fragment verification tree must be set.

Specified by:
toGuidBytes in interface VerifiableBlock
Parameters:
data - See ostore.util.QuickSerializable.to_bytes
offset - See ostore.util.QuickSerializable.to_bytes
BlockNotGuidVerifiableException

verifyGuid

public boolean verifyGuid(SecureHash guid)
                   throws BlockNotGuidVerifiableException
Description copied from interface: VerifiableBlock
Verify the contents of the object against its given guid. This method will compute the guid of the object and compare that hash against the alleged name of the object to determine its validity. As a precondition, the secure hash of the root of the fragment verification tree must be set.

Specified by:
verifyGuid in interface VerifiableBlock
Parameters:
guid - the block guid against which to verify the object
Returns:
true iff the guid of the object matches bguid; false otherwise
BlockNotGuidVerifiableException

serialize

public void serialize(OutputBuffer buffer)
Description copied from interface: QuickSerializable
Add the object to the buffer.

Specified by:
serialize in interface QuickSerializable
Parameters:
buffer - the output buffer to add the object to