Saturday, June 23, 2012

Filtering Filters

Hello ! (Who needs a greeting anyway), distributed queries are a very powerful part of coherence, but can introduce show stopping performance degradation, so it is vital to get your filters right.

The filters provided by coherence, take an Extractor as a parameter, and will execute that extractor across all of the nodes, and the evaluate method will run on the result of that extractor.
This means that, if you are using a normal reflexion extractor(what is used by default when you call a filter with just a method name) new EqualsFilter(“getName”,”some_name”). This is quite slow and Inefficient,  as every object will be deserialized in order to evaluate that filter. There are two ways to avoid this,

The simplest was to avoid this is to use an Index to store those values. indexed values are kept unserialized and are matched in the same was as regular db indexes. The Filter classes provided by coherence implement IndexAwareFilter, and know how to lookup those indexes, therefore avoiding the deserialization.

The other way is to simply pass a POF extractor as a parameter, POF extractors do not deserialize an object In order to extract the desired value. However this approach is slower than having Indexes, as each object will still be evaluated, as opposed to simply looking up the Index table. However, this provides more flexibility, as you can decide at run time which fields will be used.

Custom Filters:
Sometimes you need more complex logic than the custom filters provide you, so you may decide to code your own, the simplest way to do that is to simply implement the Filter interface, however, a filter created in this manner will not use indexes even if they are relevant and will deserialize every object in that particular cache resulting in catastrophic performance.

There are a few ways to create a custom filter efficiently:

Implementing EntryFilter instead of Filter allows you to implement the evaluateEntry Method, which receives a BinaryEntry as a parameter, allowing you to extract the values yourself in a clever manner, avoiding deserializing the whole entry, however the extraction will still occur for every entry, which can be time consuming.

Extending ExtractorFilter allows you to, through its superclasse’s constructor, to take advantange of the created indexes and, by implementing the evaluateExtracted method to write your complex custom logic to evaluate that Object.



  1. I got this website from my friend who informed me about this web page and now this time I am visiting this web page and reading very informative articles here. facebook log in

  2. The King Casino: The Slots, Table Games, & More | Online
    Online casino features 545 casino games including Slots, Blackjack, Roulette, Video Poker and more. All 바카라 사이트 온라인 바카라 games are available 카지노 사이트 운영 in HD 메리트 카지노 주소 and 더킹카지노 도메인 can be 더킹카지노 가입 played for

  3. The Spin Casino Welcome Bonus makes a sensible choice|a good selection} for brand spanking new|for brand new} registrants looking for the quickest approach to be a part of the Loyalty Program. Just to clarify, is not a|there is not any} have to look anyplace looking for .apk package for Android, but solely to make use of your Firefox or Chrome cell companion. A downside to the Free Spins Casino is that United States players cannot play within the on-line on line casino. Free Spins Casino has ensured that each one|that each one} its services are cell suitable. This bet365 includes a cell on line casino, cell poker room, and a cell utility suitable with all cell gadgets.