Instead of .getVersion() you should use .getTimestamp()... version is not "really" a timestamp. (Though, really, you should store your own timestamp inside the commit userData, and retrieve that, instead... the getTimestamp API will be deprecated in 3.6.0).
Also, you may need to implement onInit, in case you close/open a writer while readers stay open, you still want to ensure the commits are preserved. Instead of using "present", I think you should set that to the time of the last commit. Ie, you always compare older commits against the timestamp of the most recent commit. This way you can use the same function in onInit and onCommit. Mike McCandless http://blog.mikemccandless.com On Thu, Feb 2, 2012 at 10:17 PM, superruiye <superru...@gmail.com> wrote: > eg,I implement IndexDeletionPolicy and the onCommit(): > > 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(); > long present = System.currentTimeMillis(); > for (int i = 0; i < size - 1; i++) { > if (present - commits.get(i).getVersion() > > deletionPostPone){ > //deletionPostPone=600000 > commits.get(i).delete(); > } > } > } > > -- > View this message in context: > http://lucene.472066.n3.nabble.com/Why-read-past-EOF-tp3639401p3712006.html > Sent from the Lucene - Java Users mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org