|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.exist.storage.btree.Paged
org.exist.storage.btree.BTree
A general purpose B+-tree which stores binary keys as instances of
Value. The actual value data is not
stored in the B+tree itself. Instead, we use long pointers to record the
storage address of the value. This class has no methods to locate or
modify data records. Data handling is in the responsibilty of the
proper subclasses: BFile and
DOMFile.
Both, branch and leaf nodes are represented by the inner class
BTree.BTreeNode.
| Nested Class Summary | |
protected class |
BTree.BTreeFileHeader
|
protected class |
BTree.BTreeNode
A node in the B+-tree. |
protected static class |
BTree.BTreePageHeader
|
| Nested classes inherited from class org.exist.storage.btree.Paged |
Paged.FileHeader, Paged.Page, Paged.PageHeader |
| Field Summary | |
protected static byte |
BRANCH
Type of BTreeNode/Page |
protected int |
buffers
Size of BTreeNode cache |
protected Cache |
cache
Cache of BTreeNode(s) |
protected CacheManager |
cacheManager
|
protected byte |
fileId
|
protected double |
growthThreshold
|
protected boolean |
isTransactional
|
static long |
KEY_NOT_FOUND
Used as return value, if a value was not found |
protected static byte |
LEAF
Type of BTreeNode/Page |
static byte |
LOG_CREATE_BNODE
Log entry type for creation of a new btree node |
static byte |
LOG_INSERT_VALUE
Log entry type for an insert value operation |
static byte |
LOG_REMOVE_VALUE
Log entry type for removing a value |
static byte |
LOG_SET_PARENT
Log entry type for a parent page change resulting from a page split |
static byte |
LOG_UPDATE_PAGE
Log entry type for a page update resulting from a page split |
static byte |
LOG_UPDATE_VALUE
Log entry type for a value update |
protected Journal |
logManager
The LogManager for writing the transaction log |
| Fields inherited from class org.exist.storage.btree.Paged |
DELETED, LOG, OVERFLOW, PAGE_SIZE, UNUSED |
| Constructor Summary | |
protected |
BTree(BrokerPool pool,
byte fileId,
boolean transactional,
CacheManager cacheManager,
double growthThreshold)
|
|
BTree(BrokerPool pool,
byte fileId,
boolean transactional,
CacheManager cacheManager,
java.io.File file,
double growthThreshold)
|
| Method Summary | |
long |
addValue(Txn transaction,
Value value,
long pointer)
|
long |
addValue(Value value,
long pointer)
addValue adds a Value to the BTree and associates a pointer with it. |
boolean |
close()
Close the underlying files. |
void |
closeAndRemove()
Completely close down the instance and all underlying resources and caches. |
protected boolean |
create(short fixedKeyLen)
|
Paged.FileHeader |
createFileHeader()
createFileHeader must be implemented by a Paged implementation in order to create an appropriate subclass instance of a FileHeader. |
Paged.FileHeader |
createFileHeader(boolean read)
createFileHeader must be implemented by a Paged implementation in order to create an appropriate subclass instance of a FileHeader. |
Paged.FileHeader |
createFileHeader(long pageCount)
createFileHeader must be implemented by a Paged implementation in order to create an appropriate subclass instance of a FileHeader. |
Paged.FileHeader |
createFileHeader(long pageCount,
int pageSize)
createFileHeader must be implemented by a Paged implementation in order to create an appropriate subclass instance of a FileHeader. |
Paged.PageHeader |
createPageHeader()
createPageHeader must be implemented by a Paged implementation in order to create an appropriate subclass instance of a PageHeader. |
protected long |
createRootNode(Txn transaction)
Create the root node. |
void |
dump(java.io.Writer writer)
Print a dump of the tree to the given writer. |
protected void |
dumpValue(java.io.Writer writer,
Value value)
|
long |
findValue(Value value)
findValue finds a Value in the BTree and returns the associated pointer for it. |
boolean |
flush()
|
BufferStats |
getIndexBufferStats()
|
protected BTree.BTreeNode |
getRootNode()
|
boolean |
open(short expectedVersion)
|
void |
printStatistics()
|
void |
query(IndexQuery query,
BTreeCallback callback)
query performs a query against the BTree and performs callback operations to report the search results. |
void |
query(IndexQuery query,
Value prefix,
BTreeCallback callback)
Executes a query against the BTree and performs callback operations to report the search results. |
protected void |
redoCreateBTNode(CreateBTNodeLoggable loggable)
|
protected void |
redoInsertValue(InsertValueLoggable loggable)
|
protected void |
redoRemoveValue(RemoveValueLoggable loggable)
|
protected void |
redoSetParent(SetParentLoggable loggable)
|
protected void |
redoUpdatePage(UpdatePageLoggable loggable)
|
protected void |
redoUpdateValue(UpdateValueLoggable loggable)
|
void |
remove(IndexQuery query,
BTreeCallback callback)
|
void |
remove(Txn transaction,
IndexQuery query,
BTreeCallback callback)
Search for keys matching the given IndexQuery and
remove them from the node. |
long |
removeValue(Txn transaction,
Value value)
|
long |
removeValue(Value value)
removeValue removes a Value from the BTree and returns the associated pointer for it. |
protected boolean |
requiresRedo(Loggable loggable,
Paged.Page page)
|
protected void |
setRootNode(BTree.BTreeNode rootNode)
Set the root node of the tree. |
protected void |
undoInsertValue(InsertValueLoggable loggable)
|
protected void |
undoRemoveValue(RemoveValueLoggable loggable)
|
protected void |
undoUpdateValue(UpdateValueLoggable loggable)
|
| Methods inherited from class org.exist.storage.btree.Paged |
backupToStream, create, exists, getFile, getFileHeader, getFileVersion, getFreePage, getPage, getPageSize, hexDump, isOpened, isReadOnly, printFreeSpaceList, reuseDeleted, setFile, setPageSize, unlinkPages, unlinkPages, writeValue, writeValue, writeValue |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final long KEY_NOT_FOUND
protected static final byte LEAF
protected static final byte BRANCH
public static final byte LOG_INSERT_VALUE
public static final byte LOG_CREATE_BNODE
public static final byte LOG_UPDATE_PAGE
public static final byte LOG_SET_PARENT
public static final byte LOG_UPDATE_VALUE
public static final byte LOG_REMOVE_VALUE
protected CacheManager cacheManager
protected Cache cache
protected double growthThreshold
protected int buffers
protected Journal logManager
protected byte fileId
protected boolean isTransactional
| Constructor Detail |
protected BTree(BrokerPool pool,
byte fileId,
boolean transactional,
CacheManager cacheManager,
double growthThreshold)
throws DBException
public BTree(BrokerPool pool,
byte fileId,
boolean transactional,
CacheManager cacheManager,
java.io.File file,
double growthThreshold)
throws DBException
| Method Detail |
public boolean open(short expectedVersion)
throws DBException
open in class PagedDBException
protected boolean create(short fixedKeyLen)
throws DBException
DBExceptionpublic void closeAndRemove()
Paged
closeAndRemove in class Paged
public long addValue(Value value,
long pointer)
throws java.io.IOException,
BTreeException
value - The Value to addpointer - The pointer to associate with it
java.io.IOException - Description of the Exception
BTreeException - Description of the Exception
public long addValue(Txn transaction,
Value value,
long pointer)
throws java.io.IOException,
BTreeException
java.io.IOException
BTreeException
public long removeValue(Value value)
throws java.io.IOException,
BTreeException
value - The Value to remove
java.io.IOException - Description of the Exception
BTreeException - Description of the Exception
public long removeValue(Txn transaction,
Value value)
throws java.io.IOException,
BTreeException
java.io.IOException
BTreeException
public long findValue(Value value)
throws java.io.IOException,
BTreeException
value - The Value to find
java.io.IOException - Description of the Exception
BTreeException - Description of the Exception
public void query(IndexQuery query,
BTreeCallback callback)
throws java.io.IOException,
BTreeException,
TerminatedException
query - The IndexQuery to use (or null for everything)callback - The callback instance
java.io.IOException - Description of the Exception
BTreeException - Description of the Exception
TerminatedException
public void query(IndexQuery query,
Value prefix,
BTreeCallback callback)
throws java.io.IOException,
BTreeException,
TerminatedException
query - The IndexQuery to use (or null for everything)prefix - a prefix valuecallback - The callback instance
java.io.IOException
BTreeException
TerminatedException
public void remove(IndexQuery query,
BTreeCallback callback)
throws java.io.IOException,
BTreeException,
TerminatedException
java.io.IOException
BTreeException
TerminatedException
public void remove(Txn transaction,
IndexQuery query,
BTreeCallback callback)
throws java.io.IOException,
BTreeException,
TerminatedException
IndexQuery and
remove them from the node. Every match is reported
to the specified BTreeCallback.
query - callback -
java.io.IOException
BTreeException
TerminatedException
protected void setRootNode(BTree.BTreeNode rootNode)
throws java.io.IOException
rootNode -
java.io.IOException
protected long createRootNode(Txn transaction)
throws java.io.IOException
transaction -
java.io.IOExceptionprotected BTree.BTreeNode getRootNode()
public void dump(java.io.Writer writer)
throws java.io.IOException,
BTreeException
writer -
java.io.IOException
BTreeException
public boolean flush()
throws DBException
flush in class PagedDBException
public boolean close()
throws DBException
Paged
close in class PagedDBException
protected void dumpValue(java.io.Writer writer,
Value value)
throws java.io.IOException
java.io.IOException
protected boolean requiresRedo(Loggable loggable,
Paged.Page page)
protected void redoCreateBTNode(CreateBTNodeLoggable loggable)
throws LogException
LogException
protected void redoInsertValue(InsertValueLoggable loggable)
throws LogException
LogException
protected void undoInsertValue(InsertValueLoggable loggable)
throws LogException
LogException
protected void redoUpdateValue(UpdateValueLoggable loggable)
throws LogException
LogException
protected void undoUpdateValue(UpdateValueLoggable loggable)
throws LogException
LogException
protected void redoRemoveValue(RemoveValueLoggable loggable)
throws LogException
LogException
protected void undoRemoveValue(RemoveValueLoggable loggable)
throws LogException
LogException
protected void redoUpdatePage(UpdatePageLoggable loggable)
throws LogException
LogException
protected void redoSetParent(SetParentLoggable loggable)
throws LogException
LogExceptionpublic Paged.FileHeader createFileHeader()
Paged
createFileHeader in class PagedPaged.createFileHeader()
public Paged.FileHeader createFileHeader(boolean read)
throws java.io.IOException
Paged
createFileHeader in class Pagedread - If true, reads the FileHeader from disk
java.io.IOException - if an exception occursPaged.createFileHeader(boolean)public Paged.FileHeader createFileHeader(long pageCount)
Paged
createFileHeader in class PagedpageCount - The number of pages to allocate for primary storage
Paged.createFileHeader(long)
public Paged.FileHeader createFileHeader(long pageCount,
int pageSize)
Paged
createFileHeader in class PagedpageCount - The number of pages to allocate for primary storagepageSize - The size of a Page (should be a multiple of a FS block)
Paged.createFileHeader(long, int)public Paged.PageHeader createPageHeader()
Paged
createPageHeader in class PagedPaged.createPageHeader()public BufferStats getIndexBufferStats()
public void printStatistics()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||