lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r770615 - in /lucene/java/trunk: CHANGES.txt common-build.xml src/java/org/apache/lucene/index/IndexWriter.java src/test/org/apache/lucene/index/TestDeletionPolicy.java
Date Fri, 01 May 2009 10:25:53 GMT
Author: mikemccand
Date: Fri May  1 10:25:52 2009
New Revision: 770615

URL: http://svn.apache.org/viewvc?rev=770615&view=rev
Log:
LUCENE-1624: don't write a new empty commit when create=true and autoCommit=false on creating
IndexWriter, unless dir has no index yet

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/common-build.xml
    lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.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=770615&r1=770614&r2=770615&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Fri May  1 10:25:52 2009
@@ -57,6 +57,11 @@
     compatible behavior) but in 3.0 will be hardwired to true.  (Shon
     Vella via Mike McCandless).
 
+ 4. LUCENE-1624: If you open IndexWriter with create=true and
+    autoCommit=false on an existing index, IndexWriter no longer
+    writes an empty commit when it's created.  (Paul Taylor via Mike
+    McCandless)
+
 API Changes
 
 1. LUCENE-1419: Add expert API to set custom indexing chain. This API is 

Modified: lucene/java/trunk/common-build.xml
URL: http://svn.apache.org/viewvc/lucene/java/trunk/common-build.xml?rev=770615&r1=770614&r2=770615&view=diff
==============================================================================
--- lucene/java/trunk/common-build.xml (original)
+++ lucene/java/trunk/common-build.xml Fri May  1 10:25:52 2009
@@ -41,7 +41,7 @@
   <property name="name" value="${ant.project.name}"/>
   <property name="Name" value="Lucene"/>
   <property name="version" value="2.9-dev"/>
-  <property name="compatibility.tag" value="lucene_2_4_back_compat_tests_20090428"/>
+  <property name="compatibility.tag" value="lucene_2_4_back_compat_tests_20090501"/>
   <property name="spec.version" value="${version}"/>	
   <property name="year" value="2000-${current.year}"/>
   <property name="final.name" value="lucene-${name}-${version}"/>

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java?rev=770615&r1=770614&r2=770615&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java Fri May  1 10:25:52
2009
@@ -1445,13 +1445,27 @@
         // against an index that's currently open for
         // searching.  In this case we write the next
         // segments_N file with no segments:
+        boolean doCommit;
         try {
           segmentInfos.read(directory);
           segmentInfos.clear();
+          doCommit = false;
         } catch (IOException e) {
           // Likely this means it's a fresh directory
+          doCommit = true;
+        }
+
+        if (autoCommit || doCommit) {
+          // Always commit if autoCommit=true, else only
+          // commit if there is no segments file in this dir
+          // already.
+          segmentInfos.commit(directory);
+          synced.addAll(segmentInfos.files(directory, true));
+        } else {
+          // Record that we have a change (zero out all
+          // segments) pending:
+          changeCount++;
         }
-        segmentInfos.commit(directory);
       } else {
         segmentInfos.read(directory);
 

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=770615&r1=770614&r2=770615&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 Fri May  1
10:25:52 2009
@@ -702,7 +702,7 @@
 
       assertEquals(1+3*(N+1), policy.numOnInit);
       if (!autoCommit)
-        assertEquals(2*(N+1), policy.numOnCommit);
+        assertEquals(3*(N+1), policy.numOnCommit);
 
       IndexSearcher searcher = new IndexSearcher(dir);
       ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;



Mime
View raw message