Class PensieveWriter

  • All Implemented Interfaces:
    ITmWriter

    public class PensieveWriter
    extends Object
    implements ITmWriter
    Used to write, delete and update the index.
    • Constructor Detail

      • PensieveWriter

        public PensieveWriter​(org.apache.lucene.store.Directory indexDirectory,
                              boolean createNewTmIndex)
                       throws IOException
        Creates a PensieveWriter
        Parameters:
        indexDirectory - - the Lucene Directory implementation of choice.
        createNewTmIndex - Set to false to append to the existing TM index file. Set to true to overwrite.
        Throws:
        IOException - if the indexDirectory can not load
    • Method Detail

      • close

        public void close()
        Commits and closes (for now) the transaction.
        Specified by:
        close in interface ITmWriter
        Throws:
        OkapiIOException - if the commit cannot happen.
      • commit

        public void commit()
        Forces a commit against the index.
        Specified by:
        commit in interface ITmWriter
      • getIndexWriter

        public org.apache.lucene.index.IndexWriter getIndexWriter()
        Gets a handle on the IndexWriter so that commits and rollbacks can happen outside. For now, this is a convenience method. In other words, don't depend on it working for you.
        Returns:
        a handle on the IndexWriter used to Create, Update or Delete the index.
      • indexTranslationUnit

        public void indexTranslationUnit​(TranslationUnit tu,
                                         boolean overwrite)
        Description copied from interface: ITmWriter
        Indexes a given translation unit, possibly overwriting an existing one with the same source.
        Specified by:
        indexTranslationUnit in interface ITmWriter
        Parameters:
        tu - the translation unit to index.
        overwrite - true to overwrite any existing unit that has the same source content (codes excluded)