Package org.basex.data
Class DiskData
java.lang.Object
org.basex.data.Data
org.basex.data.DiskData
This class stores and organizes the database table and the index structures
for textual content in a compressed disk structure.
The table mapping is documented in
Data.
Texts may be inlined on disk. The bits of the first byte of the 5-byte text reference can be
decoded as follows:
Bit 0 [INLINED] indicates if value is inlined in table or stored externally
Bit 1 [COMPRESSED] indicates if value is compressed
Bit 2 [STRING] indicates if an inlined value is a string
- INLINED (text is inlined):
- STRING (value is string):
- Bits 4-7 contain string length
- 32 remaining bits contain inlined string
- COMPRESSED: unpack and return inlined text
- NOT COMPRESSED: return text unchanged
- NOT STRING (value is integer):
- return 32 bits of remaining 4 bytes as integer
- NOT INLINED (text is stored externally):
- 38 remaining bits contain text reference
- COMPRESSED: unpack and return external text
- NOT COMPRESSED: return external text unchanged
- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen, Tim Petrowsky
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor, called fromOpen.open(java.lang.String, org.basex.core.Context, org.basex.core.MainOptions).Internal database constructor, called fromDiskBuilder.build(). -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the database.voidcreateIndex(IndexType type, Command cmd) Drops the specified index.protected voiddelete(int pre, boolean text) Deletes the specified text entry.voidDrops the specified index.voidfinishUpdate(MainOptions opts) Finishes an update operation: removes the update file and the exclusive lock.voidflush(boolean all) Flushes updated data.booleaninMemory()Indicates if this data instance is in main memory or on disk.voidstartUpdate(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.byte[]text(int pre, boolean text) Returns a text (text, comment, pi, document) or attribute value.doubletextDbl(int pre, boolean text) Returns a text (text, comment, pi, document) or attribute value as double value.longtextItr(int pre, boolean text) Returns a text (text, comment, pi, document) or attribute value as integer value.inttextLen(int pre, boolean text) Returns the byte length of a (possibly compressed) text (text, comment, pi, document).protected longtextRef(byte[] value, boolean text) Generates a reference for a text (text, comment, pi, pi, document) or attribute value.protected voidupdateText(int pre, byte[] value, int kind) Updates the specified text or attribute value.Methods inherited from class org.basex.data.Data
atom, attr, attSize, attValue, closed, costs, defaultNs, delete, dist, dist, doc, elem, id, id, index, indexAdd, indexDelete, info, insert, insert, insertAttr, iter, kind, name, nameId, namespaces, nsFlag, nsFlag, parent, pre, qname, replace, size, size, text, textRef, textRef, toString, update, update, uriId
-
Constructor Details
-
DiskData
Default constructor, called fromOpen.open(java.lang.String, org.basex.core.Context, org.basex.core.MainOptions).- Parameters:
meta- meta data- Throws:
IOException- I/O Exception
-
DiskData
public DiskData(MetaData meta, Names elemNames, Names attrNames, PathIndex paths, Namespaces nspaces) throws IOException Internal database constructor, called fromDiskBuilder.build().- Parameters:
meta- meta dataelemNames- element namesattrNames- attribute namespaths- path indexnspaces- namespaces- Throws:
IOException- I/O Exception
-
-
Method Details
-
close
public void close()Description copied from class:DataCloses the database. -
createIndex
Description copied from class:DataDrops the specified index.- Specified by:
createIndexin classData- Parameters:
type- index to be droppedcmd- calling command- Throws:
IOException- I/O exception
-
dropIndex
Description copied from class:DataDrops the specified index.- Specified by:
dropIndexin classData- Parameters:
type- index to be dropped- Throws:
BaseXException- database exception
-
startUpdate
Description copied from class:DataStarts an update operation: writes a file to disk to indicate that an update is going on, and exclusively locks the table file.- Specified by:
startUpdatein classData- Parameters:
opts- main options- Throws:
BaseXException- database exception
-
finishUpdate
Description copied from class:DataFinishes an update operation: removes the update file and the exclusive lock.- Specified by:
finishUpdatein classData- Parameters:
opts- main options
-
flush
public void flush(boolean all) Description copied from class:DataFlushes updated data. -
text
public byte[] text(int pre, boolean text) Description copied from class:DataReturns a text (text, comment, pi, document) or attribute value. -
textItr
public long textItr(int pre, boolean text) Description copied from class:DataReturns a text (text, comment, pi, document) or attribute value as integer value.Long.MIN_VALUEis returned if the input is no valid integer. -
textDbl
public double textDbl(int pre, boolean text) Description copied from class:DataReturns a text (text, comment, pi, document) or attribute value as double value.Double.NaNis returned if the input is no valid double. -
textLen
public int textLen(int pre, boolean text) Description copied from class:DataReturns the byte length of a (possibly compressed) text (text, comment, pi, document). -
inMemory
public boolean inMemory()Description copied from class:DataIndicates if this data instance is in main memory or on disk. -
delete
protected void delete(int pre, boolean text) Description copied from class:DataDeletes the specified text entry. -
updateText
protected void updateText(int pre, byte[] value, int kind) Description copied from class:DataUpdates the specified text or attribute value.- Specified by:
updateTextin classData- Parameters:
pre- pre valuevalue- contentkind- node kind
-
textRef
protected long textRef(byte[] value, boolean text) Description copied from class:DataGenerates a reference for a text (text, comment, pi, pi, document) or attribute value.
-