英文:
Sort the Hazelcast json value in java
问题
我将Hazelcast JSON值存储在IMAP中
IMap.put(Integer, new HazelcastjsonValue("{\"id\":\"001\",\"name\":\"vikram\"}"));
IMap.put(Integer, new HazelcastjsonValue("{\"id\":\"002\",\"name\":\"abhishek\"}"));
如何按name
对HazelcastjsonValue进行排序
我知道我们可以使用分页谓词来实现排序的JSON数组。
但如何为HazelcastjsonValue使用分页谓词。
有谁可以帮我解决这个问题吗?
英文:
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"}"));
How to sort the HazelcastjsonValue by name
I know using paging predicate we can achieve a sorted JSON array.
But how to use the paging predicate for the HazelcastjsonValue.
Can anyone please help me with this?
答案1
得分: -1
你可以按照Hazelcast参考手册:索引查询中的描述设置索引。在你的情况下,代码如下:
IMap.addIndex(new IndexConfig(IndexType.SORTED, "name"));
然后,结果集合应该是有序的。
如果你不想设置索引,那么我猜你可以使用Predicates.pagingPredicate(comparator, size)
,但是你需要编写自己的自定义比较器。
英文:
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.
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论