Merge pull request #409 from Alkarex/patch-1
[mono.git] / mcs / tools / monkeydoc / Lucene.Net / Lucene.Net / Index / IndexDeletionPolicy.cs
1 /* 
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements.  See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License.  You may obtain a copy of the License at
8  * 
9  * http://www.apache.org/licenses/LICENSE-2.0
10  * 
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 using System;
19
20 namespace Mono.Lucene.Net.Index
21 {
22         
23         /// <summary> <p/>Expert: policy for deletion of stale {@link IndexCommit index commits}. 
24         /// 
25         /// <p/>Implement this interface, and pass it to one
26         /// of the {@link IndexWriter} or {@link IndexReader}
27         /// constructors, to customize when older
28         /// {@link IndexCommit point-in-time commits}
29         /// are deleted from the index directory.  The default deletion policy
30         /// is {@link KeepOnlyLastCommitDeletionPolicy}, which always
31         /// removes old commits as soon as a new commit is done (this
32         /// matches the behavior before 2.2).<p/>
33         /// 
34         /// <p/>One expected use case for this (and the reason why it
35         /// was first created) is to work around problems with an
36         /// index directory accessed via filesystems like NFS because
37         /// NFS does not provide the "delete on last close" semantics
38         /// that Lucene's "point in time" search normally relies on.
39         /// By implementing a custom deletion policy, such as "a
40         /// commit is only removed once it has been stale for more
41         /// than X minutes", you can give your readers time to
42         /// refresh to the new commit before {@link IndexWriter}
43         /// removes the old commits.  Note that doing so will
44         /// increase the storage requirements of the index.  See <a
45         /// target="top"
46         /// href="http://issues.apache.org/jira/browse/LUCENE-710">LUCENE-710</a>
47         /// for details.<p/>
48         /// </summary>
49         
50         public interface IndexDeletionPolicy
51         {
52                 
53                 /// <summary> <p/>This is called once when a writer is first
54                 /// instantiated to give the policy a chance to remove old
55                 /// commit points.<p/>
56                 /// 
57                 /// <p/>The writer locates all index commits present in the 
58                 /// index directory and calls this method.  The policy may 
59                 /// choose to delete some of the commit points, doing so by
60                 /// calling method {@link IndexCommit#delete delete()} 
61                 /// of {@link IndexCommit}.<p/>
62                 /// 
63                 /// <p/><u>Note:</u> the last CommitPoint is the most recent one,
64                 /// i.e. the "front index state". Be careful not to delete it,
65                 /// unless you know for sure what you are doing, and unless 
66                 /// you can afford to lose the index content while doing that. 
67                 /// 
68                 /// </summary>
69                 /// <param name="commits">List of current 
70                 /// {@link IndexCommit point-in-time commits},
71                 /// sorted by age (the 0th one is the oldest commit).
72                 /// </param>
73                 void  OnInit(System.Collections.IList commits);
74                 
75                 /// <summary> <p/>This is called each time the writer completed a commit.
76                 /// This gives the policy a chance to remove old commit points
77                 /// with each commit.<p/>
78                 /// 
79                 /// <p/>The policy may now choose to delete old commit points 
80                 /// by calling method {@link IndexCommit#delete delete()} 
81                 /// of {@link IndexCommit}.<p/>
82                 /// 
83                 /// <p/>If writer has <code>autoCommit = true</code> then
84                 /// this method will in general be called many times during
85                 /// one instance of {@link IndexWriter}.  If
86                 /// <code>autoCommit = false</code> then this method is
87                 /// only called once when {@link IndexWriter#close} is
88                 /// called, or not at all if the {@link IndexWriter#abort}
89                 /// is called. 
90                 /// 
91                 /// <p/><u>Note:</u> the last CommitPoint is the most recent one,
92                 /// i.e. the "front index state". Be careful not to delete it,
93                 /// unless you know for sure what you are doing, and unless 
94                 /// you can afford to lose the index content while doing that.
95                 /// 
96                 /// </summary>
97                 /// <param name="commits">List of {@link IndexCommit},
98                 /// sorted by age (the 0th one is the oldest commit).
99                 /// </param>
100                 void  OnCommit(System.Collections.IList commits);
101         }
102 }