Package org.apache.maven.index.reader
Class IndexReader
java.lang.Object
org.apache.maven.index.reader.IndexReader
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterable<ChunkReader>
Maven Index reader that handles incremental updates, if possible, and provides one or more
ChunkReader
s, to
read all the required records. 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.
Every involved instance, this IndexReader
, provided ChunkReader
, and used ResourceHandler
s
are Closeable
, and all have to be explicitly closed, best in try-with-resource.
- Since:
- 5.1.2
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the underlyingResourceHandler
s.Returns unmodifiable list of actual chunks that needs to be pulled from remoteResourceHandler
.Returns the index context ID that published index has set.Returns theDate
when remote index was last published.boolean
Returnstrue
if incremental update is about to happen.iterator()
Returns anIterator
ofChunkReader
s, that if read in sequence, provide all the (incremental) updates from the index.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
IndexReader
- Throws:
IOException
-
-
Method Details
-
getIndexId
Returns the index context ID that published index has set. Usually it is equal to "repository ID" used inRecord.Type.DESCRIPTOR
but does not have to be. -
getPublishedTimestamp
Returns theDate
when remote index was last published. -
isIncremental
public boolean isIncremental()Returnstrue
if incremental update is about to happen. If incremental update, theiterator()
will return only the diff from the last update. -
getChunkNames
Returns unmodifiable list of actual chunks that needs to be pulled from remoteResourceHandler
. Those are incremental chunks or the big main file, depending on result ofisIncremental()
. Empty list means local index is up to date, anditerator()
will return empty iterator. -
close
Closes the underlyingResourceHandler
s. In case of incremental update use, it also assumes that user consumed all the iterator and integrated it, hence, it will update theWritableResourceHandler
contents to prepare it for future incremental update. If this is not desired (ie. due to aborted update), then this method should NOT be invoked, but rather theResourceHandler
s that caller provided in constructor of this class should be closed manually.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
iterator
Returns anIterator
ofChunkReader
s, that if read in sequence, provide all the (incremental) updates from the index. It is caller responsibility to either consume fully this iterator, or to close currentChunkReader
if aborting.- Specified by:
iterator
in interfaceIterable<ChunkReader>
-