To enable more than 1000 filter on more than 60k records with a lot of business rules, it can be spent only 2 seconds on my PC.
Use cqengine (with RadixTreeIndex and ReversedRadixTreeIndex) instead of looping collection.
For collections.removeAll, HashSet is much faster than ArrayList since HashSet contains implementation is map.containsKey(o); while ArrayList is:
public boolean contains(Object o) {
return indexOf(o) >= 0;
}
/**
* Returns the index of the first occurrence of the specified element
* in this list, or -1 if this list does not contain the element.
* More formally, returns the lowest index <tt>i</tt> such that
* <tt>(o==null ? get(i)==null : o.equals(get(i)))</tt>,
* or -1 if there is no such index.
*/
public int indexOf(Object o) {
if (o == null) {
for (int i = 0; i < size; i++)
if (elementData[i]==null)
return i;
} else {
for (int i = 0; i < size; i++)
if (o.equals(elementData[i]))
return i;
}
return -1;
}
No comments:
Post a Comment