lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r691952 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/index/IndexCommit.java src/test/org/apache/lucene/index/TestDeletionPolicy.java
Date Thu, 04 Sep 2008 09:40:30 GMT
Author: mikemccand
Date: Thu Sep  4 02:40:29 2008
New Revision: 691952

URL: http://svn.apache.org/viewvc?rev=691952&view=rev
Log:
LUCENE-1375: added IndexCommit.getTimestamp method

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/src/java/org/apache/lucene/index/IndexCommit.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestDeletionPolicy.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=691952&r1=691951&r2=691952&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Thu Sep  4 02:40:29 2008
@@ -145,6 +145,10 @@
     constructor and fields from package to protected. (Shai Erera
     via Doron Cohen) 
 
+24. LUCENE-1375: Added convencience method IndexCommit.getTimestamp,
+    which is equivalent to
+    getDirectory().fileModified(getSegmentsFileName()).  (Mike McCandless)
+
 Bug fixes
     
  1. LUCENE-1134: Fixed BooleanQuery.rewrite to only optimize a single 

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/IndexCommit.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/IndexCommit.java?rev=691952&r1=691951&r2=691952&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/IndexCommit.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/IndexCommit.java Thu Sep  4 02:40:29
2008
@@ -112,4 +112,12 @@
   public long getGeneration() {
     throw new UnsupportedOperationException("This IndexCommit does not support this method.");
   }
+
+  /** Convenience method that returns the last modified time
+   *  of the segments_N file corresponding to this index
+   *  commit, equivalent to
+   *  getDirectory().fileModified(getSegmentsFileName()). */
+  public long getTimestamp() throws IOException {
+    return getDirectory().fileModified(getSegmentsFileName());
+  }
 }

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestDeletionPolicy.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestDeletionPolicy.java?rev=691952&r1=691951&r2=691952&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestDeletionPolicy.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestDeletionPolicy.java Thu Sep  4
02:40:29 2008
@@ -42,19 +42,24 @@
 
 public class TestDeletionPolicy extends LuceneTestCase
 {
-  private void verifyCommitOrder(List commits) {
+  private void verifyCommitOrder(List commits) throws IOException {
     final IndexCommit firstCommit = ((IndexCommit) commits.get(0));
     long last = SegmentInfos.generationFromSegmentsFileName(firstCommit.getSegmentsFileName());
     assertEquals(last, firstCommit.getGeneration());
     long lastVersion = firstCommit.getVersion();
+    long lastTimestamp = firstCommit.getTimestamp();
     for(int i=1;i<commits.size();i++) {
       final IndexCommit commit = ((IndexCommit) commits.get(i));
       long now = SegmentInfos.generationFromSegmentsFileName(commit.getSegmentsFileName());
       long nowVersion = commit.getVersion();
+      long nowTimestamp = commit.getTimestamp();
       assertTrue("SegmentInfos commits are out-of-order", now > last);
       assertTrue("SegmentInfos versions are out-of-order", nowVersion > lastVersion);
+      assertTrue("SegmentInfos timestamps are out-of-order: now=" + nowTimestamp + " vs last="
+ lastTimestamp, nowTimestamp >= lastTimestamp);
       assertEquals(now, commit.getGeneration());
       last = now;
+      lastVersion = nowVersion;
+      lastTimestamp = nowTimestamp;
     }
   }
 
@@ -62,7 +67,7 @@
     int numOnInit;
     int numOnCommit;
     Directory dir;
-    public void onInit(List commits) {
+    public void onInit(List commits) throws IOException {
       verifyCommitOrder(commits);
       numOnInit++;
     }
@@ -83,7 +88,7 @@
   class KeepNoneOnInitDeletionPolicy implements IndexDeletionPolicy {
     int numOnInit;
     int numOnCommit;
-    public void onInit(List commits) {
+    public void onInit(List commits) throws IOException {
       verifyCommitOrder(commits);
       numOnInit++;
       // On init, delete all commit points:
@@ -94,7 +99,7 @@
         assertTrue(commit.isDeleted());
       }
     }
-    public void onCommit(List commits) {
+    public void onCommit(List commits) throws IOException {
       verifyCommitOrder(commits);
       int size = commits.size();
       // Delete all but last one:
@@ -116,14 +121,14 @@
       this.numToKeep = numToKeep;
     }
 
-    public void onInit(List commits) {
+    public void onInit(List commits) throws IOException {
       verifyCommitOrder(commits);
       numOnInit++;
       // do no deletions on init
       doDeletes(commits, false);
     }
 
-    public void onCommit(List commits) {
+    public void onCommit(List commits) throws IOException {
       verifyCommitOrder(commits);
       doDeletes(commits, true);
     }



Mime
View raw message