public abstract class Btree extends java.lang.Object implements Index, Streamable, StorageClient
The btreeindex package is as much as possible independent of the btreestorage implementation. However, there are a few dependencies which would need to be addressed if this code was to be used with some other storage mechanism. The main one is the need, when instantiating a that was retrieved from the repository via Btree.read(), to instantiate the specific BtreePageSource implementation that this btree will use. The MOFID class also comes from the btreestorage package, and the Converter routines from that package are used to convert integers to byte arrays and back.
| Modifier and Type | Field and Description |
|---|---|
protected EntryTypeInfo |
dataInfo |
protected int |
dataLength |
protected Storage.EntryType |
dataType |
protected boolean |
hasBigKeys |
protected EntryTypeInfo |
keyInfo |
protected Storage.EntryType |
keyType |
protected java.lang.String |
name |
protected int |
pageIdLength |
protected int |
pageSize |
protected BtreePageSource |
pageSource |
protected byte[] |
rootPageId |
protected BtreeStorage |
storage |
protected boolean |
uniqueKeys |
protected boolean |
uniqueValues |
| Constructor and Description |
|---|
Btree() |
Btree(java.lang.String name,
Storage.EntryType keyType,
Storage.EntryType dataType,
BtreePageSource pageSource) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(java.lang.Object key,
java.lang.Object data)
Add a new entry to the index.
|
protected void |
beginRead() |
protected void |
beginWrite() |
protected void |
btreePut(java.lang.Object key,
java.lang.Object data,
byte operation,
int index) |
int |
consistencyCheck(java.io.PrintWriter out)
Check the btree for consistency, for testing and debugging.
|
void |
dumpTree(java.io.PrintWriter out)
Print the contents of the btree for debugging purposes.
|
protected void |
endRead() |
protected void |
endWrite() |
Storage.EntryType |
getKeyType()
Returns the type of keys in index.
|
java.lang.String |
getName()
Returns the unique name of the index in the Storage.
|
Storage.EntryType |
getValueType()
Returns the type of values indexed by this index.
|
protected void |
init() |
java.util.Set |
keySet()
Returns a set view of the keys contained in this index.
|
BtreePage |
pageFactory()
Returns the right kind of BtreePage for this btree.
|
void |
read(java.io.InputStream inputStream)
Populate this Btree from the InputStream.
|
boolean |
remove(java.lang.Object key)
Remove all entries associated with the specified key.
|
void |
setStorage(Storage storage)
Pass the object the Storage implementation.
|
void |
write(java.io.OutputStream outputStream)
Write the state of this Btree to the OutputStream.
|
protected BtreePageSource pageSource
protected BtreeStorage storage
protected Storage.EntryType keyType
protected Storage.EntryType dataType
protected java.lang.String name
protected EntryTypeInfo keyInfo
protected EntryTypeInfo dataInfo
protected int dataLength
protected int pageIdLength
protected int pageSize
protected byte[] rootPageId
protected boolean uniqueKeys
protected boolean uniqueValues
protected boolean hasBigKeys
public Btree(java.lang.String name,
Storage.EntryType keyType,
Storage.EntryType dataType,
BtreePageSource pageSource)
throws StorageException
StorageExceptionpublic Btree()
protected void init()
throws StorageException
StorageExceptionpublic void write(java.io.OutputStream outputStream)
throws StorageException
write in interface StreamableoutputStream - OutputStreamStorageExceptionpublic void read(java.io.InputStream inputStream)
throws StorageException
read in interface StreamableinputStream - InputStreamStorageExceptionpublic void setStorage(Storage storage)
StorageClientsetStorage in interface StorageClientstorage - the Stroage implementation which
instantiated the objectpublic Storage.EntryType getKeyType()
getKeyType in interface IndexStorageExceptionpublic Storage.EntryType getValueType()
getValueType in interface IndexStorageExceptionpublic java.lang.String getName()
getName in interface IndexStorageExceptionpublic java.util.Set keySet()
throws StorageException
keySet in interface IndexStorageExceptionpublic void add(java.lang.Object key,
java.lang.Object data)
throws StorageException
add in interface Indexkey - key to insertdata - data associated with keyStorageBadRequestException - If key or data are incorrect type, or if
the insert would violate the constraints of this indexStorageException - If a problem was encountered accessing storagepublic boolean remove(java.lang.Object key)
throws StorageException
remove in interface Indexkey - key for entry to be removedStorageException - If there was a problem reading or
writing pagespublic BtreePage pageFactory()
protected void btreePut(java.lang.Object key,
java.lang.Object data,
byte operation,
int index)
throws StorageException
StorageExceptionprotected void beginRead()
protected void endRead()
protected void beginWrite()
protected void endWrite()
public void dumpTree(java.io.PrintWriter out)
throws StorageException
out - PrintWriter to print btree toStorageExceptionpublic int consistencyCheck(java.io.PrintWriter out)
throws StorageException
out - PrintWriter to print results toStorageExceptionCopyright © 2005-2012 Apache Software Foundation. All Rights Reserved.