org.basex.index.name
Class Names

java.lang.Object
  extended by org.basex.util.hash.ASet
      extended by org.basex.util.hash.TokenSet
          extended by org.basex.index.name.Names
All Implemented Interfaces:
java.lang.Iterable<byte[]>, Index

public final class Names
extends TokenSet
implements Index

This class indexes and organizes the tags or attribute names, used in an XML document.

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

Field Summary
 
Fields inherited from class org.basex.util.hash.TokenSet
keys
 
Fields inherited from class org.basex.util.hash.ASet
bucket, next, size
 
Constructor Summary
Names(DataInput in, MetaData md)
          Constructor, specifying an input file.
Names(MetaData md)
          Default constructor.
 
Method Summary
 void close()
          Closes the index.
 int count(IndexToken token)
          Returns the (approximate/estimated) number of hits for the specified token.
 EntryIterator entries(IndexEntries entries)
          Returns all entries that match the specified token.
 int index(byte[] n, byte[] v, boolean st)
          Indexes a name and returns its unique id.
 void index(int n, byte[] v)
          Adds a value to the statistics of the specified key.
 byte[] info()
          Returns information on the index structure.
 void init()
          Initializes the index.
 IndexIterator iter(IndexToken token)
          Returns an iterator for the index results.
protected  void rehash(int s)
          Rehashes all entries.
 Stats stat(int id)
          Returns the statistics for the specified key id.
 void write(DataOutput out)
          Writes the data structure to the specified output.
 
Methods inherited from class org.basex.util.hash.TokenSet
add, add, clear, contains, delete, hash, id, iterator, key, put, read, toString
 
Methods inherited from class org.basex.util.hash.ASet
checkSize, isEmpty, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Names

public Names(MetaData md)
Default constructor.

Parameters:
md - meta data

Names

public Names(DataInput in,
             MetaData md)
      throws java.io.IOException
Constructor, specifying an input file.

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

init

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

Specified by:
init in interface Index

index

public int index(byte[] n,
                 byte[] v,
                 boolean st)
Indexes a name and returns its unique id.

Parameters:
n - name to be added
v - value, added to statistics
st - statistics flag
Returns:
name id

index

public void index(int n,
                  byte[] v)
Adds a value to the statistics of the specified key. Evaluates the value for the specified key id.

Parameters:
n - name id
v - value, added to statistics

write

public void write(DataOutput out)
           throws java.io.IOException
Description copied from class: TokenSet
Writes the data structure to the specified output.

Overrides:
write in class TokenSet
Parameters:
out - output stream
Throws:
java.io.IOException - I/O exception

stat

public Stats stat(int id)
Returns the statistics for the specified key id.

Parameters:
id - id
Returns:
statistics

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

rehash

protected void rehash(int s)
Description copied from class: ASet
Rehashes all entries.

Overrides:
rehash in class TokenSet
Parameters:
s - new hash size

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