final class IndexFileDeleter
extends java.lang.Object
implements java.io.Closeable
Modifier and Type | Class and Description |
---|---|
private static class |
IndexFileDeleter.CommitPoint
Holds details for each commit point.
|
private static class |
IndexFileDeleter.RefCount
Tracks the reference count for a single index file:
|
Modifier and Type | Field and Description |
---|---|
private java.util.List<IndexFileDeleter.CommitPoint> |
commits |
private java.util.List<IndexFileDeleter.CommitPoint> |
commitsToDelete |
private Directory |
directory |
private Directory |
directoryOrig |
private InfoStream |
infoStream |
private java.util.List<java.lang.String> |
lastFiles |
private SegmentInfos |
lastSegmentInfos |
private IndexDeletionPolicy |
policy |
private java.util.Map<java.lang.String,IndexFileDeleter.RefCount> |
refCounts |
(package private) boolean |
startingCommitDeleted |
static boolean |
VERBOSE_REF_COUNTS
Change to true to see details of reference counts when
infoStream is enabled
|
private IndexWriter |
writer |
Constructor and Description |
---|
IndexFileDeleter(java.lang.String[] files,
Directory directoryOrig,
Directory directory,
IndexDeletionPolicy policy,
SegmentInfos segmentInfos,
InfoStream infoStream,
IndexWriter writer,
boolean initialIndexExists,
boolean isReaderInit)
Initialize the deleter: find all previous commits in
the Directory, incref the files they reference, call
the policy to let it delete commits.
|
Modifier and Type | Method and Description |
---|---|
void |
checkpoint(SegmentInfos segmentInfos,
boolean isCommit)
For definition of "check point" see IndexWriter comments:
"Clarification: Check Points (and commits)".
|
void |
close() |
(package private) void |
decRef(java.util.Collection<java.lang.String> files)
Decrefs all provided files, even on exception; throws first exception hit, if any.
|
(package private) void |
decRef(SegmentInfos segmentInfos) |
private boolean |
decRef(java.lang.String fileName)
Returns true if the file should now be deleted.
|
private void |
deleteCommits()
Remove the CommitPoints in the commitsToDelete List by
DecRef'ing all files from each SegmentInfos.
|
private void |
deleteFile(java.lang.String fileName) |
private void |
deleteFiles(java.util.Collection<java.lang.String> names) |
(package private) void |
deleteNewFiles(java.util.Collection<java.lang.String> files)
Deletes the specified files, but only if they are new
(have not yet been incref'd).
|
(package private) void |
ensureOpen() |
boolean |
exists(java.lang.String fileName) |
private IndexFileDeleter.RefCount |
getRefCount(java.lang.String fileName) |
(package private) void |
incRef(java.util.Collection<java.lang.String> files) |
(package private) void |
incRef(SegmentInfos segmentInfos,
boolean isCommit) |
(package private) void |
incRef(java.lang.String fileName) |
(package private) static void |
inflateGens(SegmentInfos infos,
java.util.Collection<java.lang.String> files,
InfoStream infoStream)
Set all gens beyond what we currently see in the directory, to avoid double-write in cases where the previous IndexWriter did not
gracefully close/rollback (e.g.
|
(package private) boolean |
isClosed() |
private boolean |
locked() |
(package private) void |
refresh()
Writer calls this when it has hit an error and had to
roll back, to tell us that there may now be
unreferenced files in the filesystem.
|
(package private) void |
revisitPolicy()
Revisits the
IndexDeletionPolicy by calling its
IndexDeletionPolicy.onCommit(List) again with the known commits. |
private java.util.Map<java.lang.String,IndexFileDeleter.RefCount> refCounts
private java.util.List<IndexFileDeleter.CommitPoint> commits
private final java.util.List<java.lang.String> lastFiles
private java.util.List<IndexFileDeleter.CommitPoint> commitsToDelete
private final InfoStream infoStream
private final Directory directoryOrig
private final Directory directory
private final IndexDeletionPolicy policy
final boolean startingCommitDeleted
private SegmentInfos lastSegmentInfos
public static boolean VERBOSE_REF_COUNTS
private final IndexWriter writer
public IndexFileDeleter(java.lang.String[] files, Directory directoryOrig, Directory directory, IndexDeletionPolicy policy, SegmentInfos segmentInfos, InfoStream infoStream, IndexWriter writer, boolean initialIndexExists, boolean isReaderInit) throws java.io.IOException
java.io.IOException
- if there is a low-level IO errorprivate boolean locked()
static void inflateGens(SegmentInfos infos, java.util.Collection<java.lang.String> files, InfoStream infoStream)
void ensureOpen() throws AlreadyClosedException
AlreadyClosedException
boolean isClosed()
private void deleteCommits() throws java.io.IOException
java.io.IOException
void refresh() throws java.io.IOException
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
void revisitPolicy() throws java.io.IOException
IndexDeletionPolicy
by calling its
IndexDeletionPolicy.onCommit(List)
again with the known commits.
This is useful in cases where a deletion policy which holds onto index
commits is used. The application may know that some commits are not held by
the deletion policy anymore and call
IndexWriter.deleteUnusedFiles()
, which will attempt to delete the
unused commits again.java.io.IOException
public void checkpoint(SegmentInfos segmentInfos, boolean isCommit) throws java.io.IOException
java.io.IOException
void incRef(SegmentInfos segmentInfos, boolean isCommit) throws java.io.IOException
java.io.IOException
void incRef(java.util.Collection<java.lang.String> files)
void incRef(java.lang.String fileName)
void decRef(java.util.Collection<java.lang.String> files) throws java.io.IOException
java.io.IOException
private boolean decRef(java.lang.String fileName)
void decRef(SegmentInfos segmentInfos) throws java.io.IOException
java.io.IOException
public boolean exists(java.lang.String fileName)
private IndexFileDeleter.RefCount getRefCount(java.lang.String fileName)
void deleteNewFiles(java.util.Collection<java.lang.String> files) throws java.io.IOException
java.io.IOException
private void deleteFiles(java.util.Collection<java.lang.String> names) throws java.io.IOException
java.io.IOException
private void deleteFile(java.lang.String fileName) throws java.io.IOException
java.io.IOException