mirror of https://github.com/apache/lucene.git
Add IndexReader.undeleteAll().
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150111 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f0d57d81a3
commit
ede163802d
|
@ -52,6 +52,9 @@ $Id$
|
|||
stop most OutOfMemoryExceptions by prefix, wildcard and fuzzy
|
||||
queries which run amok. (cutting)
|
||||
|
||||
13. Add new method: IndexReader.undeleteAll(). This undeletes all
|
||||
deleted documents which still remain in the index. (cutting)
|
||||
|
||||
|
||||
1.3 RC1
|
||||
|
||||
|
|
|
@ -124,6 +124,7 @@ public class FilterIndexReader extends IndexReader {
|
|||
|
||||
public boolean isDeleted(int n) { return in.isDeleted(n); }
|
||||
public boolean hasDeletions() { return in.hasDeletions(); }
|
||||
public void undeleteAll() throws IOException { in.undeleteAll(); }
|
||||
|
||||
public byte[] norms(String f) throws IOException { return in.norms(f); }
|
||||
|
||||
|
|
|
@ -318,6 +318,9 @@ public abstract class IndexReader {
|
|||
return n;
|
||||
}
|
||||
|
||||
/** Undeletes all documents currently marked as deleted in this index.*/
|
||||
public abstract void undeleteAll() throws IOException;
|
||||
|
||||
/**
|
||||
* Closes files associated with this index.
|
||||
* Also saves any new deletions to disk.
|
||||
|
|
|
@ -185,6 +185,23 @@ final class SegmentReader extends IndexReader {
|
|||
deletedDocs.set(docNum);
|
||||
}
|
||||
|
||||
public void undeleteAll() throws IOException {
|
||||
synchronized (directory()) { // in- & inter-process sync
|
||||
new Lock.With(directory().makeLock(IndexWriter.COMMIT_LOCK_NAME),
|
||||
IndexWriter.COMMIT_LOCK_TIMEOUT) {
|
||||
public Object doBody() throws IOException {
|
||||
if (directory().fileExists(segment + ".del")) {
|
||||
directory().deleteFile(segment + ".del");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
deletedDocs = null;
|
||||
deletedDocsDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final Vector files() throws IOException {
|
||||
Vector files = new Vector(16);
|
||||
final String ext[] = new String[] {
|
||||
|
|
|
@ -125,6 +125,11 @@ final class SegmentsReader extends IndexReader
|
|||
hasDeletions = true;
|
||||
}
|
||||
|
||||
public void undeleteAll() throws IOException {
|
||||
for (int i = 0; i < readers.length; i++)
|
||||
readers[i].undeleteAll();
|
||||
}
|
||||
|
||||
private final int readerIndex(int n) { // find reader for doc n:
|
||||
int lo = 0; // search starts array
|
||||
int hi = readers.length - 1; // for first element less
|
||||
|
|
Loading…
Reference in New Issue