Lucene.Net  3.0.3
Lucene.Net is a port of the Lucene search engine library, written in C# and targeted at .NET runtime users.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Pages
Classes | Public Member Functions | Static Public Attributes | Properties | List of all members
Lucene.Net.Index.IndexFileDeleter Class Reference

More...

Inherits IDisposable.

Public Member Functions

 IndexFileDeleter (Directory directory, IndexDeletionPolicy policy, SegmentInfos segmentInfos, System.IO.StreamWriter infoStream, DocumentsWriter docWriter, HashSet< string > synced)
 Initialize the deleter: find all previous commits in the Directory, incref the files they reference, call the policy to let it delete commits. This will remove any files not referenced by any of the commits.
 
void Refresh (System.String segmentName)
 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. So we re-list the filesystem and delete such files. If segmentName is non-null, we will only delete files corresponding to that segment.
 
void Refresh ()
 
void Dispose ()
 
void Checkpoint (SegmentInfos segmentInfos, bool isCommit)
 For definition of "check point" see IndexWriter comments: "Clarification: Check Points (and commits)".
 
bool Exists (String fileName)
 

Static Public Attributes

static bool VERBOSE_REF_COUNTS = false
 Change to true to see details of reference counts when infoStream != null
 

Properties

SegmentInfos LastSegmentInfos [get]
 

Detailed Description

This class keeps track of each SegmentInfos instance that is still "live", either because it corresponds to a segments_N file in the Directory (a "commit", i.e. a committed SegmentInfos) or because it's an in-memory SegmentInfos that a writer is actively updating but has not yet committed. This class uses simple reference counting to map the live SegmentInfos instances to individual files in the Directory.

The same directory file may be referenced by more than one IndexCommit, i.e. more than one SegmentInfos. Therefore we count how many commits reference each file. When all the commits referencing a certain file have been deleted, the refcount for that file becomes zero, and the file is deleted.

A separate deletion policy interface (IndexDeletionPolicy) is consulted on creation (onInit) and once per commit (onCommit), to decide when a commit should be removed.

It is the business of the IndexDeletionPolicy to choose when to delete commit points. The actual mechanics of file deletion, retrying, etc, derived from the deletion of commit points is the business of the IndexFileDeleter.

The current default deletion policy is KeepOnlyLastCommitDeletionPolicy, which removes all prior commits when a new commit has completed. This matches the behavior before 2.2.

Note that you must hold the write.lock before instantiating this class. It opens segments_N file(s) directly with no retry logic.

Definition at line 63 of file IndexFileDeleter.cs.

Constructor & Destructor Documentation

Lucene.Net.Index.IndexFileDeleter.IndexFileDeleter ( Directory  directory,
IndexDeletionPolicy  policy,
SegmentInfos  segmentInfos,
System.IO.StreamWriter  infoStream,
DocumentsWriter  docWriter,
HashSet< string >  synced 
)

Initialize the deleter: find all previous commits in the Directory, incref the files they reference, call the policy to let it delete commits. This will remove any files not referenced by any of the commits.

<throws> CorruptIndexException if the index is corrupt </throws> <throws> IOException if there is a low-level IO error </throws>

Definition at line 126 of file IndexFileDeleter.cs.

Member Function Documentation

void Lucene.Net.Index.IndexFileDeleter.Checkpoint ( SegmentInfos  segmentInfos,
bool  isCommit 
)

For definition of "check point" see IndexWriter comments: "Clarification: Check Points (and commits)".

Writer calls this when it has made a "consistent change" to the index, meaning new files are written to the index and the in-memory SegmentInfos have been modified to point to those files.

This may or may not be a commit (segments_N may or may not have been written).

We simply incref the files referenced by the new SegmentInfos and decref the files we had previously seen (if any).

If this is a commit, we also call the policy to give it a chance to remove other commits. If any commits are removed, we decref their files as well.

Definition at line 436 of file IndexFileDeleter.cs.

void Lucene.Net.Index.IndexFileDeleter.Dispose ( )

Definition at line 384 of file IndexFileDeleter.cs.

bool Lucene.Net.Index.IndexFileDeleter.Exists ( String  fileName)

Definition at line 564 of file IndexFileDeleter.cs.

void Lucene.Net.Index.IndexFileDeleter.Refresh ( System.String  segmentName)

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. So we re-list the filesystem and delete such files. If segmentName is non-null, we will only delete files corresponding to that segment.

Definition at line 347 of file IndexFileDeleter.cs.

void Lucene.Net.Index.IndexFileDeleter.Refresh ( )

Definition at line 379 of file IndexFileDeleter.cs.

Member Data Documentation

bool Lucene.Net.Index.IndexFileDeleter.VERBOSE_REF_COUNTS = false
static

Change to true to see details of reference counts when infoStream != null

Definition at line 103 of file IndexFileDeleter.cs.

Property Documentation

SegmentInfos Lucene.Net.Index.IndexFileDeleter.LastSegmentInfos
get

Definition at line 283 of file IndexFileDeleter.cs.


The documentation for this class was generated from the following file: