lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject lucene-solr:branch_7x: LUCENE-8243: fix IndexWriter.addIndexes(Directory[]) to properly preserve index file names for updated doc values fields
Date Sun, 08 Apr 2018 15:15:08 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7x aaddf2ee4 -> 27ad64d67


LUCENE-8243: fix IndexWriter.addIndexes(Directory[]) to properly preserve index file names
for updated doc values fields


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/27ad64d6
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/27ad64d6
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/27ad64d6

Branch: refs/heads/branch_7x
Commit: 27ad64d672670d1ece372fbbb20847d6bd9f2a38
Parents: aaddf2e
Author: Mike McCandless <mikemccand@apache.org>
Authored: Sun Apr 8 11:14:51 2018 -0400
Committer: Mike McCandless <mikemccand@apache.org>
Committed: Sun Apr 8 11:14:51 2018 -0400

----------------------------------------------------------------------
 lucene/CHANGES.txt                              |  4 +
 .../org/apache/lucene/index/IndexWriter.java    |  9 ++-
 .../org/apache/lucene/index/TestAddIndexes.java | 81 ++++++++++++++++++++
 3 files changed, 91 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/27ad64d6/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 1d5fe56..131ea78 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -39,6 +39,10 @@ Bug Fixes
 * LUCENE-8236: Filter duplicated points when creating GeoPath shapes
   to avoid creation of bogus planes. (Ignacio Vera)
 
+* LUCENE-8243: IndexWriter.addIndexes(Directory[]) did not properly preserve
+  index file names for updated doc values fields (Simon Willnauer,
+  Michael McCandless)
+
 Other
 
 * LUCENE-8228: removed obsolete IndexDeletionPolicy clone() requirements from

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/27ad64d6/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
index 4f6e706..94d6feb 100644
--- a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
@@ -3209,8 +3209,10 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable
{
                                           info.info.getDiagnostics(), info.info.getId(),
info.info.getAttributes(), info.info.getIndexSort());
     SegmentCommitInfo newInfoPerCommit = new SegmentCommitInfo(newInfo, info.getDelCount(),
info.getDelGen(), 
                                                                info.getFieldInfosGen(), info.getDocValuesGen());
-    
-    newInfo.setFiles(info.files());
+
+    newInfo.setFiles(info.info.files());
+    newInfoPerCommit.setFieldInfosFiles(info.getFieldInfosFiles());
+    newInfoPerCommit.setDocValuesUpdatesFiles(info.getDocValuesUpdatesFiles());
 
     boolean success = false;
 
@@ -3230,7 +3232,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable
{
       }
     }
 
-    assert copiedFiles.equals(newInfoPerCommit.files());
+    assert copiedFiles.equals(newInfoPerCommit.files()): "copiedFiles=" + copiedFiles + "
vs " + newInfoPerCommit.files();
     
     return newInfoPerCommit;
   }
@@ -3571,6 +3573,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable
{
     return seqNo;
   }
 
+  @SuppressWarnings("try")
   private final void finishCommit() throws IOException {
 
     boolean commitCompleted = false;

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/27ad64d6/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java b/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java
index 876328a..48a28e2 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java
@@ -1332,4 +1332,85 @@ public class TestAddIndexes extends LuceneTestCase {
     assertEquals("cannot change index sort from <int: \"foo\"> to <string: \"foo\">",
message);
     IOUtils.close(r1, dir1, w2, dir2);
   }
+
+  public void testAddIndexesDVUpdateSameSegmentName() throws Exception {
+    Directory dir1 = newDirectory();
+    IndexWriterConfig iwc1 = newIndexWriterConfig(new MockAnalyzer(random()));
+    IndexWriter w1 = new IndexWriter(dir1, iwc1);
+    Document doc = new Document();
+    doc.add(new StringField("id", "1", Field.Store.YES));
+    doc.add(new StringField("version", "1", Field.Store.YES));
+    doc.add(new NumericDocValuesField("soft_delete", 1));
+    w1.addDocument(doc);
+    w1.flush();
+
+    w1.updateDocValues(new Term("id", "1"), new NumericDocValuesField("soft_delete", 1));
+    w1.commit();
+    w1.close();
+
+    IndexWriterConfig iwc2 = newIndexWriterConfig(new MockAnalyzer(random()));
+    Directory dir2 = newDirectory();
+    IndexWriter w2 = new IndexWriter(dir2, iwc2);
+    w2.addIndexes(dir1);
+    w2.commit();
+    w2.close();
+
+    if (VERBOSE) {
+      System.out.println("\nTEST: now open w3");
+    }
+    IndexWriterConfig iwc3 = newIndexWriterConfig(new MockAnalyzer(random()));
+    if (VERBOSE) {
+      iwc3.setInfoStream(System.out);
+    }        
+    IndexWriter w3 = new IndexWriter(dir2, iwc3);
+    w3.close();
+
+    iwc3 = newIndexWriterConfig(new MockAnalyzer(random()));
+    w3 = new IndexWriter(dir2, iwc3);
+    w3.close();
+    dir1.close();
+    dir2.close();
+  }
+
+  public void testAddIndexesDVUpdateNewSegmentName() throws Exception {
+    Directory dir1 = newDirectory();
+    IndexWriterConfig iwc1 = newIndexWriterConfig(new MockAnalyzer(random()));
+    IndexWriter w1 = new IndexWriter(dir1, iwc1);
+    Document doc = new Document();
+    doc.add(new StringField("id", "1", Field.Store.YES));
+    doc.add(new StringField("version", "1", Field.Store.YES));
+    doc.add(new NumericDocValuesField("soft_delete", 1));
+    w1.addDocument(doc);
+    w1.flush();
+
+    w1.updateDocValues(new Term("id", "1"), new NumericDocValuesField("soft_delete", 1));
+    w1.commit();
+    w1.close();
+
+    IndexWriterConfig iwc2 = newIndexWriterConfig(new MockAnalyzer(random()));
+    Directory dir2 = newDirectory();
+    IndexWriter w2 = new IndexWriter(dir2, iwc2);
+    w2.addDocument(new Document());
+    w2.commit();
+    
+    w2.addIndexes(dir1);
+    w2.commit();
+    w2.close();
+
+    if (VERBOSE) {
+      System.out.println("\nTEST: now open w3");
+    }
+    IndexWriterConfig iwc3 = newIndexWriterConfig(new MockAnalyzer(random()));
+    if (VERBOSE) {
+      iwc3.setInfoStream(System.out);
+    }        
+    IndexWriter w3 = new IndexWriter(dir2, iwc3);
+    w3.close();
+
+    iwc3 = newIndexWriterConfig(new MockAnalyzer(random()));
+    w3 = new IndexWriter(dir2, iwc3);
+    w3.close();
+    dir1.close();
+    dir2.close();
+  }
 }


Mime
View raw message