ostore.dataobj
Class DataObject

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

public class DataObject
extends Object
implements VerifiableBlock, QuickSerializable

Version:
$Id: DataObject.java,v 1.81 2003/12/11 22:44:47 eaton Exp $
Author:
Patrick R. Eaton

Nested Class Summary
static class DataObject.DataBlock
          The DataBlock object is stored at the leaves of the Btree.
 
Field Summary
static boolean DEBUG
           
static int FLAT_OBJECT
          A constant to refer to the type of DataObject's that do not include an index.
static int INDEXED_OBJECT
          A constant to refer to the type of DataObject's that include an index.
 
Constructor Summary
DataObject(DataObject data_obj)
           
DataObject(InputBuffer buffer)
           
DataObject(int type, SecureHash active_guid, SignedQS signed_create_request, SignedQS signed_prcert, Acl acl, int block_size)
           
DataObject(int type, SecureHash active_guid, SignedQS signed_create_request, SignedQS signed_prcert, Acl acl, SecureHash last_ckpt_guid, QSArray last_log_guid, boolean is_log, int block_size)
           
DataObject(int type, SecureHash active_guid, SignedQS signed_create_request, SignedQS signed_prcert, Acl acl, SecureHash last_ckpt_guid, QSArray last_log_guid, boolean is_log, int block_size, byte[] data)
           
 
Method Summary
 void append(InputBuffer data_buffer, int length, DataObjectAppendException except, CacheablePinned memory_handle, DataCache cache)
           
 DataObject begin()
           
 SecureHash commit(DataCache cache)
           
 SecureHash computeGuid()
          Compute and return the guid of the object.
 SecureHash computeVhash()
          Compute and return the verification hash of the object.
static DataObject fromGuidBytes(byte[] data, int[] offset)
           
 Btree getBtree()
          Returns the btree containing the data of the object.
 SecureHash getFhash()
          Return the secure hash at the root of the verification tree constructed from the erasure-encoded fragments of a block.
 QuickSerializable getFromMetadata(int field)
           
 QuickSerializable getFromMetadata(String field)
           
 byte[] getInlinedData()
          Returns the inlined data.
 Metadata getMetadata()
           
static int getTopBlockSize(int btree_block_size)
           
 boolean isDataInlined()
          Reports whether the data is inlined or in a btree.
 boolean isIndexed()
           
 byte[] read(int start, int length, DataCache cache)
           
 byte[] read(int start, int length, DataObjectReadException except, DataCache cache)
           
 byte[] read(Selection sel, DataCache cache)
           
 byte[] read(Selection sel, DataCache cache, DataObjectReadException except)
           
 byte[] readIndex(KeyedSelection key_sel, DataCache cache, DataObjectReadException except)
           
 Set readSlice(int start, int length, DataCache cache)
           
 Set readSlice(int start, int length, DataObjectReadSliceException except, DataCache cache)
           
 void replace(InputBuffer data_buffer, int start, int length, DataObjectReplaceException except, CacheablePinned memory_handle, DataCache cache)
           
 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 setInMetadata(int field, QuickSerializable value)
           
 void setInMetadata(String field, QuickSerializable value)
           
 void toGuidBytes(byte[] data, int[] offset)
          Serialize the object in a form suitable for computing the block guid of the object.
 void toVhashBytes(byte[] data, int[] offset)
          Serialize the object in a form suitable for computing the verification hash of the object.
 void truncate()
           
 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, toString, wait, wait, wait
 

Field Detail

DEBUG

public static final boolean DEBUG
See Also:
Constant Field Values

INDEXED_OBJECT

public static final int INDEXED_OBJECT
A constant to refer to the type of DataObject's that include an index.

See Also:
Constant Field Values

FLAT_OBJECT

public static final int FLAT_OBJECT
A constant to refer to the type of DataObject's that do not include an index.

See Also:
Constant Field Values
Constructor Detail

DataObject

public DataObject(int type,
                  SecureHash active_guid,
                  SignedQS signed_create_request,
                  SignedQS signed_prcert,
                  Acl acl,
                  int block_size)

DataObject

public DataObject(int type,
                  SecureHash active_guid,
                  SignedQS signed_create_request,
                  SignedQS signed_prcert,
                  Acl acl,
                  SecureHash last_ckpt_guid,
                  QSArray last_log_guid,
                  boolean is_log,
                  int block_size)

DataObject

public DataObject(int type,
                  SecureHash active_guid,
                  SignedQS signed_create_request,
                  SignedQS signed_prcert,
                  Acl acl,
                  SecureHash last_ckpt_guid,
                  QSArray last_log_guid,
                  boolean is_log,
                  int block_size,
                  byte[] data)

DataObject

public DataObject(DataObject data_obj)

DataObject

public DataObject(InputBuffer buffer)
           throws QSException
Method Detail

fromGuidBytes

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

begin

public DataObject begin()

commit

public SecureHash commit(DataCache cache)

getTopBlockSize

public static int getTopBlockSize(int btree_block_size)

isIndexed

public boolean isIndexed()

getMetadata

public Metadata getMetadata()

getFromMetadata

public QuickSerializable getFromMetadata(int field)

getFromMetadata

public QuickSerializable getFromMetadata(String field)

setInMetadata

public void setInMetadata(int field,
                          QuickSerializable value)

setInMetadata

public void setInMetadata(String field,
                          QuickSerializable value)

isDataInlined

public boolean isDataInlined()
Reports whether the data is inlined or in a btree.

Returns:
true if the data is inlined, false

getInlinedData

public byte[] getInlinedData()
Returns the inlined data.

Returns:
a byte array containing the inlined data, null if the data is not inlined

getBtree

public Btree getBtree()
Returns the btree containing the data of the object.

Returns:
the btree containing the data of the object, null if the data is inlined

read

public byte[] read(Selection sel,
                   DataCache cache)
            throws DataObjectReadException
DataObjectReadException

read

public byte[] read(Selection sel,
                   DataCache cache,
                   DataObjectReadException except)
            throws DataObjectReadException
DataObjectReadException

readIndex

public byte[] readIndex(KeyedSelection key_sel,
                        DataCache cache,
                        DataObjectReadException except)
                 throws DataObjectReadException
DataObjectReadException

read

public byte[] read(int start,
                   int length,
                   DataCache cache)
            throws DataObjectReadException,
                   ReadUnsatisfiableException
DataObjectReadException
ReadUnsatisfiableException

read

public byte[] read(int start,
                   int length,
                   DataObjectReadException except,
                   DataCache cache)
            throws DataObjectReadException,
                   ReadUnsatisfiableException
DataObjectReadException
ReadUnsatisfiableException

readSlice

public Set readSlice(int start,
                     int length,
                     DataCache cache)
              throws DataObjectReadSliceException,
                     ReadUnsatisfiableException
DataObjectReadSliceException
ReadUnsatisfiableException

readSlice

public Set readSlice(int start,
                     int length,
                     DataObjectReadSliceException except,
                     DataCache cache)
              throws DataObjectReadSliceException,
                     ReadUnsatisfiableException
DataObjectReadSliceException
ReadUnsatisfiableException

truncate

public void truncate()

append

public void append(InputBuffer data_buffer,
                   int length,
                   DataObjectAppendException except,
                   CacheablePinned memory_handle,
                   DataCache cache)
            throws DataObjectAppendException
DataObjectAppendException

replace

public void replace(InputBuffer data_buffer,
                    int start,
                    int length,
                    DataObjectReplaceException except,
                    CacheablePinned memory_handle,
                    DataCache cache)
             throws DataObjectReplaceException
DataObjectReplaceException

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