VisualVM OQL:如何搜索原始浮点值而不是实际的浮点实例?
我想知道如何搜索与特定数字匹配的所有原始浮点值。
当执行以下操作时:
select n from java.lang.Float n where n.value == 1.00
仅找到 Float 类实例。我正在探索的应用程序使用不同的包装器,而不仅仅是 Float (例如向量),它使用原始浮点值作为我需要搜索的字段。
我将如何实现这个目标?
以下返回“找不到浮动错误”:
select n from float n where n.value == 1.00
I am wondering how one can search for all primitive float values that match a certain number.
When doing something like:
select n from java.lang.Float n where n.value == 1.00
Only the Float class instances are being found. The application I am exploring is using different wrappers than just Float (eg. Vectors) that use primitive float values as fields for which I need to search.
How would I accomplish this?
The following returns a "float is not found error":
select n from float n where n.value == 1.00
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
原始值仅作为其所属结构中的字段存在(或直接存在于堆栈中)。因为它不是一个对象,所以不能被引用。尝试如下操作:
如果您想检查所有对象中的所有浮点字段,应该可以使用 OQL 的反射功能来执行此操作,使用如下所示的操作:
但是,虽然这可以正常工作使用 jhat,它在我的 VisualVM 版本(1.6.0_22)中不起作用,因为 cls.fields 似乎不正确地返回静态字段列表而不是实例字段。
它也非常慢,搜索 1MB 的堆转储需要 10 秒。通过仅搜索一组有限的类,可能可以优化代码并加快速度。
A primitive value exists only as a field in the structure it's a part of (or directly on the stack). Because it isn't an object, it can't be referenced. Try something like the following:
If you want to examine all float fields in all objects, it should be possible to use OQL's reflection capabilities to do so, using something like the following:
However, while this works correctly using jhat, it doesn't work in my version of VisualVM (1.6.0_22), because cls.fields seems to improperly return a list of static fields rather than instance fields.
It's also very slow, taking 10 seconds to search a 1MB heap dump. It's probably possible to optimize the code and also speed things up by only searching a limited set of classes.