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 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
  • Constructor Details

  • Method Details

    • close

      public void close()
      Description copied from class: Data
      Closes the database.
      Overrides:
      close in class Data
    • createIndex

      public void createIndex(IndexType type, Command cmd) throws IOException
      Description copied from class: Data
      Drops the specified index.
      Specified by:
      createIndex in class Data
      Parameters:
      type - index to be dropped
      cmd - calling command
      Throws:
      IOException - I/O exception
    • dropIndex

      public void dropIndex(IndexType type) throws BaseXException
      Description copied from class: Data
      Drops the specified index.
      Specified by:
      dropIndex in class Data
      Parameters:
      type - index to be dropped
      Throws:
      BaseXException - database exception
    • startUpdate

      public void startUpdate(MainOptions opts) throws BaseXException
      Description copied from class: Data
      Starts an update operation: writes a file to disk to indicate that an update is going on, and exclusively locks the table file.
      Specified by:
      startUpdate in class Data
      Parameters:
      opts - main options
      Throws:
      BaseXException - database exception
    • finishUpdate

      public void finishUpdate(MainOptions opts)
      Description copied from class: Data
      Finishes an update operation: removes the update file and the exclusive lock.
      Specified by:
      finishUpdate in class Data
      Parameters:
      opts - main options
    • flush

      public void flush(boolean all)
      Description copied from class: Data
      Flushes updated data.
      Specified by:
      flush in class Data
      Parameters:
      all - flush all data
    • text

      public byte[] text(int pre, boolean text)
      Description copied from class: Data
      Returns a text (text, comment, pi, document) or attribute value.
      Specified by:
      text in class Data
      Parameters:
      pre - pre value
      text - text/attribute flag
      Returns:
      atomized value
    • textItr

      public long textItr(int pre, boolean text)
      Description copied from class: Data
      Returns a text (text, comment, pi, document) or attribute value as integer value. Long.MIN_VALUE is returned if the input is no valid integer.
      Specified by:
      textItr in class Data
      Parameters:
      pre - pre value
      text - text/attribute flag
      Returns:
      numeric value
    • textDbl

      public double textDbl(int pre, boolean text)
      Description copied from class: Data
      Returns a text (text, comment, pi, document) or attribute value as double value. Double.NaN is returned if the input is no valid double.
      Specified by:
      textDbl in class Data
      Parameters:
      pre - pre value
      text - text/attribute flag
      Returns:
      numeric value
    • textLen

      public int textLen(int pre, boolean text)
      Description copied from class: Data
      Returns the byte length of a (possibly compressed) text (text, comment, pi, document).
      Specified by:
      textLen in class Data
      Parameters:
      pre - pre value
      text - text/attribute flag
      Returns:
      length
    • inMemory

      public boolean inMemory()
      Description copied from class: Data
      Indicates if this data instance is in main memory or on disk.
      Specified by:
      inMemory in class Data
      Returns:
      result of check
    • delete

      protected void delete(int pre, boolean text)
      Description copied from class: Data
      Deletes the specified text entry.
      Specified by:
      delete in class Data
      Parameters:
      pre - pre value
      text - text (text, comment or pi) or attribute flag
    • updateText

      protected void updateText(int pre, byte[] value, int kind)
      Description copied from class: Data
      Updates the specified text or attribute value.
      Specified by:
      updateText in class Data
      Parameters:
      pre - pre value
      value - content
      kind - node kind
    • textRef

      protected long textRef(byte[] value, boolean text)
      Description copied from class: Data
      Generates a reference for a text (text, comment, pi, pi, document) or attribute value.
      Specified by:
      textRef in class Data
      Parameters:
      value - text to be indexed
      text - text/attribute flag
      Returns:
      reference