public abstract class Data extends Object
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.
Modifier and Type | Field and Description |
---|---|
static byte |
ATTR
Node kind: attribute (code:
3 ). |
Index |
attrIndex
Attribute value index.
|
Names |
attrNames
Attribute names.
|
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 ). |
Names |
elemNames
Element names.
|
Index |
ftxtIndex
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.
|
static byte |
TEXT
Node kind: text (code:
2 ). |
Index |
textIndex
Text index.
|
Modifier | Constructor and Description |
---|---|
protected |
Data(MetaData meta)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
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.
|
int |
costs(IndexToken token)
Returns a cost estimation for searching the specified token.
|
abstract void |
createIndex(IndexType type,
MainOptions options,
Command cmd)
Drops the specified index.
|
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.
|
abstract boolean |
dropIndex(IndexType type)
Drops the specified index.
|
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(MainOptions opts)
Finishes an update operation: removes the update file and the exclusive lock.
|
abstract void |
flush(boolean all)
Flushes updated data.
|
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,
MainOptions options)
Returns info on the specified index structure.
|
abstract 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 an index iterator for the specified token.
|
int |
kind(int pre)
|
int |
name(int pre)
Returns a reference to the name of an element, attribute or processing instruction.
|
byte[] |
name(int pre,
int kind)
Returns the name of an element, attribute or processing instruction.
|
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 for the specified id.
|
int[] |
pre(int[] ids,
int off,
int len)
Returns a pre value for the specified id.
|
void |
replace(int tpre,
DataClip source)
Rapid Replace implementation.
|
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 void |
startUpdate(MainOptions opts)
Starts an update operation: writes a file to disk to indicate that an update is
going on, and exclusively locks the table file.
|
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 (possibly compressed) text (text, comment, pi).
|
long |
textOff(int pre)
Returns the disk offset of a text (text, comment, pi) or attribute value.
|
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) the name of an element, attribute or processing instruction.
|
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.
|
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 final MetaData meta
public Names elemNames
public Names attrNames
public Namespaces nspaces
public PathSummary paths
public Index textIndex
public Index attrIndex
public Index ftxtIndex
public int pins
public boolean cache
protected Data(MetaData meta)
meta
- meta datapublic abstract void close()
public abstract void createIndex(IndexType type, MainOptions options, Command cmd) throws IOException
type
- index to be droppedoptions
- main optionscmd
- calling commandIOException
- I/O exceptionpublic abstract boolean dropIndex(IndexType type)
type
- index to be droppedpublic abstract void startUpdate(MainOptions opts) throws IOException
opts
- main optionsIOException
- I/O exceptionpublic abstract void finishUpdate(MainOptions opts)
opts
- main optionspublic abstract void flush(boolean all)
all
- flush all datapublic final IndexIterator iter(IndexToken token)
token
- index token referencepublic final int costs(IndexToken token)
token
- text to be foundpublic final byte[] info(IndexType type, MainOptions options)
type
- index typeoptions
- main optionspublic final byte[] atom(int pre)
pre
- pre valuepublic final int pre(int id)
id
- unique node id-1
if id was not foundpublic final int[] pre(int[] ids, int off, int len)
ids
- unique node idsoff
- start offsetlen
- number of idspublic final int id(int pre)
pre
- pre valuepublic final int kind(int pre)
pre
- pre valuepublic final int parent(int pre, int kind)
pre
- pre valuekind
- node kindpublic int dist(int pre, int kind)
pre
- pre valuekind
- node kindpublic final int size(int pre, int kind)
pre
- pre valuekind
- node kindpublic final int attSize(int pre, int kind)
pre
- pre valuekind
- node kindpublic final byte[] attValue(int att, int pre)
att
- the attribute id of the attribute to be foundpre
- pre valuenull
public final int name(int pre)
pre
- pre valuepublic final byte[] name(int pre, int kind)
pre
- pre valuekind
- node kindpublic final int uri(int pre, int kind)
pre
- pre valuekind
- node kindpublic final boolean nsFlag(int pre)
pre
- pre valuepublic final Atts ns(int pre)
pre
- pre valuepublic final long textOff(int pre)
pre
- pre valuepublic abstract byte[] text(int pre, boolean text)
pre
- pre valuetext
- text/attribute flagpublic abstract long textItr(int pre, boolean text)
Long.MIN_VALUE
is returned if the input is no valid integer.pre
- pre valuetext
- text/attribute flagpublic abstract double textDbl(int pre, boolean text)
Double.NaN
is returned if the input is no valid double.pre
- pre valuetext
- text/attribute flagpublic abstract int textLen(int pre, boolean text)
pre
- pre valuetext
- text/attribute flagpublic final void update(int pre, int kind, byte[] name, byte[] uri)
pre
- pre valuekind
- node kindname
- name of new element, attribute or processing instructionuri
- uripublic final void update(int pre, int kind, byte[] value)
pre
- pre value to be replacedkind
- node kindvalue
- value to be updated (element 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
- element 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 kindprotected abstract void indexDelete(int pre, int size)
pre
- pre value of the node to deletesize
- number of descendantspublic abstract boolean inMemory()
Copyright © 2005–2015 BaseX Team. All rights reserved.