org.basex.index.resource
Class Resources

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

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

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

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

Constructor Summary
Resources(Data d)
          Constructor.
 
Method Summary
 TokenList binaries(java.lang.String path)
          Returns the database paths to all binary files that match the specified path.
 TokenBoolMap children(byte[] path, boolean dir)
          Returns the child resources for the given path.
 void close()
          Closes the index.
 int count(IndexToken token)
          Returns the (approximate/estimated) number of hits for the specified token.
 void delete(int pre, int size)
          Deletes the specified entry and updates subsequent nodes.
 int doc(java.lang.String path)
          Returns the pre value of the node that matches the specified path, or -1.
 IntList docs()
          Returns the pre values of all document nodes.
 IntList docs(java.lang.String path)
          Returns the pre values of all document nodes starting with the specified path.
 IntList docs(java.lang.String path, boolean exact)
          Returns the pre values of all document nodes matching the specified 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.
 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.
 IndexIterator iter(IndexToken token)
          Returns an iterator for the index results.
 void read(DataInput in)
          Reads information on database resources from disk.
 void rename(int pre, byte[] value)
          Updates the index after a document has been renamed.
 void replace(int pre, int size, DataClip clip)
          Replaces entries in the index.
 void write(DataOutput out)
          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 Detail

Resources

public Resources(Data d)
Constructor.

Parameters:
d - data reference
Method Detail

read

public void read(DataInput in)
          throws java.io.IOException
Reads information on database resources from disk.

Parameters:
in - input stream
Throws:
java.io.IOException - I/O exception

write

public void write(DataOutput out)
           throws java.io.IOException
Writes information on database resources to disk.

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

docs

public IntList docs()
Returns the pre values of all document nodes.

Returns:
document nodes

init

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

Specified by:
init in interface Index

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

replace

public void replace(int pre,
                    int size,
                    DataClip clip)
Replaces entries in the index.

Parameters:
pre - insertion position
size - number of deleted nodes
clip - data clip

docs

public IntList docs(java.lang.String path)
Returns the pre values of all document nodes starting with the specified path.

Parameters:
path - input path
Returns:
root nodes

docs

public IntList docs(java.lang.String path,
                    boolean exact)
Returns the pre values of all document nodes matching the specified path.

Parameters:
path - input path
exact - exact (no prefix) matches
Returns:
root nodes

doc

public int doc(java.lang.String path)
Returns the pre value of the node that matches the specified path, or -1.

Parameters:
path - input path
Returns:
pre value

binaries

public TokenList binaries(java.lang.String path)
Returns the database paths to all binary files that match 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

close

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

Specified by:
close in interface Index

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

info

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

Specified by:
info in interface Index
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