|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ostore.dataobj.Btree
The Btree forms the basis for storing data in OceanStore. While it is based on the ideas of standard Btree, it is not a generic, general-purpose Btree. Note that a Btree is initialized with the desired size of the nodes rather than the traditional degree of the tree. This is the case because it is more important that we know the size of the blocks (for network transmission, archival, etc.) than the branching factor.
Nested Class Summary | |
---|---|
static interface |
Btree.Callback
This interface must be implemented by clients wishing to use any of the Depth-First Search (DFS) methods. |
static class |
Btree.InteriorNode
The InteriorNode object is the interior node of the Btree. |
static interface |
Btree.Predicate
This interface must be implemented by clients wishing to use any of the Depth-First Search (DFS) methods. |
static interface |
Btree.Record
|
Field Summary | |
---|---|
static int |
DATA_BTREE
|
static int |
INDEX_BTREE
|
Constructor Summary | |
---|---|
Btree(Btree old_btree)
Create a new Btree tree by cloning an existing Btree. |
|
Btree(InputBuffer buffer)
|
|
Btree(int btree_type,
int blocksize)
Create a new Btree. |
Method Summary | |
---|---|
Btree |
begin()
|
void |
commit(HandleStore handle_store,
DataCache cache)
|
SecureHash |
computeGuid()
Compute and return the guid of the object. |
SecureHash |
computeVhash()
Compute and return the verification hash of the object. |
protected Object |
dfs_helper(BtreeNode node,
Btree.Predicate pred,
Btree.Callback cb,
Btree.Record rec,
int level,
boolean pre,
HandleStore handle_store,
DataCache cache)
|
Object |
dfsPostorder(Btree.Predicate pred,
Btree.Callback cb,
Btree.Record rec,
HandleStore handle_store,
DataCache cache)
Traverse the tree in depth-first order, guided by the predicate pred , and invoke the callback cb on each
node as it is left. |
Object |
dfsPreorder(Btree.Predicate pred,
Btree.Callback cb,
Btree.Record rec,
HandleStore handle_store,
DataCache cache)
Traverse the tree in depth-first order, guided by the predicate pred , and invoke the callback cb on each
node as it is entered. |
static Btree |
fromGuidBytes(byte[] data,
int[] offset)
|
static Btree |
fromGuidBytes(InputBuffer buffer)
|
int |
getBlockSize()
|
SecureHash |
getFhash()
Return the secure hash at the root of the verification tree constructed from the erasure-encoded fragments of a block. |
Btree.InteriorNode |
getRoot()
|
void |
insert(BtreeKey key,
BtreeNode data,
HandleStore handle_store,
CacheablePinned memory_handle,
DataCache cache)
|
void |
insert(BtreeKey key,
BtreeNode data,
HandleStore handle_store,
DataCache cache)
|
boolean |
isDataNode()
|
boolean |
isLeaf()
|
Collection |
readPath(BtreeKey key,
HandleStore handle_store,
DataCache cache)
|
boolean |
replace(BtreeKey key,
BtreeNode data,
CacheablePinned memory_handle,
HandleStore handle_store,
DataCache cache,
LinkedList reserved_blocks)
|
boolean |
replace(BtreeKey key,
BtreeNode data,
HandleStore handle_store,
DataCache cache)
|
CacheablePinned |
search(BtreeKey key,
HandleStore handle_store,
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 |
setRoot(Btree.InteriorNode root)
|
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 |
public static final int DATA_BTREE
public static final int INDEX_BTREE
Constructor Detail |
public Btree(int btree_type, int blocksize)
blocksize
- the maximum size in bytes to be used by each node in the Btreepublic Btree(Btree old_btree)
old_btree
- the old Btree to clonepublic Btree(InputBuffer buffer) throws QSException
Method Detail |
public static Btree fromGuidBytes(byte[] data, int[] offset) throws QSException
QSException
public static Btree fromGuidBytes(InputBuffer buffer) throws QSException
QSException
public int getBlockSize()
public Btree begin()
public void commit(HandleStore handle_store, DataCache cache)
public void insert(BtreeKey key, BtreeNode data, HandleStore handle_store, DataCache cache) throws CacheException
CacheException
public void insert(BtreeKey key, BtreeNode data, HandleStore handle_store, CacheablePinned memory_handle, DataCache cache) throws CacheException
CacheException
public CacheablePinned search(BtreeKey key, HandleStore handle_store, DataCache cache) throws CacheException
CacheException
public boolean replace(BtreeKey key, BtreeNode data, HandleStore handle_store, DataCache cache) throws CacheException
CacheException
public boolean replace(BtreeKey key, BtreeNode data, CacheablePinned memory_handle, HandleStore handle_store, DataCache cache, LinkedList reserved_blocks) throws CacheException
CacheException
public Collection readPath(BtreeKey key, HandleStore handle_store, DataCache cache) throws CacheException
CacheException
public Btree.InteriorNode getRoot()
public void setRoot(Btree.InteriorNode root)
public Object dfsPreorder(Btree.Predicate pred, Btree.Callback cb, Btree.Record rec, HandleStore handle_store, DataCache cache) throws CacheException
pred
, and invoke the callback cb
on each
node as it is entered.
pred
- the predicate that determines whether a node is visitedcb
- the callback to invoke as each node is entered
CacheException
public Object dfsPostorder(Btree.Predicate pred, Btree.Callback cb, Btree.Record rec, HandleStore handle_store, DataCache cache) throws CacheException
pred
, and invoke the callback cb
on each
node as it is left.
pred
- the predicate that determines whether a node is visitedcb
- the callback to invoke as each node is left
CacheException
protected Object dfs_helper(BtreeNode node, Btree.Predicate pred, Btree.Callback cb, Btree.Record rec, int level, boolean pre, HandleStore handle_store, DataCache cache) throws CacheException
CacheException
public String toString()
toString
in class Object
public SecureHash getFhash()
VerifiableBlock
getFhash
in interface VerifiableBlock
public void setFhash(SecureHash fhash)
VerifiableBlock
setFhash
in interface VerifiableBlock
fhash
- the secure hash at the root of the verification treepublic SecureHash computeVhash()
VerifiableBlock
computeVhash
in interface VerifiableBlock
public void toVhashBytes(byte[] data, int[] offset)
VerifiableBlock
toVhashBytes
in interface VerifiableBlock
data
- See ostore.util.QuickSerializable.to_bytes
offset
- See ostore.util.QuickSerializable.to_bytes
public boolean verifyVhash(SecureHash vhash)
VerifiableBlock
verifyVhash
in interface VerifiableBlock
vhash
- the vhash against which to verify the object
true
iff the hash of the object matches
vhash
; false
otherwisepublic SecureHash computeGuid() throws BlockNotGuidVerifiableException
VerifiableBlock
computeGuid
in interface VerifiableBlock
BlockNotGuidVerifiableException
VerifiableBlock.setFhash(ostore.util.SecureHash)
public void toGuidBytes(byte[] data, int[] offset) throws BlockNotGuidVerifiableException
VerifiableBlock
toGuidBytes
in interface VerifiableBlock
data
- See ostore.util.QuickSerializable.to_bytes
offset
- See ostore.util.QuickSerializable.to_bytes
BlockNotGuidVerifiableException
public boolean verifyGuid(SecureHash guid) throws BlockNotGuidVerifiableException
VerifiableBlock
verifyGuid
in interface VerifiableBlock
guid
- the block guid against which to verify the object
true
iff the guid of the object matches
bguid
; false
otherwise
BlockNotGuidVerifiableException
public void serialize(OutputBuffer buffer)
QuickSerializable
buffer
.
serialize
in interface QuickSerializable
buffer
- the output buffer to add the object topublic boolean isDataNode()
isDataNode
in interface BtreeNode
public boolean isLeaf()
isLeaf
in interface BtreeNode
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |