romseygeek commented on code in PR #15718:
URL: https://github.com/apache/lucene/pull/15718#discussion_r2832194450


##########
lucene/core/src/test/org/apache/lucene/index/TestSortingStoredFieldsConsumer.java:
##########
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.lucene.index;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.lucene.codecs.Codec;
+import org.apache.lucene.codecs.StoredFieldsReader;
+import 
org.apache.lucene.codecs.lucene90.compressing.Lucene90CompressingStoredFieldsWriter;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.FilterDirectory;
+import org.apache.lucene.store.FilterIndexInput;
+import org.apache.lucene.store.FlushInfo;
+import org.apache.lucene.store.IOContext;
+import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.tests.util.LuceneTestCase;
+import org.apache.lucene.tests.util.TestUtil;
+import org.apache.lucene.util.StringHelper;
+import org.apache.lucene.util.Version;
+
+public class TestSortingStoredFieldsConsumer extends LuceneTestCase {
+
+  /**
+   * Verifies that when no stored fields are written, flushing the {@link
+   * SortingStoredFieldsConsumer} skips per-document seeks and reads on the 
stored fields file. Only
+   * the initial seek for checksum retrieval should occur.
+   */
+  public void testFlushWithNoStoredFieldsSkipsPerDocumentSeeks() throws 
IOException {
+    try (Directory dir = newDirectory()) {
+      IndexWriterConfig iwc = new IndexWriterConfig();
+      Codec codec = iwc.getCodec();
+      SegmentInfo si =
+          new SegmentInfo(
+              dir,
+              Version.LATEST,
+              null,
+              "_0",
+              -1,
+              false,
+              false,
+              codec,
+              Collections.emptyMap(),
+              StringHelper.randomId(),
+              new HashMap<>(),
+              null);
+
+      AtomicInteger numSeeks = new AtomicInteger();
+      Directory trackingDir =
+          new FilterDirectory(dir) {
+            @Override
+            public IndexInput openInput(String name, IOContext context) throws 
IOException {
+              if 
(name.contains(Lucene90CompressingStoredFieldsWriter.FIELDS_EXTENSION)) {

Review Comment:
   It's not ideal, but we're not doing Codec randomization here so I think we 
should be OK.



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