|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.terrier.structures.Index
public class Index
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.
The Index will apply methods on specially marked interfaces. Currently, the only interface supported is IndexConfigurable. Moreover, structures implementing java.io.Closeable will have their close method called when the Index is closed.
Nested Class Summary | |
---|---|
protected class |
Index.UpdatingCollectionStatistics
This collection statistics parses the associated index properties for each call. |
Field Summary | |
---|---|
protected boolean |
dirtyProperties
Have the properties of this index changed, suggesting a flush() is necessary when closing |
protected static java.lang.Class<?>[] |
EMPTY_CLASS_ARRAY
empty class array |
protected static java.lang.String |
lastLoadError
|
protected java.lang.String |
loadError
|
protected boolean |
loadSuccess
Set to true if loading an index succeeds |
protected static org.apache.log4j.Logger |
logger
The logger used |
protected static int |
MINIMUM_INDEX_TERRIER_VERSION
|
protected java.lang.String |
path
path component of this index's location |
protected java.lang.String |
prefix
prefix component of this index's location |
protected java.util.Properties |
properties
properties of this index |
protected static java.lang.String |
PROPERTIES_SUFFIX
|
protected static boolean |
RETRIEVAL_LOADING_PROFILE
|
protected java.util.HashMap<java.lang.String,java.lang.Object> |
structureCache
Cache of all opened index structures, but not input streams |
Constructor Summary | |
---|---|
protected |
Index()
A default constuctor that creates an instance of the index. |
protected |
Index(long a,
long b,
long c)
A constructor for child classes that doesnt open the file |
protected |
Index(java.lang.String _path,
java.lang.String _prefix,
boolean isNew)
Constructs a new Index object. |
Method Summary | |
---|---|
void |
addIndexStructure(java.lang.String structureName,
java.lang.Class<?> className,
java.lang.Class<?>[] paramTypes,
java.lang.String[] paramValues)
tell the index about a new index structure it provides. |
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.Class<?> className,
java.lang.Class<?>[] 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)
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. |
protected static boolean |
allExists(java.lang.String... files)
returns true if all named files exist |
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 |
protected void |
flushProperties()
Write any dirty properties down to disk |
CollectionStatistics |
getCollectionStatistics()
Get the collection statistics |
DirectIndex |
getDirectIndex()
Return the DirectIndex associated with this index |
DocumentIndex |
getDocumentIndex()
Return the DocumentIndex associated with this index |
static boolean |
getIndexLoadingProfileAsRetrieval()
Get RETRIEVAL_LOADING_PROFILE |
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<java.lang.String> |
getLexicon()
Return the Lexicon associated with this index |
MetaIndex |
getMetaIndex()
Get the Meta Index structure |
java.lang.String |
getPath()
Returns the path of this index |
java.lang.String |
getPrefix()
Returns the prefix of this index |
java.util.Properties |
getProperties()
Get the index properties |
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? |
protected static java.lang.String |
join(java.lang.String[] input,
java.lang.String joinString)
joins a series of strings together with a delimiter |
protected java.lang.Object |
loadIndexStructure(java.lang.String structureName)
Load a new instance of the named index structure. |
protected void |
loadIndices()
load all index structures. |
protected boolean |
loadProperties()
loads in the properties file, falling back to the Terrier 1.xx log file if no properties exist. |
protected void |
loadStatistics()
for an immutable index, use a normal collection statistics, never changes |
protected void |
loadUpdatingStatistics()
for an index that is not yet built, use an UpdatingCollectionStatistics, which is slower but can support updates of the index statistics |
static void |
main(java.lang.String[] args)
main |
static void |
setIndexLoadingProfileAsRetrieval(boolean yes)
Set RETRIEVAL_LOADING_PROFILE |
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 |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final int MINIMUM_INDEX_TERRIER_VERSION
protected static final java.lang.String PROPERTIES_SUFFIX
protected static boolean RETRIEVAL_LOADING_PROFILE
protected static final org.apache.log4j.Logger logger
protected static java.lang.String lastLoadError
protected java.lang.String path
protected java.lang.String prefix
protected final java.util.Properties properties
protected final java.util.HashMap<java.lang.String,java.lang.Object> structureCache
protected boolean dirtyProperties
protected boolean loadSuccess
protected java.lang.String loadError
protected static final java.lang.Class<?>[] EMPTY_CLASS_ARRAY
Constructor Detail |
---|
protected Index(long a, long b, long c)
protected Index()
protected Index(java.lang.String _path, java.lang.String _prefix, boolean isNew)
_path
- String the path in which the data structures
will be created._prefix
- String the prefix of the files to
be created.isNew
- where a new Index should be created if there is no index
at the specified locationMethod Detail |
---|
public static void setIndexLoadingProfileAsRetrieval(boolean yes)
yes
- public static boolean getIndexLoadingProfileAsRetrieval()
public java.util.Properties getProperties()
protected void loadStatistics()
protected void loadUpdatingStatistics()
protected void loadIndices()
protected boolean loadProperties()
public boolean hasIndexStructure(java.lang.String structureName)
structureName
- name of the required structure
public boolean hasIndexStructureInputStream(java.lang.String structureName)
structureName
- name of the required structure
public java.lang.Object getIndexStructure(java.lang.String structureName)
structureName
- name of the required structure
protected java.lang.Object loadIndexStructure(java.lang.String structureName)
structureName
- name of the required structure
public java.lang.Object getIndexStructureInputStream(java.lang.String structureName)
structureName
- The name of the structure of which you want the inputstream. Eg "lexicon"
public void close() throws java.io.IOException
close
in interface java.io.Closeable
java.io.IOException
protected void flushProperties() throws java.io.IOException
java.io.IOException
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
java.io.IOException
public InvertedIndex getInvertedIndex()
public DirectIndex getDirectIndex()
public Lexicon<java.lang.String> getLexicon()
public DocumentIndex getDocumentIndex()
public MetaIndex getMetaIndex()
public CollectionStatistics getCollectionStatistics()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getPath()
public java.lang.String getPrefix()
public void addIndexStructure(java.lang.String structureName, java.lang.String className)
structureName
- className
- public void addIndexStructure(java.lang.String structureName, java.lang.Class<?> className, java.lang.Class<?>[] paramTypes, java.lang.String[] paramValues)
public void addIndexStructure(java.lang.String structureName, java.lang.String className, java.lang.String[] paramTypes, java.lang.String[] paramValues)
public void addIndexStructure(java.lang.String structureName, java.lang.String className, java.lang.String paramTypes, java.lang.String paramValues)
public void addIndexStructureInputStream(java.lang.String structureName, java.lang.String className)
public void addIndexStructureInputStream(java.lang.String structureName, java.lang.Class<?> className, java.lang.Class<?>[] paramTypes, java.lang.String[] paramValues)
public void addIndexStructureInputStream(java.lang.String structureName, java.lang.String className, java.lang.String[] paramTypes, java.lang.String[] paramValues)
public void addIndexStructureInputStream(java.lang.String structureName, java.lang.String className, java.lang.String paramTypes, java.lang.String paramValues)
public void setIndexProperty(java.lang.String key, java.lang.String value)
key
- Key to of the property to setvalue
- Value of the property to setpublic java.lang.String getIndexProperty(java.lang.String key, java.lang.String defaultValue)
key
- Key of the property to getdefaultValue
- value of the property to use if property is not set
public int getIntIndexProperty(java.lang.String key, int defaultValue)
public static Index createIndex(java.lang.String path, java.lang.String prefix)
path
- String the path in which the
data structures will be created.prefix
- String the prefix of the files
to be created.public static Index createNewIndex(java.lang.String path, java.lang.String prefix)
path
- String the path in which the
data structures will be created.prefix
- String the prefix of the files
to be created.public static java.lang.String getLastIndexLoadError()
public static boolean existsIndex(java.lang.String path, java.lang.String prefix)
path
- prefix
-
public static Index createIndex()
protected static boolean allExists(java.lang.String... files)
protected static java.lang.String join(java.lang.String[] input, java.lang.String joinString)
public static void main(java.lang.String[] args)
args
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |