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 MemData

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

    public class MemData

extends Data

This class stores and organizes the database table and the index structures for textual content in a compressed memory structure. Each node occupies 64 bits. The current storage layout looks like follows:

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

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

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
`MemData(int cap, Names tag, Names att)` Constructor.

Method Summary
`void` | `addAtt(byte[] a, byte[] v, int p)` Convenience method for adding an attribute.
`void` | `addAtt(int a, byte[] v, int d)` Adds an attribute.
`void` | `addElem(byte[] t, int d, int a, int s, int k)` Convenience method for adding an element.
`void` | `addElem(int t, int d, int a, int s, int k)` Adds an element.
`void` | `addText(byte[] t, int d, int k)` Adds a text node.
`void` | `append(MemData d, int p)` Copies some data.
`int` | `attID(byte[] v)` Returns the id for the specified attribute value.
`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[]` | `attToken(int id)` Returns the index value for the specified attribute value id.
`byte[]` | `attValue(int pre)` Returns an attribute value.
`void` | `close()` Closes the current database.
`void` | `closeIndex(Index.TYPE index)` Closes the specified index.
`void` | `delete(int pre)` Deletes a node and its descendants.
`void` | `finishTag(int pre)` Adds the size value to the table.
`void` | `flush()` Flushes the table data.
`int[][]` | `ftIDs(byte[] word, FTOption ftOption)` 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[] tag, byte kind)` Inserts a tag name, text node, comment or processing instruction.
`void` | `insert(int pre, int par, byte[] name, byte[] v)` Inserts an attribute.
`void` | `insert(int pre, int par, Data d)` Insert a data instance at the specified pre value.
`void` | `insert(MemData d, int pos)` Inserts a data instance at the specified position.
`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 ind)` 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.
`byte[]` | `textToken(int id)` Returns the index value for the specified index id.
`void` | `update(int pre, byte[] text)` Updates a tag name, text node, comment or processing instruction.
`void` | `update(int pre, byte[] attName, byte[] attValue)` 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

### MemData

    public MemData(int cap,
                   Names tag,
                   Names att)

  Constructor.

  Parameters:
    `cap` - initial array capacity
    `tag` - tag index
    `att` - attribute name index

Method Detail

### addAtt

    public final void addAtt(byte[] a,
                             byte[] v,
                             int p)

  Convenience method for adding an attribute.

  Parameters:
    `a` - attribute name
    `v` - attribute value
    `p` - parent

### addAtt

    public final void addAtt(int a,
                             byte[] v,
                             int d)

  Adds an attribute.

  Parameters:
    `a` - attribute name
    `v` - attribute value
    `d` - distance

### addElem

    public final void addElem(byte[] t,
                              int d,
                              int a,
                              int s,
                              int k)

  Convenience method for adding an element.

  Parameters:
    `t` - tag
    `d` - distance
    `a` - number of attributes
    `s` - node size
    `k` - node kind

### addElem

    public final void addElem(int t,
                              int d,
                              int a,
                              int s,
                              int k)

  Adds an element.

  Parameters:
    `t` - tag
    `d` - distance
    `a` - number of attributes
    `s` - node size
    `k` - node kind

### addText

    public final void addText(byte[] t,
                              int d,
                              int k)

  Adds a text node.

  Parameters:
    `t` - text to be added
    `d` - distance
    `k` - node kind

### append

    public final void append(MemData d,
                             int p)

  Copies some data.

  Parameters:
    `d` - data reference
    `p` - position

### attID

    public final int attID(byte[] v)

  Returns the id for the specified attribute value.

  Parameters:
    `v` - attribute value
  Returns:
    id

### attNameID

    public final 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 final 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 final 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

### attToken

    public final byte[] attToken(int id)

  Returns the index value for the specified attribute value id.

  Parameters:
    `id` - index id
  Returns:
    value

### attValue

    public final 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()

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

  Specified by:
    `close` in class `Data`

### closeIndex

    public void closeIndex(Index.TYPE index)

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

  Specified by:
    `closeIndex` in class `Data`
  Parameters:
    `index` - index to be closed

### delete

    public final 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

### finishTag

    public final void finishTag(int pre)

  Adds the size value to the table.

  Parameters:
    `pre` - closing pre tag

### 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 ftOption)

  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
    `ftOption` - fulltext options
  Returns:
    id array

### id

    public final 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 final void info(PrintOutput out)

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

  Specified by:
    `info` in class `Data`
  Parameters:
    `out` - output stream

### insert

    public final void insert(int pre,
                             int par,
                             byte[] tag,
                             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
    `tag` - value to be inserted
    `kind` - node kind

### insert

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

  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
    `v` - attribute value

### insert

    public final void insert(int pre,
                             int par,
                             Data d)

  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
    `d` - data instance to copy from

### insert

    public final void insert(MemData d,
                             int pos)

  Inserts a data instance at the specified position. Attention: get sure that both data instances are based on the same indexes as the references are simply copied and not checked at all...

  Parameters:
    `d` - data instance
    `pos` - insertion position

### kind

    public final 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 final 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 ind)

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

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

### parent

    public final 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 final 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 final 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 final 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 final 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 final 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 final 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

### textToken

    public final byte[] textToken(int id)

  Returns the index value for the specified index id.

  Parameters:
    `id` - index id
  Returns:
    value

### update

    public final void update(int pre,
                             byte[] text)

  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
    `text` - value to be updated

### update

    public final void update(int pre,
                             byte[] attName,
                             byte[] attValue)

  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
    `attName` - attribute name
    `attValue` - 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