Class Resources

java.lang.Object
org.basex.index.resource.Resources
All Implemented Interfaces:
Index

public final class Resources extends Object implements Index

This index organizes the resources of a database (XML documents and raw files).

Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the database paths to all binary files that start with the specified path.
    children(byte[] path, boolean dir)
    Returns the child resources for the given path.
    void
    Closes the index.
    Computes costs for performing the specified search.
    void
    delete(int pre, int size)
    Deletes the specified entry and updates subsequent nodes.
    int
    doc(String path)
    Returns the pre value of the document node that matches the specified path, or -1.
    Returns the pre values of all document nodes.
    docs(String path)
    Returns the pre values of all document nodes that start with the specified path.
    docs(String path, boolean desc)
    Returns the pre values of all document nodes that start with the specified path.
    boolean
    Drops the index.
    Returns all entries that match the specified token.
    byte[]
    info(MainOptions options)
    Returns information on the index structure.
    void
    insert(int pre, DataClip clip)
    Adds entries to the index and updates subsequent nodes.
    boolean
    isDir(byte[] path)
    Determines whether the given path is the path to a directory.
    iter(IndexSearch search)
    Returns an iterator for the index results.
    void
    Reads information on database resources from disk.
    void
    rename(int pre, byte[] value)
    Updates the index after a document has been renamed.
    void
    Writes information on database resources to disk.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Resources

      public Resources(Data data)
      Constructor.
      Parameters:
      data - data reference
  • Method Details

    • read

      public void read(DataInput in) throws IOException
      Reads information on database resources from disk.
      Parameters:
      in - input stream
      Throws:
      IOException - I/O exception
    • write

      public void write(DataOutput out) throws IOException
      Writes information on database resources to disk.
      Parameters:
      out - output stream
      Throws:
      IOException - I/O exception
    • docs

      public IntList docs()
      Returns the pre values of all document nodes.
      Returns:
      document nodes (internal representation!)
    • insert

      public void insert(int pre, DataClip clip)
      Adds entries to the index and updates subsequent nodes.
      Parameters:
      pre - insertion position
      clip - data clip
    • delete

      public void delete(int pre, int size)
      Deletes the specified entry and updates subsequent nodes.
      Parameters:
      pre - pre value
      size - number of deleted nodes
    • rename

      public void rename(int pre, byte[] value)
      Updates the index after a document has been renamed.
      Parameters:
      pre - pre value of updated document
      value - new name
    • docs

      public IntList docs(String path)
      Returns the pre values of all document nodes that start with the specified path.
      Parameters:
      path - input path
      Returns:
      pre values (internal representation!)
    • docs

      public IntList docs(String path, boolean desc)
      Returns the pre values of all document nodes that start with the specified path.
      Parameters:
      path - input path
      desc - descendant traversal
      Returns:
      pre values (internal representation!)
    • doc

      public int doc(String path)
      Returns the pre value of the document node that matches the specified path, or -1.
      Parameters:
      path - input path
      Returns:
      pre value, or -1
    • binaries

      public TokenList binaries(String path)
      Returns the database paths to all binary files that start with the specified path.
      Parameters:
      path - input path
      Returns:
      root nodes
    • isDir

      public boolean isDir(byte[] path)
      Determines whether the given path is the path to a directory.
      Parameters:
      path - given path
      Returns:
      result of check
    • children

      public TokenBoolMap children(byte[] path, boolean dir)
      Returns the child resources for the given path.
      Parameters:
      path - path
      dir - returns directories
      Returns:
      paths; values of documents will be false
    • drop

      public boolean drop()
      Description copied from interface: Index
      Drops the index. Also returns true if the index does not exist.
      Specified by:
      drop in interface Index
      Returns:
      success flag
    • close

      public void close()
      Description copied from interface: Index
      Closes the index.
      Specified by:
      close in interface Index
    • iter

      public IndexIterator iter(IndexSearch search)
      Description copied from interface: Index
      Returns an iterator for the index results.
      Specified by:
      iter in interface Index
      Parameters:
      search - index search definition
      Returns:
      sorted pre values for the token
    • costs

      public IndexCosts costs(IndexSearch search)
      Description copied from interface: Index
      Computes costs for performing the specified search. An integer is returned:
      • A negative value indicates that index access is not possible.
      • A value of zero indicates that no results will be returned.
      • A small value indicates that index access is fast.
      Smaller values are better, a value of zero indicates that no results will be returned.
      Specified by:
      costs in interface Index
      Parameters:
      search - index search definition
      Returns:
      cost estimation
    • info

      public byte[] info(MainOptions options)
      Description copied from interface: Index
      Returns information on the index structure.
      Specified by:
      info in interface Index
      Parameters:
      options - main options
      Returns:
      info
    • entries

      public EntryIterator entries(IndexEntries entries)
      Description copied from interface: Index
      Returns all entries that match the specified token.
      Specified by:
      entries in interface Index
      Parameters:
      entries - index entries
      Returns:
      entries