具有LimitFilter的比较器不起作用

时间:2015-12-24 08:02:19

标签: java caching comparator oracle-coherence

我正在尝试使用limitFilter从缓存中检索结果:

 public void setComparator(Comparator comparator) : Set the Comparator
 used to partition the values into pages. 

根据API

if (isAllSelected) {
    cell.imageView.image = [UIImage imageNamed:@"checked.png"];
}
else
{
// set default image
}

所以我预计limitfilter会使用比较器对数据进行排序,但似乎没有这样做。例如,我有20名学生,其studentId范围是1到20.我希望有4个带有do / while循环的studentSet,范围分别为1-5,6-10,11-15,16-20。但有时在第一个studentSet中有一个Id为13的学生,或者在最后一个studentSet中有一个学生,等等。

有人遇到过这个问题,请让我知道你的想法

1 个答案:

答案 0 :(得分:0)

According to JavaDoc for LimitFilter.setComparator(Comparator comparator) (for Coherence 12.2.1 at least)

This method is intended to be used only by query processors. Clients should not modify the content of this property.

To get the described result, you should call (inside the loop):

studentSet = studentCache.entrySet(limitFilter, comparator);