|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.netbeans.mdr.persistence.btreeimpl.btreeindex.Btree
Btree index implementation. This is the top of the Btree hierarchy which implements the org.netbeans.mdr.persistence.Index interface hierarchy. This abstract class and its subclasses contain the persistent state of a Btree and the public interface methods for accessing it. The main logic for searching and updating a Btree is contained in the BtreePage class.
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.
Field Summary | |
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 Summary | |
Btree()
|
|
Btree(java.lang.String name,
Storage.EntryType keyType,
Storage.EntryType dataType,
BtreePageSource pageSource)
|
Method Summary | |
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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
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
Constructor Detail |
public Btree(java.lang.String name, Storage.EntryType keyType, Storage.EntryType dataType, BtreePageSource pageSource) throws StorageException
public Btree()
Method Detail |
protected void init() throws StorageException
StorageException
public void write(java.io.OutputStream outputStream) throws StorageException
write
in interface Streamable
outputStream
- OutputStream
StorageException
public void read(java.io.InputStream inputStream) throws StorageException
read
in interface Streamable
inputStream
- InputStream
StorageException
public void setStorage(Storage storage)
StorageClient
setStorage
in interface StorageClient
storage
- the Stroage implementation which
instantiated the objectpublic Storage.EntryType getKeyType()
getKeyType
in interface Index
StorageException
public Storage.EntryType getValueType()
getValueType
in interface Index
StorageException
public java.lang.String getName()
getName
in interface Index
StorageException
public java.util.Set keySet() throws StorageException
keySet
in interface Index
StorageException
public void add(java.lang.Object key, java.lang.Object data) throws StorageException
add
in interface Index
key
- key to insertdata
- data associated with key
StorageBadRequestException
- If key or data are incorrect type, or if
the insert would violate the constraints of this index
StorageException
- If a problem was encountered accessing storagepublic boolean remove(java.lang.Object key) throws StorageException
remove
in interface Index
key
- key for entry to be removed
StorageException
- 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
StorageException
protected 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 to
StorageException
public int consistencyCheck(java.io.PrintWriter out) throws StorageException
out
- PrintWriter to print results to
StorageException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |