Package org.apache.maven.index.reader
Class IndexWriter
java.lang.Object
org.apache.maven.index.reader.IndexWriter
- All Implemented Interfaces:
Closeable,AutoCloseable
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.
- Since:
- 5.1.2
-
Constructor Summary
ConstructorsConstructorDescriptionIndexWriter(WritableResourceHandler local, String indexId, boolean incrementalSupported) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the underlyingResourceHandlerand synchronizes published index properties, so remote clients becomes able to consume newly published index.Returns the chain id of published index.Returns the index context ID that published index has set.Returns the next chunk name about to be published.Returns theDatewhen index was last published ornullif this is first publishing.booleanReturnstrueif incremental publish is about to happen.intwriteChunk(Iterator<Map<String, String>> iterator) Writes out the record iterator and returns the written record count.
-
Constructor Details
-
IndexWriter
public IndexWriter(WritableResourceHandler local, String indexId, boolean incrementalSupported) throws IOException - Throws:
IOException
-
-
Method Details
-
getIndexId
Returns the index context ID that published index has set. -
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
Returns the chain id of published index. IfisIncremental()isfalse, this is the newly generated chain ID. -
getNextChunkName
Returns the next chunk name about to be published. -
writeChunk
Writes out the record iterator and returns the written record count.- Throws:
IOException
-
close
Closes 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 interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-