|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Objectjava.util.Observable
org.exist.storage.DBBroker
org.exist.storage.NativeBroker
public class NativeBroker
Main class for the native XML storage backend.
By "native" it is meant file-based, embedded backend.
Provides access to all low-level operations required by
the database. Extends DBBroker.
Observer Design Pattern: role : this class is the subject (alias observable)
for various classes that generate indices for the database content :
| Nested Class Summary | |
|---|---|
static class |
NativeBroker.NodeRef
|
| Field Summary | |
|---|---|
static int |
BUFFERS
default buffer size setting |
static byte |
COLLECTIONS_DBX_ID
|
static String |
DEFAULT_DATA_DIR
|
static int |
DEFAULT_INDEX_DEPTH
|
static int |
DEFAULT_MIN_MEMORY
|
static int |
DEFAULT_NODES_BEFORE_MEMORY_CHECK
check available memory after storing DEFAULT_NODES_BEFORE_MEMORY_CHECK nodes |
static int |
DEFAULT_PAGE_SIZE
|
static byte |
DOM_DBX_ID
|
static byte |
ELEMENTS_DBX_ID
|
static int |
OFFSET_COLLECTION_ID
|
static int |
OFFSET_VALUE
|
static byte |
PREPEND_DB_ALWAYS
|
static byte |
PREPEND_DB_AS_NEEDED
|
static byte |
PREPEND_DB_NEVER
|
static String |
PROPERTY_INDEX_DEPTH
|
static String |
PROPERTY_MIN_FREE_MEMORY
|
static String |
PROPERTY_PAGE_SIZE
|
static long |
TEMP_FRAGMENT_TIMEOUT
|
static byte |
VALUES_DBX_ID
|
static byte |
WORDS_DBX_ID
|
| Fields inherited from class org.exist.storage.DBBroker |
|---|
customProperties, MATCH_EXACT, MATCH_REGEXP, MATCH_WILDCARDS, PROPERTY_XUPDATE_CONSISTENCY_CHECKS, PROPERTY_XUPDATE_FRAGMENTATION_FACTOR, PROPERTY_XUPDATE_GROWTH_FACTOR, ROOT_COLLECTION, ROOT_COLLECTION_NAME, SYSTEM_COLLECTION, TEMP_COLLECTION |
| Constructor Summary | |
|---|---|
NativeBroker(BrokerPool pool,
Configuration config)
initialize database; read configuration, etc. |
|
| Method Summary | |
|---|---|
void |
addObserver(Observer o)
|
void |
checkXMLResourceConsistency(DocumentImpl doc)
consistency Check of the database; useful after XUpdates; called if xupdate.consistency-checks is true in configuration |
void |
checkXMLResourceTree(DocumentImpl doc)
consistency Check of the database; useful after XUpdates; called by checkXMLResourceConsistency(DocumentImpl) |
void |
cleanUpTempCollection()
remove temporary collection |
void |
cleanUpTempResources()
remove all documents from temporary collection |
void |
closeDocument()
|
void |
copyCollection(Txn transaction,
Collection collection,
Collection destination,
XmldbURI newUri)
Copy a collection to the destination collection and rename it. |
void |
copyXMLResource(Txn transaction,
DocumentImpl doc,
Collection destination,
XmldbURI newName)
Copy a resource to the destination collection and rename it. |
void |
defragXMLResource(Txn transaction,
DocumentImpl doc)
Defragment pages of this document. |
void |
deleteObservers()
|
void |
dropCollectionIndex(Collection collection)
|
void |
endElement(StoredNode node,
NodePath currentPath,
String content,
boolean remove)
Update indexes for the given element node. |
void |
endRemove(Txn transaction)
Takes care of actually remove entries from the indices; must be called after one or more call to removeNode(Txn, StoredNode, NodePath, String). |
void |
flush()
Flush all data that has not been written before. |
DocumentSet |
getAllXMLResources(DocumentSet docs)
Adds all the documents in the database to the specified DocumentSet. |
byte[] |
getBinaryResource(BinaryDocument blob)
Retrieve the binary data stored under the resource descriptor BinaryDocument. |
Collection |
getCollection(XmldbURI uri)
Returns the database collection identified by the specified path. |
void |
getCollectionResources(Collection collection)
|
DOMFile |
getDOMFile()
|
ElementIndex |
getElementIndex()
|
short |
getFreeCollectionId(Txn transaction)
Get the next free collection id. |
int |
getFreeResourceId(Txn transaction)
Get the next unused document id. |
IndexSpec |
getIndexConfiguration()
|
short |
getNextCollectionId(Txn transaction)
Get the next available unique collection id. |
int |
getNextResourceId(Txn transaction,
Collection collection)
get next Free Doc Id |
Iterator |
getNodeIterator(StoredNode node)
Return a NodeIterator starting at the
specified node. |
String |
getNodeValue(StoredNode node,
boolean addWhitespace)
Get the string value of the specified node. |
Collection |
getOrCreateCollection(Txn transaction,
XmldbURI name)
Returns the database collection identified by the specified path. |
int |
getPageSize()
|
void |
getResourceMetadata(DocumentImpl document)
|
Serializer |
getSerializer()
Get an instance of the Serializer used for converting nodes back to XML. |
BTree |
getStorage(byte id)
|
byte[] |
getStorageFileIds()
|
SymbolTable |
getSymbols()
|
TextSearchEngine |
getTextEngine()
Get the TextSearchEngine associated with this broker. |
NativeValueIndex |
getValueIndex()
|
Document |
getXMLResource(XmldbURI fileName)
get a document by its file name. |
DocumentImpl |
getXMLResource(XmldbURI fileName,
int lockMode)
Return the document stored at the specified path. |
DocumentSet |
getXMLResourcesByDoctype(String doctypeName,
DocumentSet result)
Get all the documents in this database matching the given document-type's name. |
EmbeddedXMLStreamReader |
getXMLStreamReader(NodeProxy proxy,
boolean reportAttributes)
|
EmbeddedXMLStreamReader |
getXMLStreamReader(StoredNode node,
boolean reportAttributes)
|
void |
indexNode(Txn transaction,
StoredNode node,
NodePath currentPath)
Index a single node, which has been added through an XUpdate operation. |
void |
indexNode(Txn transaction,
StoredNode node,
NodePath currentPath,
int repairMode)
|
void |
insertNodeAfter(Txn transaction,
StoredNode previous,
StoredNode node)
Physically insert a node into the DOM storage. |
boolean |
isReadOnly()
Is the database running read-only? Returns false by default. |
void |
moveCollection(Txn transaction,
Collection collection,
Collection destination,
XmldbURI newName)
Move a collection and all its subcollections to another collection and rename it. |
void |
moveXMLResource(Txn transaction,
DocumentImpl doc,
Collection destination,
XmldbURI newName)
move Resource to another collection, with possible rename |
Serializer |
newSerializer()
|
StoredNode |
objectWith(Document doc,
NodeId nodeId)
Get a node with given owner document and id from the database. |
StoredNode |
objectWith(NodeProxy p)
|
Collection |
openCollection(XmldbURI uri,
int lockMode)
Open a collection for reading or writing. |
XmldbURI |
prepend(XmldbURI uri)
|
void |
readBinaryResource(BinaryDocument blob,
OutputStream os)
|
void |
reindexCollection(Collection collection,
int mode)
|
void |
reindexCollection(Txn transaction,
Collection collection,
int mode)
|
void |
reindexCollection(XmldbURI collectionName)
Reindex a collection. |
void |
removeAllNodes(Txn transaction,
StoredNode node,
NodePath currentPath,
StreamListener listener)
|
void |
removeBinaryResource(Txn transaction,
BinaryDocument blob)
Completely delete this binary document (descriptor and binary data). |
boolean |
removeCollection(Txn transaction,
Collection collection)
Remove the collection and all its subcollections from the database. |
void |
removeNode(Txn transaction,
StoredNode node,
NodePath currentPath,
String content)
Removes the Node Reference from the database. |
void |
removeXMLResource(Txn transaction,
DocumentImpl document,
boolean freeDocId)
|
void |
repair()
|
void |
saveCollection(Txn transaction,
Collection collection)
Saves the specified collection to storage. |
void |
shutdown()
Shut down the database instance. |
void |
storeBinaryResource(Txn transaction,
BinaryDocument blob,
byte[] data)
Stores the given data under the given binary resource descriptor (BinaryDocument). |
void |
storeBinaryResource(Txn transaction,
BinaryDocument blob,
InputStream is)
Stores the given data under the given binary resource descriptor (BinaryDocument). |
void |
storeNode(Txn transaction,
StoredNode node,
NodePath currentPath)
|
void |
storeNode(Txn transaction,
StoredNode node,
NodePath currentPath,
boolean fullTextIndex)
Store a node into the database. |
DocumentImpl |
storeTempResource(DocumentImpl doc)
store into the temporary collection of the database a given in-memory Document |
void |
storeXMLResource(Txn transaction,
DocumentImpl doc)
store Document entry into its collection. |
void |
sync(int syncEvent)
Sync dom and collection state data (pages) to disk. |
void |
updateNode(Txn transaction,
StoredNode node,
boolean reindex)
Update a node's data. |
| Methods inherited from class org.exist.storage.DBBroker |
|---|
addContentLoadingObserver, clearContentLoadingObservers, decReferenceCount, endElement, getBrokerPool, getConfiguration, getId, getIndexController, getReferenceCount, getUser, getXQueryService, incReferenceCount, indexNode, removeContentLoadingObserver, removeXMLResource, setId, setUser, toString |
| Methods inherited from class java.util.Observable |
|---|
countObservers, deleteObserver, hasChanged, notifyObservers, notifyObservers |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final byte PREPEND_DB_ALWAYS
public static final byte PREPEND_DB_NEVER
public static final byte PREPEND_DB_AS_NEEDED
public static final byte COLLECTIONS_DBX_ID
public static final byte ELEMENTS_DBX_ID
public static final byte VALUES_DBX_ID
public static final byte WORDS_DBX_ID
public static final byte DOM_DBX_ID
public static final String PROPERTY_PAGE_SIZE
public static final String PROPERTY_MIN_FREE_MEMORY
public static final String PROPERTY_INDEX_DEPTH
public static final String DEFAULT_DATA_DIR
public static final int DEFAULT_PAGE_SIZE
public static final int DEFAULT_INDEX_DEPTH
public static final int DEFAULT_MIN_MEMORY
public static final long TEMP_FRAGMENT_TIMEOUT
public static final int BUFFERS
public static final int DEFAULT_NODES_BEFORE_MEMORY_CHECK
public static int OFFSET_COLLECTION_ID
public static int OFFSET_VALUE
| Constructor Detail |
|---|
public NativeBroker(BrokerPool pool,
Configuration config)
throws EXistException
EXistException| Method Detail |
|---|
public void addObserver(Observer o)
addObserver in class Observablepublic void deleteObservers()
deleteObservers in class Observable
public void endElement(StoredNode node,
NodePath currentPath,
String content,
boolean remove)
endElement in class DBBrokernode - the current element nodecurrentPath - node path leading to the elementcontent - contains the string value of the element. Needed if a range index
is defined on it.public void endRemove(Txn transaction)
removeNode(Txn, StoredNode, NodePath, String).
endRemove in class DBBrokerpublic boolean isReadOnly()
DBBroker
isReadOnly in class DBBrokerpublic int getPageSize()
getPageSize in class DBBrokerpublic DOMFile getDOMFile()
public BTree getStorage(byte id)
public byte[] getStorageFileIds()
public SymbolTable getSymbols()
getSymbols in class DBBrokerpublic IndexSpec getIndexConfiguration()
getIndexConfiguration in class DBBrokerpublic ElementIndex getElementIndex()
getElementIndex in class DBBrokerpublic NativeValueIndex getValueIndex()
getValueIndex in class DBBrokerpublic TextSearchEngine getTextEngine()
DBBroker
getTextEngine in class DBBroker
public EmbeddedXMLStreamReader getXMLStreamReader(StoredNode node,
boolean reportAttributes)
throws IOException,
javax.xml.stream.XMLStreamException
getXMLStreamReader in class DBBrokerIOException
javax.xml.stream.XMLStreamException
public EmbeddedXMLStreamReader getXMLStreamReader(NodeProxy proxy,
boolean reportAttributes)
throws IOException,
javax.xml.stream.XMLStreamException
getXMLStreamReader in class DBBrokerIOException
javax.xml.stream.XMLStreamExceptionpublic Iterator getNodeIterator(StoredNode node)
DBBrokerNodeIterator starting at the
specified node.
getNodeIterator in class DBBrokerpublic Serializer getSerializer()
DBBroker
getSerializer in class DBBrokerpublic Serializer newSerializer()
newSerializer in class DBBrokerpublic XmldbURI prepend(XmldbURI uri)
public void cleanUpTempCollection()
throws IOException
cleanUpTempCollection in class DBBrokerIOException
public Collection getOrCreateCollection(Txn transaction,
XmldbURI name)
throws PermissionDeniedException,
IOException
DBBroker
getOrCreateCollection in class DBBrokertransaction - The transaction, which registers the acquired write locks. The locks should be released on commit/abort.name - The collection's URI
null if no collection matches the path
PermissionDeniedException
IOExceptionpublic Collection getCollection(XmldbURI uri)
DBBroker
getCollection in class DBBroker
public Collection openCollection(XmldbURI uri,
int lockMode)
DBBroker
openCollection in class DBBrokeruri - The collection pathlockMode - one of the modes specified in class
Lock
public void copyCollection(Txn transaction,
Collection collection,
Collection destination,
XmldbURI newUri)
throws PermissionDeniedException,
LockException,
IOException
DBBroker
copyCollection in class DBBrokercollection - the resource to movedestination - the destination collectionnewUri - the new name the resource should have in the destination
collection
PermissionDeniedException
LockException
IOException
public void moveCollection(Txn transaction,
Collection collection,
Collection destination,
XmldbURI newName)
throws PermissionDeniedException,
LockException,
IOException
DBBroker
moveCollection in class DBBrokercollection - the collection to movedestination - the destination collectionnewName - the new name the collection should have in the destination
collection
PermissionDeniedException
LockException
IOException
public boolean removeCollection(Txn transaction,
Collection collection)
throws PermissionDeniedException,
IOException
DBBroker
removeCollection in class DBBrokerPermissionDeniedException
IOException
public void saveCollection(Txn transaction,
Collection collection)
throws PermissionDeniedException,
IOException
saveCollection in class DBBrokercollection - Collection to store
PermissionDeniedException
IOException
public short getFreeCollectionId(Txn transaction)
throws ReadOnlyException
ReadOnlyException
public short getNextCollectionId(Txn transaction)
throws ReadOnlyException
ReadOnlyException
public void reindexCollection(XmldbURI collectionName)
throws PermissionDeniedException
DBBroker
reindexCollection in class DBBrokerPermissionDeniedException - public abstract void reindexCollection(String collectionName) throws
PermissionDeniedException;
public void reindexCollection(Collection collection,
int mode)
throws PermissionDeniedException
PermissionDeniedException
public void reindexCollection(Txn transaction,
Collection collection,
int mode)
throws PermissionDeniedException
PermissionDeniedException
public void dropCollectionIndex(Collection collection)
throws PermissionDeniedException
PermissionDeniedException
public DocumentImpl storeTempResource(DocumentImpl doc)
throws EXistException,
PermissionDeniedException,
LockException
storeTempResource in class DBBrokerEXistException
PermissionDeniedException
LockExceptionpublic void cleanUpTempResources()
cleanUpTempResources in class DBBroker
public void storeXMLResource(Txn transaction,
DocumentImpl doc)
storeXMLResource in class DBBrokerdoc - the document's metadata to store.
public void storeBinaryResource(Txn transaction,
BinaryDocument blob,
byte[] data)
DBBroker
storeBinaryResource in class DBBrokerblob - the binary document descriptordata - the document binary data
public void storeBinaryResource(Txn transaction,
BinaryDocument blob,
InputStream is)
DBBroker
storeBinaryResource in class DBBrokerblob - the binary document descriptoris - the document binary data as input stream
public Document getXMLResource(XmldbURI fileName)
throws PermissionDeniedException
getXMLResource in class DBBrokerfileName - absolute file name in the database;
name can be given with or without the leading path /db/shakespeare.
PermissionDeniedException
public DocumentImpl getXMLResource(XmldbURI fileName,
int lockMode)
throws PermissionDeniedException
DBBroker
getXMLResource in class DBBrokerPermissionDeniedExceptionpublic byte[] getBinaryResource(BinaryDocument blob)
DBBroker
getBinaryResource in class DBBrokerblob - the binary document descriptor
public void readBinaryResource(BinaryDocument blob,
OutputStream os)
readBinaryResource in class DBBrokerpublic void getCollectionResources(Collection collection)
getCollectionResources in class DBBroker
public DocumentSet getXMLResourcesByDoctype(String doctypeName,
DocumentSet result)
getXMLResourcesByDoctype in class DBBrokerpublic DocumentSet getAllXMLResources(DocumentSet docs)
getAllXMLResources in class DBBrokerdocs - a (possibly empty) document set to which the found
documents are added.public void getResourceMetadata(DocumentImpl document)
getResourceMetadata in class DBBroker
public void copyXMLResource(Txn transaction,
DocumentImpl doc,
Collection destination,
XmldbURI newName)
throws PermissionDeniedException,
LockException
DBBroker
copyXMLResource in class DBBrokerdoc - the resource to copydestination - the destination collectionnewName - the new name the resource should have in the destination
collection
PermissionDeniedException
LockException
public void moveXMLResource(Txn transaction,
DocumentImpl doc,
Collection destination,
XmldbURI newName)
throws PermissionDeniedException,
LockException,
IOException
moveXMLResource in class DBBrokerdoc - the resource to movedestination - the destination collectionnewName - the new name the resource should have in the destination
collection
PermissionDeniedException
LockException
IOException
public void removeXMLResource(Txn transaction,
DocumentImpl document,
boolean freeDocId)
throws PermissionDeniedException
removeXMLResource in class DBBrokerPermissionDeniedException
public void removeBinaryResource(Txn transaction,