lempinen.neatseeker.core
Class Repository

java.lang.Object
  |
  +--lempinen.neatseeker.core.Repository

public class Repository
extends java.lang.Object

Class for handling a repository of Buckets.

The Repository class provides a layer of abstraction over the individual Buckets. A Bucket is a TreeMap containing keyword data for a particular fragment of the entire index (typically, words beginning with same initial letters).

The Repository class is responsible for handling incoming and outgoing keyword requests and directing them to the correct Bucket.

As a secondary task, the Repository also manages a TargetIndex, which complements the keyword data in the Buckets and provides information about the indexed documents (e.g. their URIs, titles etc.)

A Repository can be created read-only or read-write, depending on which constructor you choose. Read-write mode is required for indexing, whereas for searches, you can use the read-only mode. This allows you to use NeatSeeker e.g. in a servlet environment, where the user account that runs the server has only write access to the index.

Version:
$Id: Repository.java,v 1.5 2000/10/05 16:51:39 lempinen Exp $
Author:
Sami Lempinen
See Also:
Bucket, TargetIndex

Field Summary
private  java.util.HashMap buckets
          The HashMap that holds the individual buckets.
protected  Configuration conf
          The Configuration object.
protected  TargetIndex documents
          The TargetIndex object for storing details about the indexed targets.
protected  boolean readonly
          The read-only flag.
protected  java.lang.String root
          The root directory of the Bucket repository.
protected  Stemmer stemmer
          The Stemmer object.
 
Constructor Summary
Repository(Configuration c)
          Creates a new read-write Repository with the given configuration.
Repository(Configuration c, boolean ro)
          Creates a new Repository (read or read-write).
 
Method Summary
 void add(Entry entry)
          Adds a single key-value pair to this repository.
 void cleanup()
          Cleans up the repository.
private  java.lang.String getBucket(java.lang.String key)
          Returns the hashed lowercase bucket name for a particular key.
 long getNextID()
          Returns the ID of the next Target.
 Target getTarget(long id)
          Returns a Target from the TargetIndex by its ID.
private  void initRepository()
          Initialises the repository directory.
 long put(Target t)
          Adds an object into the TargetIndex and returns a unique ID.
 void save()
          Writes all Buckets and the TargetIndex onto disk.
 PointerList searchSimple(java.lang.String key)
          Searches for a particular key in the repository.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

buckets

private java.util.HashMap buckets
The HashMap that holds the individual buckets. This HashMap provides a cache of Buckets, and takes away the overhead of loading Buckets from disk whenever they are accessed.

root

protected java.lang.String root
The root directory of the Bucket repository.

documents

protected TargetIndex documents
The TargetIndex object for storing details about the indexed targets.

readonly

protected boolean readonly
The read-only flag.

conf

protected Configuration conf
The Configuration object.

stemmer

protected Stemmer stemmer
The Stemmer object.
Constructor Detail

Repository

public Repository(Configuration c)
           throws java.io.IOException
Creates a new read-write Repository with the given configuration.

Repository

public Repository(Configuration c,
                  boolean ro)
           throws java.io.IOException
Creates a new Repository (read or read-write).
Method Detail

add

public void add(Entry entry)
Adds a single key-value pair to this repository.

searchSimple

public PointerList searchSimple(java.lang.String key)
Searches for a particular key in the repository.

save

public void save()
Writes all Buckets and the TargetIndex onto disk.

getTarget

public Target getTarget(long id)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Returns a Target from the TargetIndex by its ID.

getNextID

public long getNextID()
               throws java.io.IOException
Returns the ID of the next Target.

put

public long put(Target t)
         throws java.io.IOException
Adds an object into the TargetIndex and returns a unique ID.

getBucket

private java.lang.String getBucket(java.lang.String key)
Returns the hashed lowercase bucket name for a particular key. Tune this to control serialized Bucket size.

cleanup

public void cleanup()
Cleans up the repository.

initRepository

private void initRepository()
Initialises the repository directory.