|
||||||||
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. 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 ItemId
).
Nested Class Summary |
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 |
KEY_NOT_FOUND, LOG_CREATE_BNODE, LOG_INSERT_VALUE, LOG_SET_PARENT, LOG_UPDATE_PAGE |
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. |
long |
addBinary(Txn transaction,
DocumentImpl doc,
java.io.InputStream is)
Store a raw binary resource into the file. |
void |
addToBuffer(org.exist.storage.dom.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. |
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(org.exist.storage.dom.DOMFile.DOMPage page)
|
java.lang.String |
debugPages(DocumentImpl doc,
boolean showPageContents)
|
java.util.ArrayList |
findKeys(IndexQuery query)
|
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(Txn, DocumentImpl, byte[]) . |
BufferStats |
getDataBufferStats()
|
short |
getFileVersion()
|
Lock |
getLock()
Get the active Lock object for this file. |
java.lang.String |
getNodeValue(StoredNode node,
boolean addWhitespace)
Retrieve the string value of the specified node. |
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. |
void |
readBinary(long pageNum,
java.io.OutputStream os)
|
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(org.exist.storage.dom.DOMFile.DOMPage page)
Remove the specified page. |
void |
setCurrentDocument(DocumentImpl doc)
|
void |
setOwnerObject(java.lang.Object obj)
The current object owning this file. |
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, createFileHeader, createFileHeader, createFileHeader, dump, findValue, getIndexBufferStats, open, query, query, remove, remove, removeValue, removeValue |
Methods inherited from class org.exist.storage.btree.Paged |
backupToStream, exists, getFile, getFileHeader, getPageSize, hexDump, isOpened, isReadOnly, printFreeSpaceList, setPageSize |
Methods inherited from class java.lang.Object |
equals, 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 |
public short getFileVersion()
getFileVersion
in class Paged
public 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
- Binary resource as byte arraypublic long addBinary(Txn transaction, DocumentImpl doc, java.io.InputStream is)
is
- Binary resource as stream.public byte[] getBinary(long pageNum)
addBinary(Txn, DocumentImpl, byte[])
.
pageNum
- public void readBinary(long pageNum, java.io.OutputStream os)
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(org.exist.storage.dom.DOMFile.DOMPage page)
public boolean close() throws DBException
Paged
close
in class BTree
DBException
public boolean create() throws DBException
create
in class Paged
DBException
public Paged.FileHeader createFileHeader()
Paged
createFileHeader
in class BTree
Paged.createFileHeader()
public Paged.PageHeader createPageHeader()
Paged
createPageHeader
in class BTree
Paged.createPageHeader()
public java.util.ArrayList findKeys(IndexQuery query) throws java.io.IOException, BTreeException
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 Exceptionpublic boolean flush() throws DBException
flush
in class BTree
DBException
- Description of the Exceptionpublic void printStatistics()
printStatistics
in class BTree
public 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
public void removeOverflowValue(Txn transaction, long pnum)
public void closeDocument()
public boolean open() throws DBException
DBException
- Description of the Exceptionpublic long put(Txn transaction, Value key, byte[] value) throws ReadOnlyException
key
- Description of the Parametervalue
- Description of the Parameter
ReadOnlyException
public 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(org.exist.storage.dom.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 Lockable
Lockable.getLock()
public final void setOwnerObject(java.lang.Object obj)
obj
- The new ownerObject valuepublic 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
transaction
- p
- value
-
ReadOnlyException
public java.lang.String getNodeValue(StoredNode node, boolean addWhitespace)
node
-
public final void addToBuffer(org.exist.storage.dom.DOMFile.DOMPage page)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |