dnhatn commented on a change in pull request #140:
URL: https://github.com/apache/lucene/pull/140#discussion_r648815760



##########
File path: 
lucene/test-framework/src/java/org/apache/lucene/index/BaseTermVectorsFormatTestCase.java
##########
@@ -667,43 +673,92 @@ public void testRandom() throws IOException {
     dir.close();
   }
 
-  public void testMerge() throws IOException {
+  private void doTestMerge(Sort indexSort) throws IOException {
     final RandomDocumentFactory docFactory = new RandomDocumentFactory(5, 20);
     final int numDocs = atLeast(100);
-    final int numDeletes = random().nextInt(numDocs);
-    final Set<Integer> deletes = new HashSet<>();
-    while (deletes.size() < numDeletes) {
-      deletes.add(random().nextInt(numDocs));
-    }
     for (Options options : validOptions()) {
-      final RandomDocument[] docs = new RandomDocument[numDocs];
+      Map<String, RandomDocument> docs = new HashMap<>();
       for (int i = 0; i < numDocs; ++i) {
-        docs[i] = docFactory.newDocument(TestUtil.nextInt(random(), 1, 3), 
atLeast(10), options);
+        docs.put(
+            Integer.toString(i),
+            docFactory.newDocument(TestUtil.nextInt(random(), 1, 3), 
atLeast(10), options));
       }
       final Directory dir = newDirectory();
-      final RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
-      for (int i = 0; i < numDocs; ++i) {
-        writer.addDocument(addId(docs[i].toDocument(), "" + i));
+      final IndexWriterConfig iwc = newIndexWriterConfig();
+      if (indexSort != null) {
+        iwc.setIndexSort(indexSort);
+      }
+      final RandomIndexWriter writer = new RandomIndexWriter(random(), dir, 
iwc);
+      List<String> liveDocIDs = new ArrayList<>();
+      List<String> ids = new ArrayList<>(docs.keySet());
+      Collections.shuffle(ids, random());
+      Runnable verifyTermVectors =
+          () -> {
+            try (DirectoryReader reader = 
maybeWrapWithMergingReader(writer.getReader())) {
+              for (String id : liveDocIDs) {
+                final int docID = docID(reader, id);
+                assertEquals(docs.get(id), reader.getTermVectors(docID));
+              }
+            } catch (IOException e) {
+              throw new UncheckedIOException(e);
+            }
+          };
+      for (String id : ids) {
+        final Document doc = addId(docs.get(id).toDocument(), id);
+        if (indexSort != null) {
+          for (SortField sortField : indexSort.getSort()) {
+            doc.add(
+                new NumericDocValuesField(
+                    sortField.getField(), TestUtil.nextInt(random(), 0, 
10000)));
+          }

Review comment:
       ++, I reduced the range in 
https://github.com/apache/lucene/pull/140/commits/af3dc8c66e89d2960e1852152de4418a96b96f7b.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to