|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.basex.data.Data
public abstract class Data
This class represents a database instance. It provides low-level access to all
properties and values stored in a single database.
An XML node is accessed by its pre
value, which is not stored itself, but
given by the table position. The following restrictions are imposed on the data:
COMMON ATTRIBUTES: - Byte 0: KIND: Node kind (bits: 2-0) - Byte 12-15: UNID: Unique Node ID DOCUMENT NODES (kind = 0): - Byte 3- 7: TEXT: Text reference - Byte 8-11: SIZE: Number of descendants ELEMENT NODES (kind = 1): - Byte 0: ATTS: Number of attributes (bits: 7-3). Calculated in real-time, if bit range is too small - Byte 1- 2: NAME: Namespace Flag (bit: 15), Name (bits: 14-0) - Byte 3: NURI: Namespace URI - Byte 4- 7: DIST: Distance to parent node - Byte 8-11: SIZE: Number of descendants TEXT, COMMENT, PI NODES (kind = 2, 4, 5): - Byte 3- 7: TEXT: Text reference - Byte 8-11: DIST: Distance to parent node ATTRIBUTE NODES (kind = 3): - Byte 0: DIST: Distance to parent node (bits: 7-3) Calculated in real-time, if bit range is too small - Byte 1- 2: NAME: Namespace Flag (bit: 15), Name (bits: 14-0) - Byte 3- 7: TEXT: Attribute value reference - Byte 11: NURI: Namespace (bits: 7-3)As all methods of this class are optimized for performance, no checks are performed on the arguments (e.g.: if the string value of a text node is requested, the specified pre value must point to a text node). NOTE: the class is not thread-safe. It is imperative that all read/write accesses are synchronized over a single context's read/write lock.
Field Summary | |
---|---|
Names |
atnindex
Attribute name index. |
static byte |
ATTR
Node kind: attribute (code: 3 ). |
Index |
atvindex
Attribute value index. |
boolean |
cache
States if distance caching is active. |
static byte |
COMM
Node kind: comment (code: 4 ). |
static byte |
DOC
Node kind: document (code: 0 ). |
static byte |
ELEM
Node kind: element (code: 1 ). |
Index |
ftxindex
Full-text index instance. |
MetaData |
meta
Meta data. |
Namespaces |
nspaces
Namespace index. |
PathSummary |
paths
Path summary index. |
static byte |
PI
Node kind: processing instruction (code: 5 ). |
int |
pins
Number of current database users. |
Resources |
resources
Resource index. |
Names |
tagindex
Tag index. |
static byte |
TEXT
Node kind: text (code: 2 ). |
Index |
txtindex
Text index. |
Constructor Summary | |
---|---|
Data()
|
Method Summary | |
---|---|
byte[] |
atom(int pre)
Returns an atomized content for any node kind. |
void |
attr(int pre,
int dist,
int name,
byte[] value,
int uri,
boolean ne)
Adds an attribute entry to the internal update buffer. |
int |
attSize(int pre,
int kind)
Returns a number of attributes. |
byte[] |
attValue(int att,
int pre)
Finds the specified attribute and returns its value. |
abstract void |
close()
Closes the database. |
abstract void |
closeIndex(IndexType type)
Closes the specified index. |
int |
count(IndexToken token)
Returns the number of indexed pre references for the specified token. |
void |
delete(int pre)
Deletes a node and its descendants. |
protected abstract void |
delete(int pre,
boolean text)
Deletes the specified text entry. |
int |
dist(int pre,
int kind)
Returns the distance of the specified node. |
void |
dist(int pre,
int kind,
int value)
Sets the distance. |
void |
doc(int pre,
int size,
byte[] value)
Adds a document entry to the internal update buffer. |
void |
elem(int dist,
int name,
int asize,
int size,
int uri,
boolean ne)
Adds an element entry to the internal update buffer. |
abstract void |
finishUpdate()
Finishes an update operation: removes the update file and the exclusive lock. |
int |
id(int pre)
Returns a unique node id. |
protected abstract long |
index(int pre,
int id,
byte[] value,
int kind)
Indexes a text and returns the reference. |
protected abstract void |
indexDelete(int pre,
int size)
Delete a node and its descendants from the corresponding indexes. |
byte[] |
info(IndexType type)
Returns info on the specified index structure. |
boolean |
inMemory()
Indicates if this data instance is in main memory or on disk. |
void |
insert(int pre)
Inserts the internal buffer to the storage without updating the table structure. |
void |
insert(int tpre,
int tpar,
DataClip source)
Inserts a data instance at the specified pre value. |
void |
insertAttr(int pre,
int par,
DataClip source)
Inserts attributes. |
IndexIterator |
iter(IndexToken token)
Returns the indexed pre references for the specified token. |
int |
kind(int pre)
Returns the node kind, which may be DOC , ELEM , TEXT ,
ATTR , COMM or PI . |
int |
name(int pre)
Returns a reference to the tag or attribute name id. |
byte[] |
name(int pre,
int kind)
Returns a tag, attribute or pi name. |
Atts |
ns(int pre)
Returns all namespace keys and values. |
boolean |
nsFlag(int pre)
Returns the namespace flag of the addressed element. |
void |
nsFlag(int pre,
boolean ne)
Sets the namespace flag. |
int |
parent(int pre,
int kind)
Returns a pre value of the parent node. |
int |
pre(int id)
Returns a pre value. |
int[] |
pre(int[] ids,
int off,
int len)
Returns pre values. |
void |
replace(int tpre,
DataClip source)
Replaces parts of the database with the specified data instance. |
abstract void |
setIndex(IndexType type,
Index index)
Assigns the specified index. |
int |
size(int pre,
int kind)
Returns a size value (number of descendant table entries). |
void |
size(int pre,
int kind,
int value)
Sets the size value. |
abstract boolean |
startUpdate()
Starts an update operation: writes a file to disk to indicate that an update is going on, and exclusively locks the table. |
abstract byte[] |
text(int pre,
boolean text)
Returns a text (text, comment, pi) or attribute value. |
void |
text(int pre,
int dist,
byte[] value,
int kind)
Adds a text entry to the internal update buffer. |
abstract double |
textDbl(int pre,
boolean text)
Returns a text (text, comment, pi) or attribute value as double value. |
abstract long |
textItr(int pre,
boolean text)
Returns a text (text, comment, pi) or attribute value as integer value. |
abstract int |
textLen(int pre,
boolean text)
Returns the byte length of a text (text, comment, pi). |
java.lang.String |
toString()
|
void |
update(int pre,
int kind,
byte[] value)
Updates (replaces) the value of a single document, text, comment, pi or attribute node. |
void |
update(int pre,
int kind,
byte[] name,
byte[] uri)
Updates (renames) an element, attribute or pi name. |
protected abstract void |
updateText(int pre,
byte[] value,
int kind)
Updates the specified text or attribute value. |
int |
uri(int pre,
int kind)
Returns a reference to the namespace of the addressed element or attribute. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final byte DOC
0
).
public static final byte ELEM
1
).
public static final byte TEXT
2
).
public static final byte ATTR
3
).
public static final byte COMM
4
).
public static final byte PI
5
).
public final Resources resources
public MetaData meta
public Names tagindex
public Names atnindex
public Namespaces nspaces
public PathSummary paths
public Index txtindex
public Index atvindex
public Index ftxindex
public int pins
public boolean cache
Constructor Detail |
---|
public Data()
Method Detail |
---|
public abstract void close()
public abstract void closeIndex(IndexType type)
type
- index to be closedpublic abstract void setIndex(IndexType type, Index index)
type
- index to be openedindex
- index instancepublic abstract boolean startUpdate()
public abstract void finishUpdate()
public final IndexIterator iter(IndexToken token)
token
- index token reference
public final int count(IndexToken token)
token
- text to be found
public final byte[] info(IndexType type)
type
- index type
public final byte[] atom(int pre)
pre
- pre value
public final int pre(int id)
id
- unique node id
public final int[] pre(int[] ids, int off, int len)
ids
- unique node idsoff
- start offsetlen
- number of ids
public final int id(int pre)
pre
- pre value
public final int kind(int pre)
DOC
, ELEM
, TEXT
,
ATTR
, COMM
or PI
.
pre
- pre value
public final int parent(int pre, int kind)
pre
- pre valuekind
- node kind
public int dist(int pre, int kind)
pre
- pre valuekind
- node kind
public final int size(int pre, int kind)
pre
- pre valuekind
- node kind
public final int attSize(int pre, int kind)
pre
- pre valuekind
- node kind
public final byte[] attValue(int att, int pre)
att
- the attribute id of the attribute to be foundpre
- pre value
public final int name(int pre)
pre
- pre value
public final byte[] name(int pre, int kind)
pre
- pre valuekind
- node kind
public final int uri(int pre, int kind)
pre
- pre valuekind
- node kind
public final boolean nsFlag(int pre)
pre
- pre value
public final Atts ns(int pre)
pre
- pre value
public abstract byte[] text(int pre, boolean text)
pre
- pre valuetext
- text/attribute flag
public abstract long textItr(int pre, boolean text)
pre
- pre valuetext
- text/attribute flag
public abstract double textDbl(int pre, boolean text)
pre
- pre valuetext
- text/attribute flag
public abstract int textLen(int pre, boolean text)
pre
- pre valuetext
- text/attribute flag
public final void update(int pre, int kind, byte[] name, byte[] uri)
pre
- pre valuekind
- node kindname
- new tag, attribute or pi nameuri
- uripublic final void update(int pre, int kind, byte[] value)
pre
- pre value to be replacedkind
- node kindvalue
- value to be updated (tag name, text, comment, pi)public final void replace(int tpre, DataClip source)
tpre
- pre value of target node to be replacedsource
- clip with source datapublic final void delete(int pre)
pre
- pre value of the node to deletepublic final void insertAttr(int pre, int par, DataClip source)
pre
- pre valuepar
- parent of nodesource
- clip with source datapublic final void insert(int tpre, int tpar, DataClip source)
tpre
- target pre valuetpar
- target parent pre value of node (-1
if document is added)source
- clip with source datapublic final void size(int pre, int kind, int value)
pre
- pre referencekind
- node kindvalue
- value to be storedprotected abstract void updateText(int pre, byte[] value, int kind)
pre
- pre valuevalue
- contentkind
- node kindpublic void dist(int pre, int kind, int value)
pre
- pre valuekind
- node kindvalue
- valuepublic final void nsFlag(int pre, boolean ne)
pre
- pre valuene
- namespace flagpublic final void insert(int pre)
pre
- insert positionprotected abstract void delete(int pre, boolean text)
pre
- pre valuetext
- text (text, comment or pi) or attribute flagpublic final void doc(int pre, int size, byte[] value)
pre
- pre valuesize
- node sizevalue
- document namepublic final void elem(int dist, int name, int asize, int size, int uri, boolean ne)
dist
- parent distancename
- tag name indexasize
- number of attributessize
- node sizeuri
- namespace uri referencene
- namespace flagpublic final void text(int pre, int dist, byte[] value, int kind)
pre
- pre valuedist
- parent distancevalue
- string valuekind
- node kindpublic final void attr(int pre, int dist, int name, byte[] value, int uri, boolean ne)
pre
- pre valuedist
- parent distancename
- attribute namevalue
- attribute valueuri
- namespace uri referencene
- namespace flag (only true
if this is a stand-alone attribute)protected abstract long index(int pre, int id, byte[] value, int kind)
pre
- pre valueid
- id valuevalue
- text to be indexedkind
- node kind
protected abstract void indexDelete(int pre, int size)
pre
- pre value of the node to deletesize
- number of descendantspublic final boolean inMemory()
public final java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |