You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "jpountz (via GitHub)" <gi...@apache.org> on 2023/01/24 10:22:12 UTC

[GitHub] [lucene] jpountz opened a new pull request, #12109: MemoryIndex should not fail integer fields that enable doc values.

jpountz opened a new pull request, #12109:
URL: https://github.com/apache/lucene/pull/12109

   When a field indexes numeric doc values, `MemoryIndex` does an unchecked cast to `java.lang.Long`. However, the new `IntField` represents the value as a `java.lang.Integer` so this cast fails. This commit aligns `MemoryIndex` with `IndexingChain` by casting to `Number` and calling `Number#longValue` instead of casting to `Long`.


-- 
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: issues-unsubscribe@lucene.apache.org

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


[GitHub] [lucene] romseygeek commented on a diff in pull request #12109: MemoryIndex should not fail integer fields that enable doc values.

Posted by "romseygeek (via GitHub)" <gi...@apache.org>.
romseygeek commented on code in PR #12109:
URL: https://github.com/apache/lucene/pull/12109#discussion_r1085097916


##########
lucene/memory/src/test/org/apache/lucene/index/memory/TestMemoryIndex.java:
##########
@@ -793,4 +793,42 @@ private static boolean arrayBinaryContains(BytesRef[] array, BytesRef value) {
     }
     return false;
   }
+
+  public void testIntegerNumericDocValue() throws IOException {
+    // MemoryIndex used to fail when doc values are enabled and numericValue() returns an Integer
+    // such as with IntField.
+    FieldType ft = new FieldType();
+    ft.setDocValuesType(DocValuesType.NUMERIC);
+    ft.freeze();
+    Field field =
+        new Field("field", ft) {
+          {
+            fieldsData = 35;
+          }
+        };
+
+    FieldType multiFt = new FieldType();
+    multiFt.setDocValuesType(DocValuesType.SORTED_NUMERIC);
+    multiFt.freeze();
+    Field multiField =
+        new Field("multi_field", multiFt) {
+          {
+            fieldsData = 35;
+          }
+        };

Review Comment:
   Is it worth explicitly adding a test for IntField here as well?



-- 
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: issues-unsubscribe@lucene.apache.org

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


[GitHub] [lucene] jpountz merged pull request #12109: MemoryIndex should not fail integer fields that enable doc values.

Posted by "jpountz (via GitHub)" <gi...@apache.org>.
jpountz merged PR #12109:
URL: https://github.com/apache/lucene/pull/12109


-- 
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: issues-unsubscribe@lucene.apache.org

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


[GitHub] [lucene] jpountz commented on a diff in pull request #12109: MemoryIndex should not fail integer fields that enable doc values.

Posted by "jpountz (via GitHub)" <gi...@apache.org>.
jpountz commented on code in PR #12109:
URL: https://github.com/apache/lucene/pull/12109#discussion_r1085101798


##########
lucene/memory/src/test/org/apache/lucene/index/memory/TestMemoryIndex.java:
##########
@@ -793,4 +793,42 @@ private static boolean arrayBinaryContains(BytesRef[] array, BytesRef value) {
     }
     return false;
   }
+
+  public void testIntegerNumericDocValue() throws IOException {
+    // MemoryIndex used to fail when doc values are enabled and numericValue() returns an Integer
+    // such as with IntField.
+    FieldType ft = new FieldType();
+    ft.setDocValuesType(DocValuesType.NUMERIC);
+    ft.freeze();
+    Field field =
+        new Field("field", ft) {
+          {
+            fieldsData = 35;
+          }
+        };
+
+    FieldType multiFt = new FieldType();
+    multiFt.setDocValuesType(DocValuesType.SORTED_NUMERIC);
+    multiFt.freeze();
+    Field multiField =
+        new Field("multi_field", multiFt) {
+          {
+            fieldsData = 35;
+          }
+        };

Review Comment:
   I added a custom field so that I could make sure the numericValue() is actually an Integer in case IntField changes at some point in the future. I'll add IntField explicitly too.



-- 
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: issues-unsubscribe@lucene.apache.org

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


[GitHub] [lucene] jpountz commented on pull request #12109: MemoryIndex should not fail integer fields that enable doc values.

Posted by "jpountz (via GitHub)" <gi...@apache.org>.
jpountz commented on PR #12109:
URL: https://github.com/apache/lucene/pull/12109#issuecomment-1401717980

   Thanks @romseygeek !


-- 
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: issues-unsubscribe@lucene.apache.org

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