|
||||||||||
| 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
org.exist.storage.dom.DOMFile
This is the main storage for XML nodes. Nodes are stored in document order.
Every document gets its own sequence of pages, which is bound to the writing
thread to avoid conflicting writes. The page structure is as follows:
| page header | (tid1 node-data, tid2 node-data, ..., tidn node-data) |
node-data contains the raw binary data of the node as returned by
org.exist.dom.NodeImpl#serialize(). Within a page, a node is
identified by a unique id, called tuple id (tid). Every node can thus be
located by a virtual address pointer, which consists of the page id and the
tid. Both components are encoded in a long value (with additional bits used
for optional flags). The address pointer is used to reference nodes from the
indexes. It should thus remain unchanged during the life-time of a document.
However, XUpdate requests may insert new nodes in the middle of a page. In
these cases, the page will be split and the upper portion of the page is
copied to a split page. The record in the original page will be replaced by a
forward link, pointing to the new location of the node data in the split
page.
As a consequence, the class has to distinguish three different types of data
records:
1) Ordinary record:
| tid | length | data |
3) Relocated record:
| tid | length | address pointer to original location | data |
2) Forward link:
| tid | address pointer |
tid and length each use two bytes (short), address pointers 8 bytes (long).
The upper two bits of the tid are used to indicate the type of the record
(see org.exist.storage.store.ItemId).
| Nested Class Summary | |
protected static class |
DOMFile.DOMFilePageHeader
|
protected class |
DOMFile.DOMPage
|
protected class |
DOMFile.OverflowDOMPage
This represents an overflow page. |
protected static class |
DOMFile.RecordPos
|
| Nested classes inherited from class org.exist.storage.btree.BTree |
BTree.BTreeFileHeader, BTree.BTreeNode, BTree.BTreePageHeader |
| Nested classes inherited from class org.exist.storage.btree.Paged |
Paged.FileHeader, Paged.Page, Paged.PageHeader |
| Field Summary | |
static long |
DATA_SYNC_PERIOD
|
static short |
FILE_FORMAT_VERSION_ID
|
static byte |
LOB
|
static byte |
LOG_ADD_LINK
|
static byte |
LOG_ADD_MOVED_REC
|
static byte |
LOG_ADD_VALUE
|
static byte |
LOG_CREATE_PAGE
|
static byte |
LOG_INSERT_RECORD
|
static byte |
LOG_REMOVE_EMPTY_PAGE
|
static byte |
LOG_REMOVE_OVERFLOW
|
static byte |
LOG_REMOVE_PAGE
|
static byte |
LOG_REMOVE_VALUE
|
static byte |
LOG_SPLIT_PAGE
|
static byte |
LOG_UPDATE_HEADER
|
static byte |
LOG_UPDATE_LINK
|
static byte |
LOG_UPDATE_VALUE
|
static byte |
LOG_WRITE_OVERFLOW
|
static short |
OVERFLOW
|
static byte |
RECORD
|
| Fields inherited from class org.exist.storage.btree.BTree |
BRANCH, buffers, cache, cacheManager, fileId, growthThreshold, isTransactional, KEY_NOT_FOUND, LEAF, LOG_CREATE_BNODE, LOG_INSERT_VALUE, LOG_SET_PARENT, LOG_UPDATE_PAGE, logManager |
| Fields inherited from class org.exist.storage.btree.Paged |
DELETED, LOG, PAGE_SIZE, UNUSED |
| Constructor Summary | |
DOMFile(BrokerPool pool,
java.io.File file,
CacheManager cacheManager)
|
|
| Method Summary | |
long |
add(Txn transact,
byte[] value)
Append a value to the current page. |
long |
addBinary(Txn transaction,
DocumentImpl doc,
byte[] value)
Store a raw binary resource into the file. |
void |
addToBuffer(DOMFile.DOMPage page)
|
boolean |
close()
Close the underlying files. |
void |
closeDocument()
|
boolean |
create()
|
Paged.FileHeader |
createFileHeader()
createFileHeader must be implemented by a Paged implementation in order to create an appropriate subclass instance of a FileHeader. |
protected Paged.Page |
createNewPage()
|
Paged.PageHeader |
createPageHeader()
createPageHeader must be implemented by a Paged implementation in order to create an appropriate subclass instance of a PageHeader. |
java.lang.String |
debugPageContents(DOMFile.DOMPage page)
|
java.lang.String |
debugPages(DocumentImpl doc,
boolean showPageContents)
|
protected void |
dumpValue(java.io.Writer writer,
Value key)
|
java.util.ArrayList |
findKeys(IndexQuery query)
|
protected DOMFile.RecordPos |
findRecord(long p)
|
protected DOMFile.RecordPos |
findRecord(long p,
boolean skipLinks)
Find a record within the page or the pages linked to it. |
protected long |
findValue(java.lang.Object lock,
NodeProxy node)
Find a node by searching for a known ancestor in the index. |
java.util.ArrayList |
findValues(IndexQuery query)
Find matching nodes for the given query. |
boolean |
flush()
Flush all buffers to disk. |
Value |
get(long p)
Retrieve node at virtual address p. |
Value |
get(NodeProxy node)
Retrieve a node described by the given NodeProxy. |
Value |
get(Value key)
Retrieve a node by key |
byte[] |
getBinary(long pageNum)
Return binary data stored with #addBinary(byte[]). |
protected DOMFile.DOMPage |
getCurrentPage(long p)
Retrieve the page with page number p |
BufferStats |
getDataBufferStats()
|
short |
getFileVersion()
|
Lock |
getLock()
Get the active Lock object for this file. |
java.lang.String |
getNodeValue(NodeProxy proxy,
boolean addWhitespace)
Retrieve the string value of the specified node. |
protected byte[] |
getOverflowValue(long pnum)
|
protected Cache |
getPageBuffer()
|
long |
insertAfter(Txn transaction,
DocumentImpl doc,
long address,
byte[] value)
Insert a new node after the node located at the specified address. |
long |
insertAfter(Txn transaction,
DocumentImpl doc,
Value key,
byte[] value)
Insert a new node after the specified node. |
boolean |
open()
Open the file. |
void |
printStatistics()
|
long |
put(Txn transaction,
Value key,
byte[] value)
Put a new key/value pair. |
protected void |
redoAddLink(AddLinkLoggable loggable)
|
protected void |
redoAddMovedValue(AddMovedValueLoggable loggable)
|
protected void |
redoAddValue(AddValueLoggable loggable)
|
protected void |
redoCreatePage(CreatePageLoggable loggable)
|
protected void |
redoInsertValue(InsertValueLoggable loggable)
|
protected void |
redoRemoveEmptyPage(RemoveEmptyPageLoggable loggable)
|
protected void |
redoRemoveOverflow(RemoveOverflowLoggable loggable)
|
protected void |
redoRemovePage(RemovePageLoggable loggable)
|
protected void |
redoRemoveValue(RemoveValueLoggable loggable)
|
protected void |
redoSplitPage(SplitPageLoggable loggable)
|
protected void |
redoUpdateHeader(UpdateHeaderLoggable loggable)
|
protected void |
redoUpdateLink(UpdateLinkLoggable loggable)
|
protected void |
redoUpdateValue(UpdateValueLoggable loggable)
|
protected void |
redoWriteOverflow(WriteOverflowPageLoggable loggable)
|
void |
remove(Txn transaction,
Value key)
|
void |
remove(Txn transaction,
Value key,
long p)
|
void |
remove(Value key)
Physically remove a node. |
void |
remove(Value key,
long p)
Physically remove a node. |
void |
removeAll(Txn transaction,
long p)
Remove a sequence of pages, starting with the page denoted by the passed address pointer p. |
void |
removeNode(long p)
Physically remove a node. |
void |
removeNode(Txn transaction,
long p)
|
void |
removeOverflowValue(Txn transaction,
long pnum)
|
void |
removePage(DOMFile.DOMPage page)
Remove the specified page. |
void |
setCurrentDocument(DocumentImpl doc)
|
void |
setOwnerObject(java.lang.Object obj)
The current object owning this file. |
protected void |
undoAddLink(AddLinkLoggable loggable)
|
protected void |
undoAddMovedValue(AddMovedValueLoggable loggable)
|
protected void |
undoAddValue(AddValueLoggable loggable)
|
protected void |
undoCreatePage(CreatePageLoggable loggable)
|
protected void |
undoInsertValue(InsertValueLoggable loggable)
|
protected void |
undoRemoveEmptyPage(RemoveEmptyPageLoggable loggable)
|
protected void |
undoRemoveOverflow(RemoveOverflowLoggable loggable)
|
protected void |
undoRemovePage(RemovePageLoggable loggable)
|
protected void |
undoRemoveValue(RemoveValueLoggable loggable)
|
protected void |
undoSplitPage(SplitPageLoggable loggable)
|
protected void |
undoUpdateHeader(UpdateHeaderLoggable loggable)
|
protected void |
undoUpdateLink(UpdateLinkLoggable loggable)
|
protected void |
undoUpdateValue(UpdateValueLoggable loggable)
|
protected void |
undoWriteOverflow(WriteOverflowPageLoggable loggable)
|
protected void |
unlinkPages(Paged.Page page)
unlinkPages unlinks a set of pages starting at the specified Page. |
void |
update(Txn transaction,
long p,
byte[] value)
Update the key/value pair where the value is found at address p. |
boolean |
update(Txn transaction,
Value key,
byte[] value)
Update the key/value pair. |
| Methods inherited from class org.exist.storage.btree.BTree |
addValue, addValue, closeAndRemove, create, createFileHeader, createFileHeader, createFileHeader, createRootNode, dump, findValue, getIndexBufferStats, getRootNode, open, query, query, redoCreateBTNode, redoInsertValue, redoRemoveValue, redoSetParent, redoUpdatePage, redoUpdateValue, remove, remove, removeValue, removeValue, requiresRedo, setRootNode, undoInsertValue, undoRemoveValue, undoUpdateValue |
| Methods inherited from class org.exist.storage.btree.Paged |
backupToStream, exists, getFile, getFileHeader, getFreePage, getPage, getPageSize, hexDump, isOpened, isReadOnly, printFreeSpaceList, reuseDeleted, setFile, setPageSize, 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 byte LOG_CREATE_PAGE
public static final byte LOG_ADD_VALUE
public static final byte LOG_REMOVE_VALUE
public static final byte LOG_REMOVE_EMPTY_PAGE
public static final byte LOG_UPDATE_VALUE
public static final byte LOG_REMOVE_PAGE
public static final byte LOG_WRITE_OVERFLOW
public static final byte LOG_REMOVE_OVERFLOW
public static final byte LOG_INSERT_RECORD
public static final byte LOG_SPLIT_PAGE
public static final byte LOG_ADD_LINK
public static final byte LOG_ADD_MOVED_REC
public static final byte LOG_UPDATE_HEADER
public static final byte LOG_UPDATE_LINK
public static final short FILE_FORMAT_VERSION_ID
public static final byte LOB
public static final byte RECORD
public static final short OVERFLOW
public static final long DATA_SYNC_PERIOD
| Constructor Detail |
public DOMFile(BrokerPool pool,
java.io.File file,
CacheManager cacheManager)
throws DBException
| Method Detail |
protected final Cache getPageBuffer()
public short getFileVersion()
getFileVersion in class Pagedpublic void setCurrentDocument(DocumentImpl doc)
public long add(Txn transact,
byte[] value)
throws ReadOnlyException
value - the value to append
ReadOnlyException
public long addBinary(Txn transaction,
DocumentImpl doc,
byte[] value)
value -
public byte[] getBinary(long pageNum)
#addBinary(byte[]).
pageNum -
public long insertAfter(Txn transaction,
DocumentImpl doc,
Value key,
byte[] value)
key - value -
public long insertAfter(Txn transaction,
DocumentImpl doc,
long address,
byte[] value)
doc - the document to which the new node belongs.address - the storage address of the node after which the new value
should be inserted.value - the value of the new node.
public java.lang.String debugPageContents(DOMFile.DOMPage page)
public boolean close()
throws DBException
Paged
close in class BTreeDBException
public boolean create()
throws DBException
create in class PagedDBExceptionpublic Paged.FileHeader createFileHeader()
Paged
createFileHeader in class BTreePaged.createFileHeader()protected Paged.Page createNewPage()
protected void unlinkPages(Paged.Page page)
throws java.io.IOException
Paged
unlinkPages in class Pagedpage - The starting Page to unlink
java.io.IOException - if an Exception occurspublic Paged.PageHeader createPageHeader()
Paged
createPageHeader in class BTreePaged.createPageHeader()
public java.util.ArrayList findKeys(IndexQuery query)
throws java.io.IOException,
BTreeException
java.io.IOException
BTreeException
protected long findValue(java.lang.Object lock,
NodeProxy node)
throws java.io.IOException,
BTreeException
lock - node -
java.io.IOException
BTreeException
public java.util.ArrayList findValues(IndexQuery query)
throws java.io.IOException,
BTreeException
query - Description of the Parameter
java.io.IOException - Description of the Exception
BTreeException - Description of the Exception
public boolean flush()
throws DBException
flush in class BTreeDBException - Description of the Exceptionpublic void printStatistics()
printStatistics in class BTreepublic BufferStats getDataBufferStats()
public Value get(Value key)
key -
public Value get(NodeProxy node)
node - Description of the Parameter
public Value get(long p)
p - Description of the Parameter
protected byte[] getOverflowValue(long pnum)
public void removeOverflowValue(Txn transaction,
long pnum)
protected final DOMFile.DOMPage getCurrentPage(long p)
p - Description of the Parameter
public void closeDocument()
public boolean open()
throws DBException
DBException - Description of the Exception
public long put(Txn transaction,
Value key,
byte[] value)
throws ReadOnlyException
key - Description of the Parametervalue - Description of the Parameter
ReadOnlyExceptionpublic void remove(Value key)
public void remove(Txn transaction,
Value key)
public void removeNode(long p)
p -
public void removeNode(Txn transaction,
long p)
public void remove(Value key,
long p)
public void remove(Txn transaction,
Value key,
long p)
public void removePage(DOMFile.DOMPage page)
page -
public void removeAll(Txn transaction,
long p)
transaction - p -
public java.lang.String debugPages(DocumentImpl doc,
boolean showPageContents)
public final Lock getLock()
getLock in interface LockableLockable.getLock()public final void setOwnerObject(java.lang.Object obj)
obj - The new ownerObject value
public boolean update(Txn transaction,
Value key,
byte[] value)
throws ReadOnlyException
key - Description of the Parametervalue - Description of the Parameter
ReadOnlyException
public void update(Txn transaction,
long p,
byte[] value)
throws ReadOnlyException
p - Description of the Parametervalue - Description of the Parameter
ReadOnlyException
public java.lang.String getNodeValue(NodeProxy proxy,
boolean addWhitespace)
proxy -
protected DOMFile.RecordPos findRecord(long p)
protected DOMFile.RecordPos findRecord(long p,
boolean skipLinks)
p -
protected void redoCreatePage(CreatePageLoggable loggable)
protected void undoCreatePage(CreatePageLoggable loggable)
protected void redoAddValue(AddValueLoggable loggable)
protected void undoAddValue(AddValueLoggable loggable)
protected void redoUpdateValue(UpdateValueLoggable loggable)
protected void undoUpdateValue(UpdateValueLoggable loggable)
protected void redoRemoveValue(RemoveValueLoggable loggable)
protected void undoRemoveValue(RemoveValueLoggable loggable)
protected void redoRemoveEmptyPage(RemoveEmptyPageLoggable loggable)
protected void undoRemoveEmptyPage(RemoveEmptyPageLoggable loggable)
protected void redoRemovePage(RemovePageLoggable loggable)
protected void undoRemovePage(RemovePageLoggable loggable)
protected void redoWriteOverflow(WriteOverflowPageLoggable loggable)
protected void undoWriteOverflow(WriteOverflowPageLoggable loggable)
protected void redoRemoveOverflow(RemoveOverflowLoggable loggable)
protected void undoRemoveOverflow(RemoveOverflowLoggable loggable)
protected void redoInsertValue(InsertValueLoggable loggable)
protected void undoInsertValue(InsertValueLoggable loggable)
protected void redoSplitPage(SplitPageLoggable loggable)
protected void undoSplitPage(SplitPageLoggable loggable)
protected void redoAddLink(AddLinkLoggable loggable)
protected void undoAddLink(AddLinkLoggable loggable)
protected void redoUpdateLink(UpdateLinkLoggable loggable)
protected void undoUpdateLink(UpdateLinkLoggable loggable)
protected void redoAddMovedValue(AddMovedValueLoggable loggable)
protected void undoAddMovedValue(AddMovedValueLoggable loggable)
protected void redoUpdateHeader(UpdateHeaderLoggable loggable)
protected void undoUpdateHeader(UpdateHeaderLoggable loggable)
protected void dumpValue(java.io.Writer writer,
Value key)
throws java.io.IOException
dumpValue in class BTreejava.io.IOExceptionpublic final void addToBuffer(DOMFile.DOMPage page)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||