Class IndexWriter

All Implemented Interfaces:
Closeable, AutoCloseable

public class IndexWriter extends Object implements Closeable
Maven Index writer that writes chunk and maintains published property file. Instances of this class MUST BE handled as resources (have them closed once done with them), it is user responsibility to close them, ideally in try-with-resource block.

Currently no incremental update is supported, as the deletion states should be maintained by caller. Hence, this writer will always produce the "main" chunk only.

  • Constructor Details

  • Method Details

    • getIndexId

      public String getIndexId()
      Returns the index context ID that published index has set.
    • getPublishedTimestamp

      public Date getPublishedTimestamp()
      Returns the Date when index was last published or null if this is first publishing. In other words,returns null when isIncremental() returns false. After this writer is closed, the return value is updated to "now" (in method.
    • isIncremental

      public boolean isIncremental()
      Returns true if incremental publish is about to happen.
    • getChainId

      public String getChainId()
      Returns the chain id of published index. If isIncremental() is false, this is the newly generated chain ID.
    • getNextChunkName

      public String getNextChunkName()
      Returns the next chunk name about to be published.
    • writeChunk

      public int writeChunk(Iterator<Map<String,String>> iterator) throws IOException
      Writes out the record iterator and returns the written record count.
    • close

      public void close() throws IOException
      Closes the underlying ResourceHandler and synchronizes published index properties, so remote clients becomes able to consume newly published index. If sync is not desired (ie. due to aborted publish), then this method should NOT be invoked, but rather the ResourceHandler that caller provided in constructor of this class should be closed manually.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable