public class PostponeCommitDeletionPolicy implements IndexDeletionPolicy {
private final static long deletionPostPone = 600000;
public void onInit(List<? extends IndexCommit> commits) {
// Note that commits.size() should normally be 1:
onCommit(commits);
}
/**
* delete commits after deletePostPone ms.
*/
public void onCommit(List<? extends IndexCommit> commits) {
// Note that commits.size() should normally be 2 (if not
// called by onInit above):
int size = commits.size();
try {
long lastCommitTimestamp = commits.get(commits.size() -
1).getTimestamp();
for (int i = 0; i < size - 1; i++) {
if (lastCommitTimestamp -
commits.get(i).getTimestamp() >
deletionPostPone) {
commits.get(i).delete();
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
----------------------------------
indexWriterConfig.setIndexDeletionPolicy(new
PostponeCommitDeletionPolicy());
----------------------------------
and I use a time task(10 minutes) to reopen indexsearcher,but still read
past EOF...the trace:
java.io.IOException: read past EOF
at
org.apache.lucene.store.BufferedIndexInput.refill(BufferedIndexInput.java:207)
at
org.apache.lucene.store.BufferedIndexInput.readByte(BufferedIndexInput.java:39)
at org.apache.lucene.store.DataInput.readInt(DataInput.java:84)
at
org.apache.lucene.store.BufferedIndexInput.readInt(BufferedIndexInput.java:153)
at
org.apache.lucene.index.TermVectorsReader.checkValidFormat(TermVectorsReader.java:197)
at
org.apache.lucene.index.TermVectorsReader.<init>(TermVectorsReader.java:86)
at
org.apache.lucene.index.SegmentCoreReaders.openDocStores(SegmentCoreReaders.java:221)
at org.apache.lucene.index.SegmentReader.get(SegmentReader.java:117)
at org.apache.lucene.index.SegmentReader.get(SegmentReader.java:93)
at
org.apache.lucene.index.DirectoryReader.<init>(DirectoryReader.java:113)
at
org.apache.lucene.index.ReadOnlyDirectoryReader.<init>(ReadOnlyDirectoryReader.java:29)
at
org.apache.lucene.index.DirectoryReader$1.doBody(DirectoryReader.java:81)
at
org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:754)
at
org.apache.lucene.index.DirectoryReader.open(DirectoryReader.java:75)
at org.apache.lucene.index.IndexReader.open(IndexReader.java:421)
at org.apache.lucene.index.IndexReader.open(IndexReader.java:281)
at
org.apache.lucene.search.IndexSearcher.<init>(IndexSearcher.java:89)
at
com.ableskysearch.migration.timertask.ReopenIndexSearcherTask.runAsPeriod(ReopenIndexSearcherTask.java:40)
--
View this message in context:
http://lucene.472066.n3.nabble.com/Why-read-past-EOF-tp3639401p3724672.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]