Overview | Package | Class | Use | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.basex.data
Class DiskData

    java.lang.Object
      org.basex.data.Data
          org.basex.data.DiskData

    public final class DiskData

extends Data

This class stores and organizes the node table and the index structures for textual content. All nodes in the table are accessed by their implicit pre value. Some restrictions on the data are currently given:

- The table is limited to 2^31 entries (pre values are signed int's)
- A maximum of 2^16 different tag and attribute names is allowed
- A tag can have a maximum of 256 attributes

Each node occupies 128 bits. The current storage layout looks like follows:

      ELEMENTS:
     - Byte     0: Node kind (TAG)
     - Byte   1-2: Tag Reference
     - Byte     3: Number of attributes
     - Byte  4- 7: Number of descendants (size)
     - Byte  8-11: Relative parent reference
     - Byte 12-15: Unique Node ID
     TEXT NODES:
     - Byte     0: Node kind (TEXT/PI/COMM)
     - Byte  3- 7: Text reference
     - Byte  8-11: Relative parent reference
     - Byte 12-15: Unique Node ID
     ATTRIBUTE NODES:
     - Byte     0: Node kind (ATTR)
     - Byte   1-2: Attribute name reference
     - Byte  3- 7: Attribute value reference
     - Byte    11: Relative parent reference
     - Byte 12-15: Unique Node ID

Author:
  Workgroup DBIS, University of Konstanz 2005-07, ISC License, Christian Gruen, Tim Petrowsky

Field Summary

Fields inherited from class org.basex.data.Data
`ATTR, atts, COMM, contentID, deepfs, dirID, DOC, ELEM, fileID, meta, nameID, PI, size, sizeID, suffixID, tags, TEXT, timeID`

Constructor Summary
`DiskData(java.lang.String db)` Default Constructor.
`DiskData(java.lang.String db, boolean index)` Constructor, specifying if indexes are to be opened as well.

Method Summary
`int` | `attNameID(int pre)` Returns an attribute name id (reference to the attribute name index).
`double` | `attNum(int pre)` Returns an attribute value as double value.
`int` | `attSize(int pre, int kind)` Returns a number of attributes.
`byte[]` | `attValue(int pre)` Returns an attribute value.
`void` | `close()` Closes the current database.
`void` | `closeIndex(Index.TYPE index)` Closes the specified index.
`void` | `cls()` Closes the database without writing data back to disk.
`void` | `delete(int pre)` Deletes a node and its descendants.
`void` | `flush()` Flushes the table data.
`int[][]` | `ftIDs(byte[] word, FTOption ftO)` Returns the indexed id references for the specified fulltext token.
`int` | `id(int pre)` Returns a unique node id.
`void` | `info(PrintOutput out)` Returns info on the index structures.
`void` | `insert(int pre, int par, byte[] val, byte kind)` Inserts a tag name, text node, comment or processing instruction.
`void` | `insert(int pre, int par, byte[] name, byte[] val)` Inserts an attribute.
`void` | `insert(int pre, int par, Data td)` Insert a data instance at the specified pre value.
`int` | `kind(int pre)` Returns a node kind.
`int` | `nrFTIDs(byte[] token)` Returns the number of indexed id references for the specified token.
`void` | `openIndex(Index.TYPE type, Index index)` Opens the specified index.
`int` | `parent(int pre, int kind)` Returns a pre value of the parent node.
`int` | `pre(int id)` Returns a pre value.
`int` | `size(int pre, int kind)` Returns a size value (number of descendant table entries).
`int` | `tagID(int pre)` Returns a tag id (reference to the tag index).
`byte[]` | `text(int pre)` Returns a text.
`int` | `textLen(int pre)` Returns a text length.
`double` | `textNum(int pre)` Returns a text as double value.
`void` | `update(int pre, byte[] value)` Updates a tag name, text node, comment or processing instruction.
`void` | `update(int pre, byte[] name, byte[] val)` Updates an attribute name and value.

Methods inherited from class org.basex.data.Data
`atom, atomNum, attName, attNameID, attValue, ids, initNames, noLeaf, nrIDs, nrTags, tag, tagID`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DiskData

    public DiskData(java.lang.String db)
             throws java.io.IOException

  Default Constructor.

  Parameters:
    `db` - name of database
  Throws:
    `java.io.IOException` - IO Exception

### DiskData

    public DiskData(java.lang.String db,
                    boolean index)
             throws java.io.IOException

  Constructor, specifying if indexes are to be opened as well.

  Parameters:
    `db` - name of database
    `index` - open indexes
  Throws:
    `java.io.IOException` - IO Exception

Method Detail

### attNameID

    public int attNameID(int pre)

  Description copied from class: `Data`
  Returns an attribute name id (reference to the attribute name index).

  Specified by:
    `attNameID` in class `Data`
  Parameters:
    `pre` - pre value
  Returns:
    token reference

### attNum

    public double attNum(int pre)

  Description copied from class: `Data`
  Returns an attribute value as double value.

  Specified by:
    `attNum` in class `Data`
  Parameters:
    `pre` - pre value
  Returns:
    numeric value

### attSize

    public int attSize(int pre,
                       int kind)

  Description copied from class: `Data`
  Returns a number of attributes.

  Specified by:
    `attSize` in class `Data`
  Parameters:
    `pre` - pre value
    `kind` - node kind
  Returns:
    number of attributes

### attValue

    public byte[] attValue(int pre)

  Description copied from class: `Data`
  Returns an attribute value.

  Specified by:
    `attValue` in class `Data`
  Parameters:
    `pre` - pre value
  Returns:
    atomized value

### close

    public void close()
               throws java.io.IOException

  Description copied from class: `Data`
  Closes the current database.

  Specified by:
    `close` in class `Data`
  Throws:
    `java.io.IOException` - in case the database could not be closed

### closeIndex

    public void closeIndex(Index.TYPE index)
                    throws java.io.IOException

  Description copied from class: `Data`
  Closes the specified index.

  Specified by:
    `closeIndex` in class `Data`
  Parameters:
    `index` - index to be closed
  Throws:
    `java.io.IOException` - in case the index could not be closed

### cls

    public void cls()
             throws java.io.IOException

  Closes the database without writing data back to disk.

  Throws:
    `java.io.IOException` - I/O exception

### delete

    public void delete(int pre)

  Description copied from class: `Data`
  Deletes a node and its descendants.

  Specified by:
    `delete` in class `Data`
  Parameters:
    `pre` - pre value of the node to delete

### flush

    public void flush()

  Description copied from class: `Data`
  Flushes the table data.

  Specified by:
    `flush` in class `Data`

### ftIDs

    public int[][] ftIDs(byte[] word,
                         FTOption ftO)

  Description copied from class: `Data`
  Returns the indexed id references for the specified fulltext token.

  Specified by:
    `ftIDs` in class `Data`
  Parameters:
    `word` - token to be looked up
    `ftO` - fulltext options
  Returns:
    id array

### id

    public int id(int pre)

  Description copied from class: `Data`
  Returns a unique node id.

  Specified by:
    `id` in class `Data`
  Parameters:
    `pre` - pre value
  Returns:
    node id

### info

    public void info(PrintOutput out)
              throws java.io.IOException

  Description copied from class: `Data`
  Returns info on the index structures.

  Specified by:
    `info` in class `Data`
  Parameters:
    `out` - output stream
  Throws:
    `java.io.IOException` - I/O exception

### insert

    public void insert(int pre,
                       int par,
                       byte[] val,
                       byte kind)

  Description copied from class: `Data`
  Inserts a tag name, text node, comment or processing instruction.

  Specified by:
    `insert` in class `Data`
  Parameters:
    `pre` - pre value
    `par` - parent of node
    `val` - value to be inserted
    `kind` - node kind

### insert

    public void insert(int pre,
                       int par,
                       byte[] name,
                       byte[] val)

  Description copied from class: `Data`
  Inserts an attribute.

  Specified by:
    `insert` in class `Data`
  Parameters:
    `pre` - pre value
    `par` - parent of node
    `name` - attribute name
    `val` - attribute value

### insert

    public void insert(int pre,
                       int par,
                       Data td)

  Description copied from class: `Data`
  Insert a data instance at the specified pre value. Note that the specified data instance must differ from this instance.

  Specified by:
    `insert` in class `Data`
  Parameters:
    `pre` - pre value
    `par` - parent of node
    `td` - data instance to copy from

### kind

    public int kind(int pre)

  Description copied from class: `Data`
  Returns a node kind.

  Specified by:
    `kind` in class `Data`
  Parameters:
    `pre` - pre value
  Returns:
    node kind

### nrFTIDs

    public int nrFTIDs(byte[] token)

  Description copied from class: `Data`
  Returns the number of indexed id references for the specified token.

  Specified by:
    `nrFTIDs` in class `Data`
  Parameters:
    `token` - token to be looked up
  Returns:
    id array

### openIndex

    public void openIndex(Index.TYPE type,
                          Index index)

  Description copied from class: `Data`
  Opens the specified index.

  Specified by:
    `openIndex` in class `Data`
  Parameters:
    `type` - index to be opened
    `index` - index instance

### parent

    public int parent(int pre,
                      int kind)

  Description copied from class: `Data`
  Returns a pre value of the parent node.

  Specified by:
    `parent` in class `Data`
  Parameters:
    `pre` - pre value
    `kind` - node kind
  Returns:
    pre value of the parent node

### pre

    public int pre(int id)

  Description copied from class: `Data`
  Returns a pre value.

  Specified by:
    `pre` in class `Data`
  Parameters:
    `id` - unique node id
  Returns:
    pre value or -1 if id was not found

### size

    public int size(int pre,
                    int kind)

  Description copied from class: `Data`
  Returns a size value (number of descendant table entries).

  Specified by:
    `size` in class `Data`
  Parameters:
    `pre` - pre value
    `kind` - node kind
  Returns:
    size value

### tagID

    public int tagID(int pre)

  Description copied from class: `Data`
  Returns a tag id (reference to the tag index).

  Specified by:
    `tagID` in class `Data`
  Parameters:
    `pre` - pre value
  Returns:
    token reference

### text

    public byte[] text(int pre)

  Description copied from class: `Data`
  Returns a text.

  Specified by:
    `text` in class `Data`
  Parameters:
    `pre` - pre value
  Returns:
    atomized value

### textLen

    public int textLen(int pre)

  Description copied from class: `Data`
  Returns a text length.

  Specified by:
    `textLen` in class `Data`
  Parameters:
    `pre` - pre value
  Returns:
    atomized value

### textNum

    public double textNum(int pre)

  Description copied from class: `Data`
  Returns a text as double value.

  Specified by:
    `textNum` in class `Data`
  Parameters:
    `pre` - pre value
  Returns:
    numeric value

### update

    public void update(int pre,
                       byte[] value)

  Description copied from class: `Data`
  Updates a tag name, text node, comment or processing instruction.

  Specified by:
    `update` in class `Data`
  Parameters:
    `pre` - pre of the text node to change
    `value` - value to be updated

### update

    public void update(int pre,
                       byte[] name,
                       byte[] val)

  Description copied from class: `Data`
  Updates an attribute name and value.

  Specified by:
    `update` in class `Data`
  Parameters:
    `pre` - pre of node to insert after
    `name` - attribute name
    `val` - attribute value

Overview | Package | Class | Use | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD