Package org.apache.maven.index.reader
Class IndexWriter
- java.lang.Object
-
- org.apache.maven.index.reader.IndexWriter
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class IndexWriter extends java.lang.Object implements java.io.CloseableMaven 2 Index writer that writes chunk and maintains published property file. Currently no incremental update is supported, as the deleteion states should be maintained by caller. Hence, this writer will always produce the "main" chunk only.- Since:
- 5.1.2
-
-
Constructor Summary
Constructors Constructor Description IndexWriter(WritableResourceHandler local, java.lang.String indexId, boolean incrementalSupported)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the underlyingResourceHandlerand synchronizes published index properties, so remote clients becomes able to consume newly published index.java.lang.StringgetChainId()Returns the chain id of published index.java.lang.StringgetIndexId()Returns the index context ID that published index has set.java.lang.StringgetNextChunkName()Returns the next chunk name about to be published.java.util.DategetPublishedTimestamp()Returns theDatewhen index was last published ornullif this is first publishing.booleanisIncremental()Returnstrueif incremental publish is about to happen.intwriteChunk(java.util.Iterator<java.util.Map<java.lang.String,java.lang.String>> iterator)Writes out the record iterator and returns the written record count.
-
-
-
Constructor Detail
-
IndexWriter
public IndexWriter(WritableResourceHandler local, java.lang.String indexId, boolean incrementalSupported) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
getIndexId
public java.lang.String getIndexId()
Returns the index context ID that published index has set.
-
getPublishedTimestamp
public java.util.Date getPublishedTimestamp()
Returns theDatewhen index was last published ornullif this is first publishing. In other words,returnsnullwhenisIncremental()returnsfalse. After this writer is closed, the return value is updated to "now" (inmethod.
-
isIncremental
public boolean isIncremental()
Returnstrueif incremental publish is about to happen.
-
getChainId
public java.lang.String getChainId()
Returns the chain id of published index. IfisIncremental()isfalse, this is the newly generated chain ID.
-
getNextChunkName
public java.lang.String getNextChunkName()
Returns the next chunk name about to be published.
-
writeChunk
public int writeChunk(java.util.Iterator<java.util.Map<java.lang.String,java.lang.String>> iterator) throws java.io.IOExceptionWrites out the record iterator and returns the written record count.- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOExceptionCloses the underlyingResourceHandlerand 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 theResourceHandlerthat caller provided in constructor of this class should be closed manually.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
-