org.basex.index.path
Class PathSummary

java.lang.Object
  extended by org.basex.index.path.PathSummary
All Implemented Interfaces:
Index

public final class PathSummary
extends java.lang.Object
implements Index

This class stores the path summary of a database. It contains all unique location paths.

Author:
BaseX Team 2005-12, BSD License, Christian Gruen

Constructor Summary
PathSummary()
          Constructor.
PathSummary(Data d)
          Constructor, specifying a data reference.
PathSummary(Data d, DataInput in)
          Constructor, specifying an input file.
 
Method Summary
 void close()
          Closes the index.
 int count(IndexToken token)
          Returns the (approximate/estimated) number of hits for the specified token.
 void data(Data d)
          Sets the data reference.
static java.util.ArrayList<PathNode> desc(java.util.ArrayList<PathNode> in, boolean desc)
          Returns all children or descendants of the specified nodes.
 TokenList desc(byte[] k, boolean d, boolean o)
          Returns descendant tags and attributes for the specified start key.
 java.util.ArrayList<PathNode> desc(int n, int k)
          Returns all children or descendants of the specified nodes with the specified tag or attribute value.
 TokenList desc(TokenList tl, boolean d, boolean o)
          Returns descendant tags and attributes for the specified descendant path.
 EntryIterator entries(IndexEntries entries)
          Returns all entries that match the specified token.
 byte[] info()
          Returns information on the index structure.
 void init()
          Initializes the index.
 IndexIterator iter(IndexToken token)
          Returns an iterator for the index results.
static java.util.ArrayList<PathNode> parent(java.util.ArrayList<PathNode> in)
          Returns all parents of the specified nodes.
 void put(int n, byte k, int l)
          Adds an entry.
 void put(int n, byte k, int l, byte[] v, MetaData md)
          Adds an entry, including its value.
 java.util.ArrayList<PathNode> root()
          Returns the root node.
 java.lang.String toString()
           
 void write(DataOutput out)
          Writes the path summary to the specified output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PathSummary

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


PathSummary

public PathSummary(Data d)
Constructor, specifying a data reference.

Parameters:
d - data reference

PathSummary

public PathSummary(Data d,
                   DataInput in)
            throws java.io.IOException
Constructor, specifying an input file.

Parameters:
d - data reference
in - input stream
Throws:
java.io.IOException - I/O exception
Method Detail

write

public void write(DataOutput out)
           throws java.io.IOException
Writes the path summary to the specified output.

Parameters:
out - output stream
Throws:
java.io.IOException - I/O exception

data

public void data(Data d)
Sets the data reference.

Parameters:
d - reference

init

public void init()
Description copied from interface: Index
Initializes the index.

Specified by:
init in interface Index

close

public void close()
Description copied from interface: Index
Closes the index.

Specified by:
close in interface Index

put

public void put(int n,
                byte k,
                int l)
Adds an entry.

Parameters:
n - name reference (0 for nodes other than element and attributes)
k - node kind
l - current level

put

public void put(int n,
                byte k,
                int l,
                byte[] v,
                MetaData md)
Adds an entry, including its value.

Parameters:
n - name reference (0 for nodes other than element and attributes)
k - node kind
l - current level
v - value
md - meta data

root

public java.util.ArrayList<PathNode> root()
Returns the root node.

Returns:
root node

parent

public static java.util.ArrayList<PathNode> parent(java.util.ArrayList<PathNode> in)
Returns all parents of the specified nodes. Used by the query optimizers.

Parameters:
in - input nodes
Returns:
parent nodes

desc

public static java.util.ArrayList<PathNode> desc(java.util.ArrayList<PathNode> in,
                                                 boolean desc)
Returns all children or descendants of the specified nodes. Called from the query parser and optimizer.

Parameters:
in - input nodes
desc - if false, return only children
Returns:
descendant nodes

desc

public java.util.ArrayList<PathNode> desc(int n,
                                          int k)
Returns all children or descendants of the specified nodes with the specified tag or attribute value. Called from the query optimizer.

Parameters:
n - name reference
k - node kind
Returns:
descendant nodes

desc

public TokenList desc(byte[] k,
                      boolean d,
                      boolean o)
Returns descendant tags and attributes for the specified start key. Used by the GUI.

Parameters:
k - input key
d - if false, return only children
o - true/false: sort by occurrence/lexicographically
Returns:
children

desc

public TokenList desc(TokenList tl,
                      boolean d,
                      boolean o)
Returns descendant tags and attributes for the specified descendant path. Used by the GUI.

Parameters:
tl - input steps
d - if false, return only children
o - true/false: sort by occurrence/lexicographically
Returns:
children

info

public byte[] info()
Description copied from interface: Index
Returns information on the index structure.

Specified by:
info in interface Index
Returns:
info

iter

public IndexIterator iter(IndexToken token)
Description copied from interface: Index
Returns an iterator for the index results.

Specified by:
iter in interface Index
Parameters:
token - token to be found
Returns:
sorted pre values for the token

count

public int count(IndexToken token)
Description copied from interface: Index
Returns the (approximate/estimated) number of hits for the specified token.

Specified by:
count in interface Index
Parameters:
token - token to be found
Returns:
number of hits

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 java.lang.String toString()
Overrides:
toString in class java.lang.Object