You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2021/02/08 05:10:29 UTC

[GitHub] [lucene-solr] muse-dev[bot] commented on a change in pull request #2317: LUCENE-9741: Add sequential optimization for stored fields

muse-dev[bot] commented on a change in pull request #2317:
URL: https://github.com/apache/lucene-solr/pull/2317#discussion_r571784231



##########
File path: lucene/test-framework/src/java/org/apache/lucene/index/BaseStoredFieldsFormatTestCase.java
##########
@@ -839,4 +839,38 @@ public void testMismatchedFields() throws Exception {
     IOUtils.close(iw, ir, everything);
     IOUtils.close(dirs);
   }
+
+  public void testPrefetch() throws Exception {
+    Directory dir = newDirectory();
+    IndexWriterConfig config = newIndexWriterConfig().setCodec(getCodec());
+    IndexWriter writer = new IndexWriter(dir, config);
+    int numDocs = atLeast(100);
+    Map<Integer, Document> docs = new HashMap<>();
+    for (int i = 0; i < numDocs; i++) {
+      Document doc = new Document();
+      int numFields = random().nextInt(rarely() ? 1000 : 100);
+      doc.add(new StringField("num_fields", Integer.toString(numFields), Store.NO));
+      for (int f = 0; f < numFields; f++) {
+        String str = "doc=" + i + "f=" + f;
+        doc.add(new StringField("field-" + f, str, Store.YES));
+      }
+      writer.addDocument(doc);
+      docs.put(i, doc);
+    }
+    final DirectoryReader reader = new RandomPrefetchStoredFieldsCodecDirectoryReader(DirectoryReader.open(writer));
+    int iters = atLeast(100);
+    for (int i = 0; i < iters; i++) {
+      int docId = random().nextInt(numDocs);
+      int numFields = Integer.parseInt(docs.get(docId).getField("num_fields").stringValue());

Review comment:
       *NULL_DEREFERENCE:*  object returned by `docs.get(valueOf(docId)).getField("num_fields")` could be null and is dereferenced at line 864.




----------------------------------------------------------------
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:
users@infra.apache.org



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