gpt4 book ai didi

java - cqengine IndexedCollection 添加导致空指针

转载 作者:行者123 更新时间:2023-12-01 09:17:50 24 4
gpt4 key购买 nike

当前,当我向 IndexedCollection 添加元素时遇到此错误:

HIGHEST: null
java.lang.NullPointerException
at java.util.concurrent.ConcurrentSkipListMap.doGet(ConcurrentSkipListMap.java:778)
at java.util.concurrent.ConcurrentSkipListMap.get(ConcurrentSkipListMap.java:1546)
at com.googlecode.cqengine.index.support.AbstractMapBasedAttributeIndex.addAll(AbstractMapBasedAttributeIndex.java:81)
at com.googlecode.cqengine.engine.CollectionQueryEngine$12.perform(CollectionQueryEngine.java:1125)
at com.googlecode.cqengine.engine.CollectionQueryEngine.forEachIndexDo(CollectionQueryEngine.java:1206)
at com.googlecode.cqengine.engine.CollectionQueryEngine.addAll(CollectionQueryEngine.java:1122)
at com.googlecode.cqengine.ConcurrentIndexedCollection.add(ConcurrentIndexedCollection.java:351)

我尝试调试以查看是否传递了空值,但没有。我尝试添加的对象有一个 null DateTime 但相应的索引已经返回 null,而不是当它为 null 时。

我认为这个问题的解决最终取决于经验,@npgall 你是否遇到过这个问题,如果有的话你是如何解决的?

最佳答案

我认为网站上缺乏这方面的文档。它提到了 SimpleNullableAttributeMultiValueNullableAttribute 但没有真正解释何时使用它们。

TL;DR是:如果你得到一个NPE,通常意味着你需要使用可为空的属性。

或更准确地说:如果您的数据有可能包含 null 值,那么您需要使用可为 null 的属性(例如 SimpleNullableAttribute),而不是不可为 null 的属性(例如 SimpleAttribute)。

无论如何,我已经扩展了主 Readme.md 上的文档更详细地讨论“空值”。希望有帮助!

关于java - cqengine IndexedCollection 添加导致空指针,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40406059/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com