|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.lucene.index.IndexDeletionPolicy
org.apache.lucene.index.SnapshotDeletionPolicy
org.apache.lucene.index.PersistentSnapshotDeletionPolicy
public class PersistentSnapshotDeletionPolicy
A SnapshotDeletionPolicy
which adds a persistence layer so that
snapshots can be maintained across the life of an application. The snapshots
are persisted in a Directory
and are committed as soon as
snapshot()
or release(IndexCommit)
is called.
NOTE: Sharing PersistentSnapshotDeletionPolicy
s that write to
the same directory across IndexWriter
s will corrupt snapshots. You
should make sure every IndexWriter
has its own
PersistentSnapshotDeletionPolicy
and that they all write to a
different Directory
. It is OK to use the same
Directory that holds the index.
This class adds a release(long)
method to
release commits from a previous snapshot's IndexCommit.getGeneration()
.
Field Summary | |
---|---|
static String |
SNAPSHOTS_PREFIX
Prefix used for the save file. |
Fields inherited from class org.apache.lucene.index.SnapshotDeletionPolicy |
---|
indexCommits, lastCommit, refCounts |
Constructor Summary | |
---|---|
PersistentSnapshotDeletionPolicy(IndexDeletionPolicy primary,
Directory dir)
PersistentSnapshotDeletionPolicy wraps another
IndexDeletionPolicy to enable flexible
snapshotting, passing IndexWriterConfig.OpenMode.CREATE_OR_APPEND
by default. |
|
PersistentSnapshotDeletionPolicy(IndexDeletionPolicy primary,
Directory dir,
IndexWriterConfig.OpenMode mode)
PersistentSnapshotDeletionPolicy wraps another
IndexDeletionPolicy to enable flexible snapshotting. |
Method Summary | |
---|---|
String |
getLastSaveFile()
Returns the file name the snapshots are currently saved to, or null if no snapshots have been saved. |
void |
release(IndexCommit commit)
Deletes a snapshotted commit. |
void |
release(long gen)
Deletes a snapshotted commit by generation. |
IndexCommit |
snapshot()
Snapshots the last commit. |
Methods inherited from class org.apache.lucene.index.SnapshotDeletionPolicy |
---|
clone, getIndexCommit, getSnapshotCount, getSnapshots, incRef, onCommit, onInit, releaseGen |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String SNAPSHOTS_PREFIX
Constructor Detail |
---|
public PersistentSnapshotDeletionPolicy(IndexDeletionPolicy primary, Directory dir) throws IOException
PersistentSnapshotDeletionPolicy
wraps another
IndexDeletionPolicy
to enable flexible
snapshotting, passing IndexWriterConfig.OpenMode.CREATE_OR_APPEND
by default.
primary
- the IndexDeletionPolicy
that is used on non-snapshotted
commits. Snapshotted commits, by definition, are not deleted until
explicitly released via release(org.apache.lucene.index.IndexCommit)
.dir
- the Directory
which will be used to persist the snapshots
information.
IOException
public PersistentSnapshotDeletionPolicy(IndexDeletionPolicy primary, Directory dir, IndexWriterConfig.OpenMode mode) throws IOException
PersistentSnapshotDeletionPolicy
wraps another
IndexDeletionPolicy
to enable flexible snapshotting.
primary
- the IndexDeletionPolicy
that is used on non-snapshotted
commits. Snapshotted commits, by definition, are not deleted until
explicitly released via release(org.apache.lucene.index.IndexCommit)
.dir
- the Directory
which will be used to persist the snapshots
information.mode
- specifies whether a new index should be created, deleting all
existing snapshots information (immediately), or open an existing
index, initializing the class with the snapshots information.
IOException
Method Detail |
---|
public IndexCommit snapshot() throws IOException
snapshot
in class SnapshotDeletionPolicy
IndexCommit
that was snapshotted.
IOException
SnapshotDeletionPolicy.snapshot()
public void release(IndexCommit commit) throws IOException
release
in class SnapshotDeletionPolicy
commit
- the commit previously returned by SnapshotDeletionPolicy.snapshot()
IOException
SnapshotDeletionPolicy.release(org.apache.lucene.index.IndexCommit)
public void release(long gen) throws IOException
IOException
IndexCommit.getGeneration()
,
SnapshotDeletionPolicy.release(org.apache.lucene.index.IndexCommit)
public String getLastSaveFile()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |