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 class
IndexOnDisk.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.String
loadError
protected boolean
loadSuccess
Set to true if loading an index succeedsprotected java.lang.String
path
path component of this index's locationprotected java.lang.String
prefix
prefix component of this index's locationprotected java.util.HashMap<java.lang.String,java.lang.Object>
structureCache
Cache 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 protected
IndexOnDisk()
A default constructor that creates an instance of the index.IndexOnDisk(long l, long m, long n)
protected
IndexOnDisk(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 void
close()
Closes the data structures of the index.void
flush()
Write any dirty data structures down to diskprotected void
flushProperties()
Write any dirty properties down to diskCollectionStatistics
getCollectionStatistics()
Get the collection statisticsPostingIndex<Pointer>
getDirectIndex()
Return the DirectIndex associated with this indexDocumentIndex
getDocumentIndex()
Return the DocumentIndex associated with this indexjava.lang.Object
getIndexStructure(java.lang.String structureName)
Obtains the named index structure, using an already loaded one if possible.<T> T
getIndexStructure(java.lang.String structureName, java.lang.Class<? extends T> clazz)
java.lang.Object
getIndexStructureInputStream(java.lang.String structureName)
Return the input stream associated with the specified structure of this index<T> T
getIndexStructureInputStream(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 indexMetaIndex
getMetaIndex()
Get the Meta Index structurejava.lang.String
getPath()
Returns the path of this indexjava.lang.String
getPrefix()
Returns the prefix of this indexprotected 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 changesprotected void
loadUpdatingStatistics()
for an index that is not yet built, use an UpdatingCollectionStatistics, which is slower but can support updates of the index statisticsjava.lang.String
toString()
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.IOException
Description copied from class:PropertiesIndex
Closes the data structures of the index.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in classPropertiesIndex
- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException
Description copied from class:PropertiesIndex
Write any dirty data structures down to disk- Specified by:
flush
in interfacejava.io.Flushable
- Specified by:
flush
in classPropertiesIndex
- Throws:
java.io.IOException
-
flushProperties
protected void flushProperties() throws java.io.IOException
Write any dirty properties down to disk- Throws:
java.io.IOException
-
getCollectionStatistics
public CollectionStatistics getCollectionStatistics()
Description copied from class:PropertiesIndex
Get the collection statistics- Specified by:
getCollectionStatistics
in classPropertiesIndex
-
getDirectIndex
public PostingIndex<Pointer> getDirectIndex()
Description copied from class:PropertiesIndex
Return the DirectIndex associated with this index- Specified by:
getDirectIndex
in classPropertiesIndex
-
getDocumentIndex
public DocumentIndex getDocumentIndex()
Description copied from class:PropertiesIndex
Return the DocumentIndex associated with this index- Specified by:
getDocumentIndex
in 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:
getIndexStructure
in 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:PropertiesIndex
Return the input stream associated with the specified structure of this index- Specified by:
getIndexStructureInputStream
in 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:PropertiesIndex
Returns the InvertedIndex to use for this index- Specified by:
getInvertedIndex
in classPropertiesIndex
-
getLexicon
public Lexicon<java.lang.String> getLexicon()
Description copied from class:PropertiesIndex
Return the Lexicon associated with this index- Specified by:
getLexicon
in classPropertiesIndex
-
getMetaIndex
public MetaIndex getMetaIndex()
Description copied from class:PropertiesIndex
Get the Meta Index structure- Specified by:
getMetaIndex
in 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:PropertiesIndex
Returns a String representation of this index- Specified by:
toString
in classPropertiesIndex
-
-