gaobinlong commented on code in PR #15653:
URL: https://github.com/apache/lucene/pull/15653#discussion_r3214653576


##########
lucene/misc/src/test/org/apache/lucene/misc/search/TestDocValuesStatsCollector.java:
##########
@@ -99,228 +107,257 @@ public void testOneDoc() throws IOException {
   }
 
   public void testDocsWithLongValues() throws IOException {
-    try (Directory dir = newDirectory();
-        IndexWriter indexWriter = new IndexWriter(dir, 
newIndexWriterConfig())) {
-      String field = "numeric";
-      int numDocs = TestUtil.nextInt(random(), 1, 100);
-      long[] docValues = new long[numDocs];
-      int nextVal = 1;
-      for (int i = 0; i < numDocs; i++) {
-        Document doc = new Document();
-        if (random().nextBoolean()) { // not all documents have a value
-          doc.add(new NumericDocValuesField(field, nextVal));
-          doc.add(new StringField("id", "doc" + i, Store.NO));
-          docValues[i] = nextVal;
-          ++nextVal;
-        }
-        indexWriter.addDocument(doc);
-      }
-
-      // 20% of cases delete some docs
-      if (random().nextDouble() < 0.2) {
+    try (Directory dir = newDirectory()) {
+      IndexWriterConfig config = newIndexWriterConfig();
+      config.setMaxBufferedDocs(10);
+      try (RandomIndexWriter indexWriter = new RandomIndexWriter(random(), 
dir, config)) {
+        String field = "numeric";
+        int numDocs = TestUtil.nextInt(random(), 50, 100);
+        long[] docValues = new long[numDocs];
+        int nextVal = 1;
         for (int i = 0; i < numDocs; i++) {
+          Document doc = new Document();
           if (random().nextBoolean()) {
-            indexWriter.deleteDocuments(new Term("id", "doc" + i));
-            docValues[i] = 0;
+            doc.add(new NumericDocValuesField(field, nextVal));
+            doc.add(new StringField("id", "doc" + i, Store.NO));
+            docValues[i] = nextVal;
+            ++nextVal;
+          }
+          if (i != 0 && i % 10 == 0) {
+            indexWriter.commit();

Review Comment:
   Yeah, you're right, randomIndexWriter flush or commit documents randomly, 
this is not necessary.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to