Class 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
    • 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 interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in class PropertiesIndex
        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 interface java.io.Flushable
        Specified by:
        flush in class PropertiesIndex
        Throws:
        java.io.IOException
      • flushProperties

        protected void flushProperties()
                                throws java.io.IOException
        Write any dirty properties down to disk
        Throws:
        java.io.IOException
      • 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 class PropertiesIndex
        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 class PropertiesIndex
        Parameters:
        structureName - The name of the structure of which you want the inputstream. Eg "lexicon"
        Returns:
        Required structure, or null if not found
      • 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 class PropertiesIndex