~slub.team/goobi-indexserver/3.x

« back to all changes in this revision

Viewing changes to lucene/src/java/org/apache/lucene/index/IndexDeletionPolicy.java

  • Committer: Sebastian Meyer
  • Date: 2012-08-03 09:12:40 UTC
  • Revision ID: sebastian.meyer@slub-dresden.de-20120803091240-x6861b0vabq1xror
Remove Lucene and Solr source code and add patches instead
Fix Bug #985487: Auto-suggestion for the search interface

Show diffs side-by-side

added added

removed removed

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