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/05/13 10:05:00 UTC
[17/25] lucene-solr:master: 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/fa37241e
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/fa37241e
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/fa37241e
Branch: refs/heads/master
Commit: fa37241e784e0479da1637f863e07f1d909f40a9
Parents: 87690f8
Author: Mike McCandless <mi...@apache.org>
Authored: Sun May 8 08:03:11 2016 -0400
Committer: Mike McCandless <mi...@apache.org>
Committed: Sun May 8 08:03:11 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/fa37241e/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);