Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.0.0

E18683-01


com.tangosol.util
Class ConditionalIndex

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.util.SimpleMapIndex
          extended by com.tangosol.util.ConditionalIndex

All Implemented Interfaces:
MapIndex

public class ConditionalIndex
extends SimpleMapIndex

ConditionalIndex is a MapIndex implemenation that uses an associated filter to evaluate whether or not an entry should be indexed. An entry's extracted value is only added to the index if the filter evaluates to true.

Since:
Coherence 3.6
Author:
tb 2010.02.08

Nested Class Summary

 

Nested classes/interfaces inherited from class com.tangosol.util.SimpleMapIndex
SimpleMapIndex.IndexCalculator

 

Field Summary

 

Fields inherited from class com.tangosol.util.SimpleMapIndex
m_calculator, m_comparator, m_ctx, m_cUnits, m_extractor, m_fOrdered, m_fSplitCollection, m_mapForward, m_mapInverse

 

Fields inherited from interface com.tangosol.util.MapIndex
NO_VALUE

 

Constructor Summary
ConditionalIndex(Filter filter, ValueExtractor extractor, boolean fOrdered, java.util.Comparator comparator, boolean fForwardIndex, BackingMapContext ctx)
          Construct a ConditionalIndex.

 

Method Summary
protected  void deleteInternal(java.util.Map.Entry entry)
          Update this index in response to a remove operation on a cache.
 boolean equals(java.lang.Object o)
          Compares the specified object with this index for equality.
protected  boolean evaluateEntry(java.util.Map.Entry entry)
          Evaluate the given entry using this index's filter.
 java.lang.Object get(java.lang.Object oKey)
          Using the index information if possible, get the value associated with the specified key.
 Filter getFilter()
          Get the associated filter.
protected  java.util.Map.Entry getForwardEntry(java.lang.Object oKey)
          Get the forward index entry associated with the specified key.
protected  void insertInternal(java.util.Map.Entry entry)
          Update this index in response to a insert operation on a cache.
protected  java.util.Map instantiateForwardIndex()
          Instantiate the forward index.
 boolean isForwardIndexSupported()
          Determine whether or not this ConditionalIndex supports a forward index.
 boolean isPartial()
          Determine if indexed information for any entry in the indexed Map has been excluded from this index.
 java.lang.String toString()
          Returns a string representation of this ConditionalIndex.
protected  void updateInternal(java.util.Map.Entry entry)
          Update this index in response to an update operation on a cache.

 

Methods inherited from class com.tangosol.util.SimpleMapIndex
addInverseCollectionMapping, addInverseMapping, addInverseMapping, addUnits, delete, getCalculator, getComparator, getIndexContents, getUnits, getUnitsCounter, getValueExtractor, hashCode, initialize, insert, instantiateCalculator, instantiateInverseIndex, instantiateSet, isOrdered, removeInverseMapping, removeInverseMapping, removeUnits, toString, update

 

Constructor Detail

ConditionalIndex

public ConditionalIndex(Filter filter,
                        ValueExtractor extractor,
                        boolean fOrdered,
                        java.util.Comparator comparator,
                        boolean fForwardIndex,
                        BackingMapContext ctx)
Construct a ConditionalIndex.
Parameters:
filter - the filter that is used to evaluate the entries of the resource map that is being indexed
extractor - the ValueExtractor that is used to extract an indexed value from a resource map entry
fOrdered - true iff the contents of the indexed information should be ordered; false otherwise
comparator - the Comparator object which imposes an ordering on entries in the index map; or null if the entries' values natural ordering should be used
fForwardIndex - specifies whether or not this index supports a forward map
ctx - the context associated with this index

Method Detail

get

public java.lang.Object get(java.lang.Object oKey)
Using the index information if possible, get the value associated with the specified key. This is expected to be more efficient than using the ValueExtractor against an object containing the value, because the index should already have the necessary information at hand.
Specified by:
get in interface MapIndex
Overrides:
get in class SimpleMapIndex
Parameters:
oKey - the key that specifies the object to extract the value from
Returns:
the value that would be extracted by this MapIndex's ValueExtractor from the object specified by the passed key; NO_VALUE if the index does not have the necessary information

getForwardEntry

protected java.util.Map.Entry getForwardEntry(java.lang.Object oKey)
Get the forward index entry associated with the specified key.
Overrides:
getForwardEntry in class SimpleMapIndex
Parameters:
oKey - the key
Returns:
the entry associated with the given key.

instantiateForwardIndex

protected java.util.Map instantiateForwardIndex()
Instantiate the forward index.

Note: To optimize the memory footprint of the forward index, any subclasses of the SimpleMapIndex that override this method must also implement the SimpleMapIndex.getForwardEntry(Object) method accordingly.

Overrides:
instantiateForwardIndex in class SimpleMapIndex
Returns:
the forward index

isPartial

public boolean isPartial()
Determine if indexed information for any entry in the indexed Map has been excluded from this index. This information is used for IndexAwareFilter implementations to determine the most optimal way to apply the index.
Specified by:
isPartial in interface MapIndex
Overrides:
isPartial in class SimpleMapIndex
Returns:
true if any entry of the indexed Map has been excluded from the index, false otherwise

getFilter

public Filter getFilter()
Get the associated filter.
Returns:
the filter

isForwardIndexSupported

public boolean isForwardIndexSupported()
Determine whether or not this ConditionalIndex supports a forward index.
Returns:
true if this ConditionalIndex supports a forward index; false otherwise

evaluateEntry

protected boolean evaluateEntry(java.util.Map.Entry entry)
Evaluate the given entry using this index's filter. If the entry does not pass the filter then it should be excluded from this index, making this a partial index.
Parameters:
entry - the entry to evaluate
Returns:
true if the entry passes the filter, false otherwise

insertInternal

protected void insertInternal(java.util.Map.Entry entry)
Update this index in response to a insert operation on a cache.
Overrides:
insertInternal in class SimpleMapIndex
Parameters:
entry - the entry representing the object being inserted

updateInternal

protected void updateInternal(java.util.Map.Entry entry)
Update this index in response to an update operation on a cache.
Overrides:
updateInternal in class SimpleMapIndex
Parameters:
entry - the entry representing the object being updated

deleteInternal

protected void deleteInternal(java.util.Map.Entry entry)
Update this index in response to a remove operation on a cache.
Overrides:
deleteInternal in class SimpleMapIndex
Parameters:
entry - the entry representing the object being removed

toString

public java.lang.String toString()
Returns a string representation of this ConditionalIndex. The string representation consists of the SimpleMapIndex representaion concatenated by the Filter and the ForwardIndexSupported flag.
Overrides:
toString in class SimpleMapIndex
Returns:
a String representation of this ConditionalIndex

equals

public boolean equals(java.lang.Object o)
Compares the specified object with this index for equality. Returns true if the given object is also a SimpleMapIndex and the two represent the same index.
Overrides:
equals in class SimpleMapIndex
Parameters:
o - object to be compared for equality with this MapIndex
Returns:
true if the specified object is equal to this index

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.0.0

E18683-01


Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.