问题描述
我将Hazelcast JSON值存储在IMAP中
I'm storing the Hazelcast JSON value in IMAP
IMap.put(Integer,new HazelcastjsonValue("{"id":"001","name":"vikram"}"));
IMap.put(Integer,new HazelcastjsonValue("{"id":"002","name":"abhishek"}"));
如何按name
我知道使用分页谓词可以实现排序的JSON数组.
I know using paging predicate we can achieve a sorted JSON array.
但是如何使用HazelcastjsonValue的分页谓词.
But how to use the paging predicate for the HazelcastjsonValue.
有人可以帮我吗?
推荐答案
您可以按照 Hazelcast参考手册:索引查询.就您而言,它看起来像:
You can set an index as described in Hazelcast Reference Manual: Indexing Queries. In your case, it would look like:
IMap.addIndex(new IndexConfig(IndexType.SORTED, "name"));
然后,对结果集合进行排序.
Then, the result collection should be sorted.
如果您不想设置索引,那么我猜您可以使用Predicates.pagingPredicate(comparator, size)
,但是您需要编写自己的自定义比较器.
If you don't want to set an index, then I guess you can use Predicates.pagingPredicate(comparator, size)
, but you would need write your own custom comparator.
这篇关于在Java中对Hazelcast json值进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!