Package org.terrier.structures
Class IndexOnDisk
- java.lang.Object
-
- org.terrier.structures.Index
-
- org.terrier.structures.PropertiesIndex
-
- org.terrier.structures.IndexOnDisk
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class IndexOnDisk extends PropertiesIndex
The replacement for what was Index in earlier Terrier versions. Represents the most common type of index, i.e. one which is stored on disk.- Since:
- 4.0
- Author:
- Stuart Mackie, Craig Macdonald, Richard McCreadie
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classIndexOnDisk.DiskIndexLoader-
Nested classes/interfaces inherited from class org.terrier.structures.PropertiesIndex
PropertiesIndex.UpdatingCollectionStatistics
-
Nested classes/interfaces inherited from class org.terrier.structures.Index
Index.DirectIndexRef
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringloadErrorprotected booleanloadSuccessSet to true if loading an index succeedsprotected java.lang.Stringpathpath component of this index's locationprotected java.lang.Stringprefixprefix component of this index's locationprotected java.util.HashMap<java.lang.String,java.lang.Object>structureCacheCache of all opened index structures, but not input streams-
Fields inherited from class org.terrier.structures.PropertiesIndex
dirtyProperties, EMPTY_CLASS_ARRAY, lastLoadError, logger, MINIMUM_INDEX_TERRIER_VERSION, properties, PROPERTIES_SUFFIX, RETRIEVAL_LOADING_PROFILE
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedIndexOnDisk()A default constructor that creates an instance of the index.IndexOnDisk(long l, long m, long n)protectedIndexOnDisk(java.lang.String _path, java.lang.String _prefix, boolean isNew)Constructs a new Index object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the data structures of the index.voidflush()Write any dirty data structures down to diskprotected voidflushProperties()Write any dirty properties down to diskCollectionStatisticsgetCollectionStatistics()Get the collection statisticsPostingIndex<Pointer>getDirectIndex()Return the DirectIndex associated with this indexDocumentIndexgetDocumentIndex()Return the DocumentIndex associated with this indexjava.lang.ObjectgetIndexStructure(java.lang.String structureName)Obtains the named index structure, using an already loaded one if possible.<T> TgetIndexStructure(java.lang.String structureName, java.lang.Class<? extends T> clazz)java.lang.ObjectgetIndexStructureInputStream(java.lang.String structureName)Return the input stream associated with the specified structure of this index<T> TgetIndexStructureInputStream(java.lang.String structureName, java.lang.Class<? extends T> clazz)PostingIndex<?>getInvertedIndex()Returns the InvertedIndex to use for this indexLexicon<java.lang.String>getLexicon()Return the Lexicon associated with this indexMetaIndexgetMetaIndex()Get the Meta Index structurejava.lang.StringgetPath()Returns the path of this indexjava.lang.StringgetPrefix()Returns the prefix of this indexprotected java.lang.ObjectloadIndexStructure(java.lang.String structureName)Load a new instance of the named index structure.protected voidloadIndices()load all index structures.protected booleanloadProperties()loads in the properties file, falling back to the Terrier 1.xx log file if no properties exist.protected voidloadStatistics()for an immutable index, use a normal collection statistics, never changesprotected voidloadUpdatingStatistics()for an index that is not yet built, use an UpdatingCollectionStatistics, which is slower but can support updates of the index statisticsjava.lang.StringtoString()Returns a String representation of this index-
Methods inherited from class org.terrier.structures.PropertiesIndex
addIndexStructure, addIndexStructure, addIndexStructure, addIndexStructure, addIndexStructureInputStream, addIndexStructureInputStream, addIndexStructureInputStream, addIndexStructureInputStream, allExists, createIndex, createIndex, createNewIndex, existsIndex, getEnd, getIndexLoadingProfileAsRetrieval, getIndexProperty, getIndexRef, getIntIndexProperty, getLastIndexLoadError, getProperties, getStart, hasIndexStructure, hasIndexStructureInputStream, join, setIndexLoadingProfileAsRetrieval, setIndexProperty
-
Methods inherited from class org.terrier.structures.Index
makeDirectIndexRef
-
-
-
-
Field Detail
-
path
protected java.lang.String path
path component of this index's location
-
prefix
protected java.lang.String prefix
prefix component of this index's location
-
structureCache
protected final java.util.HashMap<java.lang.String,java.lang.Object> structureCache
Cache of all opened index structures, but not input streams
-
loadSuccess
protected boolean loadSuccess
Set to true if loading an index succeeds
-
loadError
protected java.lang.String loadError
-
-
Constructor Detail
-
IndexOnDisk
protected IndexOnDisk()
A default constructor that creates an instance of the index.
-
IndexOnDisk
protected IndexOnDisk(java.lang.String _path, java.lang.String _prefix, boolean isNew)Constructs a new Index object. Don't call this method, call the createIndex(String) factory method to construct an Index object.- Parameters:
_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 location
-
IndexOnDisk
public IndexOnDisk(long l, long m, long n)
-
-
Method Detail
-
close
public void close() throws java.io.IOExceptionDescription copied from class:PropertiesIndexCloses the data structures of the index.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein classPropertiesIndex- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOExceptionDescription copied from class:PropertiesIndexWrite any dirty data structures down to disk- Specified by:
flushin interfacejava.io.Flushable- Specified by:
flushin classPropertiesIndex- Throws:
java.io.IOException
-
flushProperties
protected void flushProperties() throws java.io.IOExceptionWrite any dirty properties down to disk- Throws:
java.io.IOException
-
getCollectionStatistics
public CollectionStatistics getCollectionStatistics()
Description copied from class:PropertiesIndexGet the collection statistics- Specified by:
getCollectionStatisticsin classPropertiesIndex
-
getDirectIndex
public PostingIndex<Pointer> getDirectIndex()
Description copied from class:PropertiesIndexReturn the DirectIndex associated with this index- Specified by:
getDirectIndexin classPropertiesIndex
-
getDocumentIndex
public DocumentIndex getDocumentIndex()
Description copied from class:PropertiesIndexReturn the DocumentIndex associated with this index- Specified by:
getDocumentIndexin classPropertiesIndex
-
getIndexStructure
public <T> T getIndexStructure(java.lang.String structureName, java.lang.Class<? extends T> clazz)
-
getIndexStructure
public java.lang.Object getIndexStructure(java.lang.String structureName)
Obtains the named index structure, using an already loaded one if possible.- Specified by:
getIndexStructurein classPropertiesIndex- Parameters:
structureName- name of the required structure- Returns:
- desired object or null if not found
-
getIndexStructureInputStream
public <T> T getIndexStructureInputStream(java.lang.String structureName, java.lang.Class<? extends T> clazz)
-
getIndexStructureInputStream
public java.lang.Object getIndexStructureInputStream(java.lang.String structureName)
Description copied from class:PropertiesIndexReturn the input stream associated with the specified structure of this index- Specified by:
getIndexStructureInputStreamin classPropertiesIndex- Parameters:
structureName- The name of the structure of which you want the inputstream. Eg "lexicon"- Returns:
- Required structure, or null if not found
-
getInvertedIndex
public PostingIndex<?> getInvertedIndex()
Description copied from class:PropertiesIndexReturns the InvertedIndex to use for this index- Specified by:
getInvertedIndexin classPropertiesIndex
-
getLexicon
public Lexicon<java.lang.String> getLexicon()
Description copied from class:PropertiesIndexReturn the Lexicon associated with this index- Specified by:
getLexiconin classPropertiesIndex
-
getMetaIndex
public MetaIndex getMetaIndex()
Description copied from class:PropertiesIndexGet the Meta Index structure- Specified by:
getMetaIndexin classPropertiesIndex
-
getPath
public java.lang.String getPath()
Returns the path of this index
-
getPrefix
public java.lang.String getPrefix()
Returns the prefix of this index
-
loadIndexStructure
protected java.lang.Object loadIndexStructure(java.lang.String structureName)
Load a new instance of the named index structure.- Parameters:
structureName- name of the required structure- Returns:
- desired object or null if not found
-
loadIndices
protected void loadIndices()
load all index structures. Is disabled if index property index.preloadIndices.disabled is set to true. It is false by default, which means that all non-inputstream indices are loaded on initialisation of the index. When the property is true, indices are loaded as required.
-
loadProperties
protected boolean loadProperties()
loads in the properties file, falling back to the Terrier 1.xx log file if no properties exist.
-
loadStatistics
protected void loadStatistics()
for an immutable index, use a normal collection statistics, never changes
-
loadUpdatingStatistics
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
-
toString
public java.lang.String toString()
Description copied from class:PropertiesIndexReturns a String representation of this index- Specified by:
toStringin classPropertiesIndex
-
-