Class PathIndex

java.lang.Object
org.basex.index.path.PathIndex
All Implemented Interfaces:
Index

public final class PathIndex extends Object implements Index
This class stores the path summary of a database. It contains all unique location paths.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Constructor Details

    • PathIndex

      public PathIndex()
      Constructor. The Data reference must be set in a second step via data(Data).
    • PathIndex

      public PathIndex(Data data)
      Constructor, specifying a data reference.
      Parameters:
      data - data reference
    • PathIndex

      public PathIndex(Data data, DataInput in) throws IOException
      Constructor, specifying an input file.
      Parameters:
      data - data reference
      in - input stream
      Throws:
      IOException - I/O exception
  • Method Details

    • write

      public void write(DataOutput out) throws IOException
      Writes the path summary to the specified output.
      Parameters:
      out - output stream
      Throws:
      IOException - I/O exception
    • data

      public void data(Data dt)
      Sets the data reference.
      Parameters:
      dt - reference
    • init

      public void init()
      Initializes the index.
    • close

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

      public void index(int name, byte kind, int level)
      Adds an element or document node.
      Parameters:
      name - name id (0 for nodes other than elements and attributes)
      kind - node kind
      level - current level
    • index

      public void index(int name, byte kind, int level, byte[] value, MetaData meta)
      Adds an entry, including its value.
      Parameters:
      name - name id (0 for nodes other than elements and attributes)
      kind - node kind
      level - current level
      value - value (null for element or document nodes)
      meta - meta data (ignored if value is null)
    • root

      public ArrayList<PathNode> root()
      Returns the root node.
      Returns:
      root node
    • parent

      public static ArrayList<PathNode> parent(ArrayList<PathNode> nodes)
      Returns all parents of the specified nodes. Called by the query optimizer.
      Parameters:
      nodes - input nodes
      Returns:
      parent nodes
    • desc

      public static ArrayList<PathNode> desc(ArrayList<PathNode> nodes, boolean desc)
      Returns all children or descendants of the specified nodes. Called by the query parser and optimizer.
      Parameters:
      nodes - input nodes
      desc - if false, return only children
      Returns:
      descendant nodes
    • desc

      public ArrayList<PathNode> desc(byte[] name)
      Returns all descendants with the specified element name. Called by the query optimizer.
      Parameters:
      name - local name
      Returns:
      descendant nodes
    • desc

      public TokenList desc(byte[] name, boolean desc, boolean occ)
      Returns descendant element and attribute names for the specified start key. Called by the GUI.
      Parameters:
      name - input key
      desc - if false, return only children
      occ - true/false: sort by occurrence/lexicographically
      Returns:
      names
    • desc

      public TokenList desc(TokenList names, boolean desc, boolean occ)
      Returns descendant element and attribute names for the specified descendant path. Called by the GUI.
      Parameters:
      names - input steps
      desc - if false, return only children
      occ - true/false: sort by occurrence/lexicographically
      Returns:
      children
    • 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
    • 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
    • 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
    • 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
    • toString

      public String toString()
      Overrides:
      toString in class Object