Return-Path: Delivered-To: apmail-lucene-java-commits-archive@www.apache.org Received: (qmail 82899 invoked from network); 28 May 2008 11:00:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 May 2008 11:00:58 -0000 Received: (qmail 85193 invoked by uid 500); 28 May 2008 11:00:59 -0000 Delivered-To: apmail-lucene-java-commits-archive@lucene.apache.org Received: (qmail 85148 invoked by uid 500); 28 May 2008 11:00:59 -0000 Mailing-List: contact java-commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-dev@lucene.apache.org Delivered-To: mailing list java-commits@lucene.apache.org Received: (qmail 85139 invoked by uid 99); 28 May 2008 11:00:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 May 2008 04:00:59 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 May 2008 11:00:12 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id DAEFB2388A0F; Wed, 28 May 2008 04:00:33 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r660904 - in /lucene/java/trunk: ./ src/java/org/apache/lucene/index/ src/test/org/apache/lucene/index/ Date: Wed, 28 May 2008 11:00:33 -0000 To: java-commits@lucene.apache.org From: mikemccand@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080528110033.DAEFB2388A0F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mikemccand Date: Wed May 28 04:00:33 2008 New Revision: 660904 URL: http://svn.apache.org/viewvc?rev=660904&view=rev Log: LUCENE-1288: add getVersion, getGeneration to IndexCommit Modified: lucene/java/trunk/CHANGES.txt lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryIndexReader.java lucene/java/trunk/src/java/org/apache/lucene/index/IndexCommit.java lucene/java/trunk/src/java/org/apache/lucene/index/IndexFileDeleter.java lucene/java/trunk/src/java/org/apache/lucene/index/SnapshotDeletionPolicy.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=660904&r1=660903&r2=660904&view=diff ============================================================================== --- lucene/java/trunk/CHANGES.txt (original) +++ lucene/java/trunk/CHANGES.txt Wed May 28 04:00:33 2008 @@ -71,6 +71,11 @@ and remove all references to these classes from the core. Also update demos and tutorials. (Michael Busch) +10. LUCENE-1288: Add getVersion() and getGeneration() to IndexCommit. + getVersion() returns the same value that IndexReader.getVersion() + returns when the reader is opened on the same commit. (Jason + Rutherglen via 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/DirectoryIndexReader.java URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryIndexReader.java?rev=660904&r1=660903&r2=660904&view=diff ============================================================================== --- lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryIndexReader.java (original) +++ lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryIndexReader.java Wed May 28 04:00:33 2008 @@ -343,6 +343,8 @@ private String segmentsFileName; Collection files; Directory dir; + long generation; + long version; ReaderCommit(SegmentInfos infos, Directory dir) throws IOException { segmentsFileName = infos.getCurrentSegmentFileName(); @@ -355,6 +357,8 @@ if (info.dir == dir) files.addAll(info.files()); } + version = infos.getVersion(); + generation = infos.getGeneration(); } public String getSegmentsFileName() { return segmentsFileName; @@ -365,6 +369,12 @@ public Directory getDirectory() { return dir; } + public long getVersion() { + return version; + } + public long getGeneration() { + return generation; + } } /** 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=660904&r1=660903&r2=660904&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 Wed May 28 04:00:33 2008 @@ -89,4 +89,17 @@ public int hashCode() { return getDirectory().hashCode() + getSegmentsFileName().hashCode(); } + + /** Returns the version for this IndexCommit. This is the + same value that {@link IndexReader#getVersion} would + return if it were opened on this commit. */ + public long getVersion() { + throw new UnsupportedOperationException("This IndexCommit does not support this method."); + } + + /** Returns the generation (the _N in segments_N) for this + IndexCommit */ + public long getGeneration() { + throw new UnsupportedOperationException("This IndexCommit does not support this method."); + } } Modified: lucene/java/trunk/src/java/org/apache/lucene/index/IndexFileDeleter.java URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/IndexFileDeleter.java?rev=660904&r1=660903&r2=660904&view=diff ============================================================================== --- lucene/java/trunk/src/java/org/apache/lucene/index/IndexFileDeleter.java (original) +++ lucene/java/trunk/src/java/org/apache/lucene/index/IndexFileDeleter.java Wed May 28 04:00:33 2008 @@ -577,11 +577,15 @@ boolean deleted; Directory directory; Collection commitsToDelete; + long version; + long generation; public CommitPoint(Collection commitsToDelete, Directory directory, SegmentInfos segmentInfos) throws IOException { this.directory = directory; this.commitsToDelete = commitsToDelete; segmentsFileName = segmentInfos.getCurrentSegmentFileName(); + version = segmentInfos.getVersion(); + generation = segmentInfos.getGeneration(); int size = segmentInfos.size(); files = new ArrayList(size); files.add(segmentsFileName); @@ -606,6 +610,14 @@ return directory; } + public long getVersion() { + return version; + } + + public long getGeneration() { + return generation; + } + /** * Called only be the deletion policy, to remove this * commit point from the index. Modified: lucene/java/trunk/src/java/org/apache/lucene/index/SnapshotDeletionPolicy.java URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/SnapshotDeletionPolicy.java?rev=660904&r1=660903&r2=660904&view=diff ============================================================================== --- lucene/java/trunk/src/java/org/apache/lucene/index/SnapshotDeletionPolicy.java (original) +++ lucene/java/trunk/src/java/org/apache/lucene/index/SnapshotDeletionPolicy.java Wed May 28 04:00:33 2008 @@ -109,6 +109,12 @@ cp.delete(); } } + public long getVersion() { + return cp.getVersion(); + } + public long getGeneration() { + return cp.getGeneration(); + } } private List wrapCommits(List commits) { 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=660904&r1=660903&r2=660904&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 Wed May 28 04:00:33 2008 @@ -42,10 +42,17 @@ public class TestDeletionPolicy extends LuceneTestCase { private void verifyCommitOrder(List commits) { - long last = SegmentInfos.generationFromSegmentsFileName(((IndexCommit) commits.get(0)).getSegmentsFileName()); + final IndexCommit firstCommit = ((IndexCommit) commits.get(0)); + long last = SegmentInfos.generationFromSegmentsFileName(firstCommit.getSegmentsFileName()); + assertEquals(last, firstCommit.getGeneration()); + long lastVersion = firstCommit.getVersion(); for(int i=1;i last); + assertTrue("SegmentInfos versions are out-of-order", nowVersion > lastVersion); + assertEquals(now, commit.getGeneration()); last = now; } }