Reviews
Oracle CoherenceOracle Coherence: Other built-in value extractors
While the ReflectionExtractor is definitely the one that is used most often, there are several other value extractors that ship with Coherence.
IdentityExtractor
The simplest extractor is the IdentityExtractor, which doesn't really extract anything from the target object, but returns the target object itself. This extractor can come in handy when you actually want filters to operate on the cache value itself instead of on one of its attributes, which is typically the case only if the value is of a simple type, such as one of the intrinsic numeric types or a string.
ChainedExtractor and MultiExtractor
There are also two composite value extractors, ChainedExtractor and MultiExtractor. Both of them accept an array of value extractors as a constructor argument, but they use them differently.
The ChainedExtractor executes extractors one by one, using the result of the previous extractor as the target object to evaluate the next extractor against. For example, you can use the ChainedExtractor to extract the accountId attribute from a Transaction instance:
- ValueExtractor ex =
- new ChainedExtractor(new ValueExtractor[] {
- new ReflectionExtractor("getId"),
- new ReflectionExtractor("getAccountId") })
<p> </p><br>
This is necessary because the Transaction class does not expose the accountId attribute directly--we need to extract the id attribute from a transaction first, and then extract accountId from a Transaction.Id instance.
Avoiding the need for chaining Of course, we could've easily avoided the need for chaining if we simply exposed the accountId attribute directly on the Transaction class. Doing that is trivial and makes perfect sense in this case. However, if I had done that, I'd have to come up with an example of ChainedExtractor usage that is outside of our domain.
When creating a ChainedExtractor you can also use a convenience constructor that will parse a dot-separated string and create an array of ReflectionExtractor instances automatically:
- ValueExtractor ex =
- new ChainedExtractor("getId.getAccountId")
As a matter of fact, you don't even need to go that far--all built-in filters will automatically create a ChainedExtractor containing an array of ReflectionExtractors from a dot-separated string, which is the feature we relied on earlier when we defined a query that returns transactions for a specific account.
On the other hand, MultiExtractor will execute all extractors against the same target object and return the list of extracted values. While you will rarely use this extractor when querying the cache, it can be very convenient when you want to extract only a subset of an object's attributes during aggregation (which we'll discuss shortly), in order to minimize the amount of data that needs to be transferred across the wire.
PofExtractor
One of the features introduced in Coherence 3.5 is PofExtractor--an extractor that can be used to extract values from the POF-serialized binaries without deserialization. This can provide a huge performance boost and reduced memory footprint for queries that would otherwise have to deserialize every single object in the cache in order to evaluate the filter.
However, you will only see those benefits when working with caches containing large objects. For small objects, the overhead of initializing a structure that is used to keep track of the location of serialized attributes within a binary POF value will likely be higher (both from memory and performance perspective) than the full deserialization of an object.
Oracle Coherence
- Oracle Coherence 3.5
- Oracle Coherence: Distributed Caching
- Oracle Coherence: In-place and Parallel Processing
- Oracle Coherence: Coherence within the Oracle Ecosystem
- Oracle Coherence: Querying The Data Grid
- Oracle Coherence: Built-in Filters
- Oracle Coherence: Value and Reflection Extractor
- Oracle Coherence: Other built-in value extractors
- Oracle Coherence: Implementing Custom Value Extractor
- Oracle Coherence: Simplifying Coherence Queries
- Oracle Coherence: Obtaining Query Results
- Oracle Coherence: Controlling Query Scope Using Data Affinity
- Oracle Coherence: Querying Near Cache
- Oracle Coherence: Paging Over Query Results
- Oracle Coherence: Anatomy of an Index
- Oracle Coherence: Creating Indexes
- Oracle Coherence: Query Limitations
- Oracle Coherence: Aggregators
- Oracle Coherence: Built-in Aggregators
- Oracle Coherence: Implementing LookupValuesAggregator







