ostore.dataobj
Class DataObject.DataBlock

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

public static class DataObject.DataBlock
extends Object
implements BtreeNode, QuickSerializable

The DataBlock object is stored at the leaves of the Btree. It holds the user data. Effectively, it is little more than an array of bytes.


Field Summary
 byte[] _bytes
           
static int overhead
           
 
Constructor Summary
DataObject.DataBlock(InputBuffer buffer)
           
DataObject.DataBlock(int size)
           
 
Method Summary
 SecureHash computeGuid()
          Compute and return the guid of the object.
 SecureHash computeVhash()
          Compute and return the verification hash of the object.
static DataObject.DataBlock fromGuidBytes(byte[] data, int[] offset)
           
static DataObject.DataBlock fromGuidBytes(InputBuffer buffer)
           
 byte[] getData()
           
 SecureHash getFhash()
          Return the secure hash at the root of the verification tree constructed from the erasure-encoded fragments of a block.
 int getSizeInBytes()
           
 boolean isDataNode()
           
 boolean isLeaf()
           
 void serialize(OutputBuffer buffer)
          Add the object to the buffer.
 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 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_bytes

public byte[] _bytes

overhead

public static final int overhead
Constructor Detail

DataObject.DataBlock

public DataObject.DataBlock(int size)

DataObject.DataBlock

public DataObject.DataBlock(InputBuffer buffer)
                     throws QSException
Method Detail

fromGuidBytes

public static DataObject.DataBlock fromGuidBytes(byte[] data,
                                                 int[] offset)
                                          throws QSException
QSException

fromGuidBytes

public static DataObject.DataBlock fromGuidBytes(InputBuffer buffer)
                                          throws QSException
QSException

toString

public String toString()
Overrides:
toString in class Object

getData

public byte[] getData()

getSizeInBytes

public int getSizeInBytes()

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

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

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

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

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

isDataNode

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

isLeaf

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