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
ConstructorDescriptionIndexWriter
(WritableResourceHandler local, String indexId, boolean incrementalSupported) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the underlyingResourceHandler
and 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 theDate
when index was last published ornull
if this is first publishing.boolean
Returnstrue
if incremental publish is about to happen.int
writeChunk
(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 theDate
when index was last published ornull
if this is first publishing. In other words,returnsnull
whenisIncremental()
returnsfalse
. After this writer is closed, the return value is updated to "now" (inmethod
. -
isIncremental
public boolean isIncremental()Returnstrue
if 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 underlyingResourceHandler
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 theResourceHandler
that caller provided in constructor of this class should be closed manually.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-