You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2016/06/11 15:49:23 UTC

[07/21] lucene-solr:branch_6x: LUCENE-6766: add deletions to random test

LUCENE-6766: add deletions to random test


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

Branch: refs/heads/branch_6x
Commit: a4722befb3f878faa0a5ee9752ae21070c771cf2
Parents: 3010ffa
Author: Mike McCandless <mi...@apache.org>
Authored: Sun May 8 08:03:11 2016 -0400
Committer: Mike McCandless <mi...@apache.org>
Committed: Sat Jun 11 11:48:40 2016 -0400

----------------------------------------------------------------------
 .../test/org/apache/lucene/index/TestIndexSorting.java  | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a4722bef/lucene/core/src/test/org/apache/lucene/index/TestIndexSorting.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexSorting.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexSorting.java
index e14606e..ba17131 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexSorting.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexSorting.java
@@ -1214,6 +1214,10 @@ public class TestIndexSorting extends LuceneTestCase {
     iwc2.setIndexSort(sort);
     IndexWriter w2 = new IndexWriter(dir2, iwc2);
 
+    Set<Integer> toDelete = new HashSet<>();
+
+    double deleteChance = random().nextDouble();
+
     for(int id=0;id<numDocs;id++) {
       RandomDoc docValues = new RandomDoc(id);
       docs.add(docValues);
@@ -1236,7 +1240,13 @@ public class TestIndexSorting extends LuceneTestCase {
       doc.add(new SortedDocValuesField("bytes", new BytesRef(docValues.bytesValue)));
       w1.addDocument(doc);
       w2.addDocument(doc);
-      // nocommit do some deletions
+      if (random().nextDouble() < deleteChance) {
+        toDelete.add(id);
+      }
+    }
+    for(int id : toDelete) {
+      w1.deleteDocuments(new Term("id", Integer.toString(id)));
+      w2.deleteDocuments(new Term("id", Integer.toString(id)));
     }
     DirectoryReader r1 = DirectoryReader.open(w1);
     IndexSearcher s1 = newSearcher(r1);