| 1 | /*------------------------------------------------------------------------------ |
| 2 | * Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team |
| 3 | * |
| 4 | * Distributable under the terms of either the Apache License (Version 2.0) or |
| 5 | * the GNU Lesser General Public License, as specified in the COPYING file. |
| 6 | ------------------------------------------------------------------------------*/ |
| 7 | #ifndef _lucene_index_IndexDeletionPolicy_ |
| 8 | #define _lucene_index_IndexDeletionPolicy_cxx . . $ `src/core/CLucene/index/IndexDeletionPolicy.h:8:9`! |
| 9 | |
| 10 | #include <vector> |
| 11 | #include "CLucene/util/Equators.h"cxx . . $ `<file>/src/core/CLucene/util/Equators.h`/ |
| 12 | |
| 13 | CL_NS_DEFcxx . . $ `src/shared/CLucene/SharedHeader.h:74:10`!(index) |
| 14 | |
| 15 | |
| 16 | class CLUCENE_EXPORTcxx . . $ `src/shared/CLucene/SharedHeader.h:141:10`! IndexCommitPointcxx . . $ lucene/index/IndexCommitPoint# { |
| 17 | public: |
| 18 | virtual ~cxx . . $ lucene/index/IndexCommitPoint#`~IndexCommitPoint`(49f6e7a06ebc5aa8).IndexCommitPointcxx . . $ lucene/index/IndexCommitPoint#(); |
| 19 | /** |
| 20 | * Get the segments file (<code>segments_N</code>) associated |
| 21 | * with this commit point. |
| 22 | */ |
| 23 | virtual stdcxx . . $ std/::stringcxx . . $ std/string# getSegmentsFileNamecxx . . $ lucene/index/IndexCommitPoint#getSegmentsFileName(efd28698952f529a).() = 0; |
| 24 | |
| 25 | /** |
| 26 | * Returns all index files referenced by this commit point. |
| 27 | */ |
| 28 | virtual const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#>& getFileNamescxx . . $ lucene/index/IndexCommitPoint#getFileNames(a1b7bc52201ad7c5).() = 0; |
| 29 | |
| 30 | /** |
| 31 | * Delete this commit point. |
| 32 | * <p> |
| 33 | * Upon calling this, the writer is notified that this commit |
| 34 | * point should be deleted. |
| 35 | * <p> |
| 36 | * Decision that a commit-point should be deleted is taken by the {@link IndexDeletionPolicy} in effect |
| 37 | * and therefore this should only be called by its {@link IndexDeletionPolicy#onInit onInit()} or |
| 38 | * {@link IndexDeletionPolicy#onCommit onCommit()} methods. |
| 39 | */ |
| 40 | virtual void deleteCommitPointcxx . . $ lucene/index/IndexCommitPoint#deleteCommitPoint(49f6e7a06ebc5aa8).() = 0; |
| 41 | }; |
| 42 | |
| 43 | /** |
| 44 | * <p>Expert: policy for deletion of stale {@link IndexCommitPoint index commits}. |
| 45 | * |
| 46 | * <p>Implement this interface, and pass it to one |
| 47 | * of the {@link IndexWriter} or {@link IndexReader} |
| 48 | * constructors, to customize when older |
| 49 | * {@link IndexCommitPoint point-in-time commits} |
| 50 | * are deleted from the index directory. The default deletion policy |
| 51 | * is {@link KeepOnlyLastCommitDeletionPolicy}, which always |
| 52 | * removes old commits as soon as a new commit is done (this |
| 53 | * matches the behavior before 2.2).</p> |
| 54 | * |
| 55 | * <p>One expected use case for this (and the reason why it |
| 56 | * was first created) is to work around problems with an |
| 57 | * index directory accessed via filesystems like NFS because |
| 58 | * NFS does not provide the "delete on last close" semantics |
| 59 | * that Lucene's "point in time" search normally relies on. |
| 60 | * By implementing a custom deletion policy, such as "a |
| 61 | * commit is only removed once it has been stale for more |
| 62 | * than X minutes", you can give your readers time to |
| 63 | * refresh to the new commit before {@link IndexWriter} |
| 64 | * removes the old commits. Note that doing so will |
| 65 | * increase the storage requirements of the index. See <a |
| 66 | * target="top" |
| 67 | * href="http://issues.apache.org/jira/browse/LUCENE-710">LUCENE-710</a> |
| 68 | * for details.</p> |
| 69 | */ |
| 70 | class CLUCENE_EXPORTcxx . . $ `src/shared/CLucene/SharedHeader.h:141:10`! IndexDeletionPolicycxx . . $ lucene/index/IndexDeletionPolicy#: public CL_NScxx . . $ `src/shared/CLucene/SharedHeader.h:83:10`!(util)::NamedObjectcxx . . $ lucene/util/NamedObject#{ |
| 71 | public: |
| 72 | virtual ~cxx . . $ lucene/index/IndexDeletionPolicy#`~IndexDeletionPolicy`(49f6e7a06ebc5aa8).IndexDeletionPolicycxx . . $ lucene/index/IndexDeletionPolicy#(); |
| 73 | |
| 74 | /** |
| 75 | * <p>This is called once when a writer is first |
| 76 | * instantiated to give the policy a chance to remove old |
| 77 | * commit points.</p> |
| 78 | * |
| 79 | * <p>The writer locates all index commits present in the |
| 80 | * index directory and calls this method. The policy may |
| 81 | * choose to delete some of the commit points, doing so by |
| 82 | * calling method {@link IndexCommitPoint#delete delete()} |
| 83 | * of {@link IndexCommitPoint}.</p> |
| 84 | * |
| 85 | * <p><u>Note:</u> the last CommitPoint is the most recent one, |
| 86 | * i.e. the "front index state". Be careful not to delete it, |
| 87 | * unless you know for sure what you are doing, and unless |
| 88 | * you can afford to lose the index content while doing that. |
| 89 | * |
| 90 | * @param commits List of current |
| 91 | * {@link IndexCommitPoint point-in-time commits}, |
| 92 | * sorted by age (the 0th one is the oldest commit). |
| 93 | */ |
| 94 | virtual void onInitcxx . . $ lucene/index/IndexDeletionPolicy#onInit(63b767b3865e7df4).(stdcxx . . $ std/::vectorcxx . . $ std/vector#<IndexCommitPointcxx . . $ lucene/index/IndexCommitPoint#*>& commits) = 0; |
| 95 | |
| 96 | /** |
| 97 | * <p>This is called each time the writer completed a commit. |
| 98 | * This gives the policy a chance to remove old commit points |
| 99 | * with each commit.</p> |
| 100 | * |
| 101 | * <p>The policy may now choose to delete old commit points |
| 102 | * by calling method {@link IndexCommitPoint#delete delete()} |
| 103 | * of {@link IndexCommitPoint}.</p> |
| 104 | * |
| 105 | * <p>If writer has <code>autoCommit = true</code> then |
| 106 | * this method will in general be called many times during |
| 107 | * one instance of {@link IndexWriter}. If |
| 108 | * <code>autoCommit = false</code> then this method is |
| 109 | * only called once when {@link IndexWriter#close} is |
| 110 | * called, or not at all if the {@link IndexWriter#abort} |
| 111 | * is called. |
| 112 | * |
| 113 | * <p><u>Note:</u> the last CommitPoint is the most recent one, |
| 114 | * i.e. the "front index state". Be careful not to delete it, |
| 115 | * unless you know for sure what you are doing, and unless |
| 116 | * you can afford to lose the index content while doing that. |
| 117 | * |
| 118 | * @param commits List of {@link IndexCommitPoint}, |
| 119 | * sorted by age (the 0th one is the oldest commit). |
| 120 | */ |
| 121 | virtual void onCommitcxx . . $ lucene/index/IndexDeletionPolicy#onCommit(63b767b3865e7df4).(stdcxx . . $ std/::vectorcxx . . $ std/vector#<IndexCommitPointcxx . . $ lucene/index/IndexCommitPoint#*>& commits) = 0; |
| 122 | }; |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | /** |
| 128 | * This {@link IndexDeletionPolicy} implementation that |
| 129 | * keeps only the most recent commit and immediately removes |
| 130 | * all prior commits after a new commit is done. This is |
| 131 | * the default deletion policy. |
| 132 | */ |
| 133 | |
| 134 | class CLUCENE_EXPORTcxx . . $ `src/shared/CLucene/SharedHeader.h:141:10`! KeepOnlyLastCommitDeletionPolicycxx . . $ lucene/index/KeepOnlyLastCommitDeletionPolicy#: public IndexDeletionPolicycxx . . $ lucene/index/IndexDeletionPolicy# { |
| 135 | public: |
| 136 | virtual ~cxx . . $ lucene/index/KeepOnlyLastCommitDeletionPolicy#`~KeepOnlyLastCommitDeletionPolicy`(49f6e7a06ebc5aa8).KeepOnlyLastCommitDeletionPolicycxx . . $ lucene/index/KeepOnlyLastCommitDeletionPolicy#(); |
| 137 | /** |
| 138 | * Deletes all commits except the most recent one. |
| 139 | */ |
| 140 | void onInitcxx . . $ lucene/index/KeepOnlyLastCommitDeletionPolicy#onInit(63b767b3865e7df4).(stdcxx . . $ std/::vectorcxx . . $ std/vector#<IndexCommitPointcxx . . $ lucene/index/IndexCommitPoint#*>& commits); |
| 141 | |
| 142 | /** |
| 143 | * Deletes all commits except the most recent one. |
| 144 | */ |
| 145 | void onCommitcxx . . $ lucene/index/KeepOnlyLastCommitDeletionPolicy#onCommit(63b767b3865e7df4).(stdcxx . . $ std/::vectorcxx . . $ std/vector#<IndexCommitPointcxx . . $ lucene/index/IndexCommitPoint#*>& commits); |
| 146 | |
| 147 | static const char* getClassNamecxx . . $ lucene/index/KeepOnlyLastCommitDeletionPolicy#getClassName(33a1f659e94feb42).(); |
| 148 | const char* getObjectNamecxx . . $ lucene/index/KeepOnlyLastCommitDeletionPolicy#getObjectName(a9f41ea0e82d88cf).() const; |
| 149 | }; |
| 150 | |
| 151 | CL_NS_ENDcxx . . $ `src/shared/CLucene/SharedHeader.h:77:10`! |
| 152 | #endif |