Terrier IR Platform
2.2.1

uk.ac.gla.terrier.structures
Class Index

java.lang.Object
  extended by uk.ac.gla.terrier.structures.Index
All Implemented Interfaces:
Closeable

public class Index
extends java.lang.Object
implements Closeable

This class encapsulates all the Indexes at retrieval time. It is loaded by giving a path and prefix. This looks for an index properties file at path/prefix.properties. Essentially, the properties file then specifies which index structures the index supports. The index then loads these so they can be used in retrieval.

Arbitrary properties can be defined in the index properties files, and in particular, properties are used to record index statistics and the contructor type and values of various index objects. Properties defaults are chosen appropriately for Terrier 1.x indices.

The Index will apply methods on specially marked interfaces. Currently, these are LegacyBitFileStructure and IndexConfigurable. Moreover, structures implementing Closeable will have their close method called when the Index is closed.

Version:
$Revision: 1.35 $
Author:
Craig Macdonald & Vassilis Plachouras

Method Summary
 void addIndexStructure(java.lang.String structureName, java.lang.String className)
          add an index structure to this index.
 void addIndexStructure(java.lang.String structureName, java.lang.String className, java.lang.String[] paramTypes, java.lang.String[] paramValues)
          add an index structure to this index.
 void addIndexStructure(java.lang.String structureName, java.lang.String className, java.lang.String paramTypes, java.lang.String paramValues)
          add an index structure to this index.
 void addIndexStructureInputStream(java.lang.String structureName, java.lang.String className)
          tell the index about a new input stream index structure it provides.
 void addIndexStructureInputStream(java.lang.String structureName, java.lang.String className, java.lang.String[] paramTypes, java.lang.String[] paramValues)
          tell the index about a new input stream index structure it provides.
 void addIndexStructureInputStream(java.lang.String structureName, java.lang.String className, java.lang.String paramTypes, java.lang.String paramValues)
          tell the index about a new input stream index structure it provides.
 void close()
          Closes the data structures of the index.
static Index createIndex()
          Factory method for creating an index.
static Index createIndex(java.lang.String path, java.lang.String prefix)
          Factory method for load an index.
static Index createNewIndex(java.lang.String path, java.lang.String prefix)
          Factory method create a new index.
static boolean existsIndex(java.lang.String path, java.lang.String prefix)
          Returns true if it is likely that an index exists at the specified location
 void flush()
          Write any dirty data structures down to disk
 CollectionStatistics getCollectionStatistics()
           
 DirectIndex getDirectIndex()
          Return the DirectIndex associated with this index
 DocumentIndex getDocumentIndex()
          Return the DocumentIndex associated with this index
 java.lang.String getIndexProperty(java.lang.String key, java.lang.String defaultValue)
          get an arbitrary property in the index
 java.lang.Object getIndexStructure(java.lang.String structureName)
          Obtains the named index structure, using an already loaded one if possible.
 java.lang.Object getIndexStructureInputStream(java.lang.String structureName)
          Return the input stream associated with the specified structure of this index
 int getIntIndexProperty(java.lang.String key, int defaultValue)
          get an arbitrary int property from the index
 InvertedIndex getInvertedIndex()
          Returns the InvertedIndex to use for this index
static java.lang.String getLastIndexLoadError()
          Returns the last warning given by an index being loaded.
 Lexicon getLexicon()
          Return the Lexicon associated with this index
 java.lang.String getPath()
          Returns the path of this index
 java.lang.String getPrefix()
          Returns the prefix of this index
 boolean hasIndexStructure(java.lang.String structureName)
          Does this index have an index structure with the specified name?
 boolean hasIndexStructureInputStream(java.lang.String structureName)
          Does this index have an index structure input stream with the specified name?
 void setIndexProperty(java.lang.String key, java.lang.String value)
          set an arbitrary property in the index
 java.lang.String toString()
          Returns a String representation of this index
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

hasIndexStructure

public boolean hasIndexStructure(java.lang.String structureName)
Does this index have an index structure with the specified name?

Parameters:
structureName - name of the required structure
Returns:
true if the index has an appropriately named structure

hasIndexStructureInputStream

public boolean hasIndexStructureInputStream(java.lang.String structureName)
Does this index have an index structure input stream with the specified name?

Parameters:
structureName - name of the required structure
Returns:
true if the index has an appropriately named structure

getIndexStructure

public java.lang.Object getIndexStructure(java.lang.String structureName)
Obtains the named index structure, using an already loaded one if possible.

Parameters:
structureName - name of the required structure
Returns:
desired object or null if not found

getIndexStructureInputStream

public java.lang.Object getIndexStructureInputStream(java.lang.String structureName)
Return the input stream associated with the specified structure of this index

Parameters:
structureName - The name of the structure of which you want the inputstream. Eg "lexicon"
Returns:
Required structure, or null if not found

close

public void close()
Closes the data structures of the index.

Specified by:
close in interface Closeable

flush

public void flush()
Write any dirty data structures down to disk


getInvertedIndex

public InvertedIndex getInvertedIndex()
Returns the InvertedIndex to use for this index


getDirectIndex

public DirectIndex getDirectIndex()
Return the DirectIndex associated with this index


getLexicon

public Lexicon getLexicon()
Return the Lexicon associated with this index


getDocumentIndex

public DocumentIndex getDocumentIndex()
Return the DocumentIndex associated with this index


getCollectionStatistics

public CollectionStatistics getCollectionStatistics()

toString

public java.lang.String toString()
Returns a String representation of this index

Overrides:
toString in class java.lang.Object

getPath

public java.lang.String getPath()
Returns the path of this index


getPrefix

public java.lang.String getPrefix()
Returns the prefix of this index


addIndexStructure

public void addIndexStructure(java.lang.String structureName,
                              java.lang.String className)
add an index structure to this index. Structure will be called structureName, and instantiated by a class called className. Instantiation parameters are "String,String", which are "path,prefix".

Parameters:
structureName -
className -

addIndexStructure

public void addIndexStructure(java.lang.String structureName,
                              java.lang.String className,
                              java.lang.String[] paramTypes,
                              java.lang.String[] paramValues)
add an index structure to this index. Structure will be called structureName, and instantiated by a class called className. Instantiation type parameters or values are non-default.


addIndexStructure

public void addIndexStructure(java.lang.String structureName,
                              java.lang.String className,
                              java.lang.String paramTypes,
                              java.lang.String paramValues)
add an index structure to this index. Structure will be called structureName, and instantiated by a class called className. Instantiation type parameters or values are non-default.


addIndexStructureInputStream

public void addIndexStructureInputStream(java.lang.String structureName,
                                         java.lang.String className)
tell the index about a new input stream index structure it provides.


addIndexStructureInputStream

public void addIndexStructureInputStream(java.lang.String structureName,
                                         java.lang.String className,
                                         java.lang.String[] paramTypes,
                                         java.lang.String[] paramValues)
tell the index about a new input stream index structure it provides.


addIndexStructureInputStream

public void addIndexStructureInputStream(java.lang.String structureName,
                                         java.lang.String className,
                                         java.lang.String paramTypes,
                                         java.lang.String paramValues)
tell the index about a new input stream index structure it provides.


setIndexProperty

public void setIndexProperty(java.lang.String key,
                             java.lang.String value)
set an arbitrary property in the index

Parameters:
key - Key to of the property to set
value - Value of the property to set

getIndexProperty

public java.lang.String getIndexProperty(java.lang.String key,
                                         java.lang.String defaultValue)
get an arbitrary property in the index

Parameters:
key - Key of the property to get
defaultValue - value of the property to use if property is not set
Returns:
Value of the property

getIntIndexProperty

public int getIntIndexProperty(java.lang.String key,
                               int defaultValue)
get an arbitrary int property from the index


createIndex

public static Index createIndex(java.lang.String path,
                                java.lang.String prefix)
Factory method for load an index. This method should be used in order to load an existing index in the applications.

Parameters:
path - String the path in which the data structures will be created.
prefix - String the prefix of the files to be created.

createNewIndex

public static Index createNewIndex(java.lang.String path,
                                   java.lang.String prefix)
Factory method create a new index. This method should be used in order to load a new index in the applications.

Parameters:
path - String the path in which the data structures will be created.
prefix - String the prefix of the files to be created.

getLastIndexLoadError

public static java.lang.String getLastIndexLoadError()
Returns the last warning given by an index being loaded.


existsIndex

public static boolean existsIndex(java.lang.String path,
                                  java.lang.String prefix)
Returns true if it is likely that an index exists at the specified location

Parameters:
path -
prefix -
Returns:
true if a .properties or a .log files exists

createIndex

public static Index createIndex()
Factory method for creating an index. This method should be used in order to load an existing index in the applications.


Terrier IR Platform
2.2.1

Terrier Information Retrieval Platform 2.2.1. Copyright 2004-2008 University of Glasgow