|
Oracle® Coherence Java API Reference Release 3.7.1.0 E22843-01 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
com.tangosol.util.Base
com.tangosol.util.SimpleMapIndex
public class SimpleMapIndex
SimpleMapIndex is a MapIndex implementation used to correlate property values extracted from resource map entries with corresponding keys using what is commonly known as an Inverted Index algorithm.
Nested Class Summary | |
---|---|
static class |
SimpleMapIndex.IndexCalculator A stateful calculator used to calculate the cost of a homogeneous index (holding all values of a single type). |
Field Summary | |
---|---|
protected ConfigurableCacheMap.UnitCalculator |
m_calculator UnitCalculator used to estimate the cost of a value. |
protected java.util.Comparator |
m_comparator Comparator used to sort the index. |
protected BackingMapContext |
m_ctx The context associated with this index. |
protected java.util.concurrent.atomic.AtomicLong |
m_cUnits The size footprint of the index, in units (as defined by the UnitCalculator). |
protected ValueExtractor |
m_extractor ValueExtractor object that this MapIndex uses to extract an indexable property value from a [converted] value stored in the resource map. |
protected boolean |
m_fOrdered Specifies whether or not this MapIndex orders the contents of the indexed information. |
protected boolean |
m_fSplitCollection If a value extracted by the ValueExtractor is a Collection, this property specifies whether or not it should be treated as a Collection of contained attributes or indexed as a single composite attribute. |
protected java.util.Map |
m_mapForward Map that contains the index values (forward index). |
protected java.util.Map |
m_mapInverse Map that contains the index contents (inverse index). |
Fields inherited from interface com.tangosol.util.MapIndex |
---|
NO_VALUE |
Constructor Summary | |
---|---|
|
SimpleMapIndex(ValueExtractor extractor, boolean fOrdered, java.util.Comparator comparator, BackingMapContext ctx) Construct an index for the given map. |
protected |
SimpleMapIndex(ValueExtractor extractor, boolean fOrdered, java.util.Comparator comparator, boolean fInit, BackingMapContext ctx) Construct an index for the given map. |
Method Summary | |
---|---|
protected java.lang.Object |
addInverseCollectionMapping(java.util.Map mapIndex, java.lang.Object oIxValue, java.lang.Object oKey) Add new mappings from the elements of the given value to the given key in the supplied index. |
protected java.lang.Object |
addInverseMapping(java.util.Map mapIndex, java.lang.Object oIxValue, java.lang.Object oKey) Add a new mapping from the given indexed value to the given key in the supplied index. |
protected java.lang.Object |
addInverseMapping(java.lang.Object oIxValue, java.lang.Object oKey) Add a new mapping from the given indexed value to the given key in the inverse index. |
protected void |
addUnits(java.lang.Object oValue) Increase the size for the index by the estimated size of the specified added value. |
void |
delete(java.util.Map.Entry entry) Update this index in response to a remove operation on a cache. |
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. |
java.lang.Object |
get(java.lang.Object oKey) Using the index information if possible, get the value associated with the specified key. |
ConfigurableCacheMap.UnitCalculator |
getCalculator() Return the UnitCalculator used to size this index's contents. |
java.util.Comparator |
getComparator() Get the Comparator used to sort the index. |
protected java.util.Map.Entry |
getForwardEntry(java.lang.Object oKey) Get the forward index entry associated with the specified key. |
java.util.Map |
getIndexContents() Get the Map that contains the index contents. |
long |
getUnits() Retrieve the size of this index in units (as defined by the {@link #getCalculator() UnitCalculator). |
protected java.util.concurrent.atomic.AtomicLong |
getUnitsCounter() Get the counter for the size of this index. |
ValueExtractor |
getValueExtractor() Obtain the ValueExtractor object that the MapIndex uses to extract an indexable Object from a value stored in the indexed Map. |
int |
hashCode() Returns the hash code value for this MapIndex. |
protected void |
initialize() Initialize the index's data structures. |
void |
insert(java.util.Map.Entry entry) Update this index in response to a insert operation on a cache. |
protected void |
insertInternal(java.util.Map.Entry entry) Update this index in response to a insert operation on a cache. |
protected ConfigurableCacheMap.UnitCalculator |
instantiateCalculator() Factory method used to create a new calculator. |
protected java.util.Map |
instantiateForwardIndex() Instantiate the forward index. |
protected java.util.Map |
instantiateInverseIndex(boolean fOrdered, java.util.Comparator comparator) Instantiate the inverse index. |
protected java.util.Set |
instantiateSet() Factory method used to create a new set containing the keys associated with a single value. |
boolean |
isOrdered() Determine if the MapIndex orders the contents of the indexed information. |
boolean |
isPartial() Determine if indexed information for any entry in the indexed Map has been excluded from this index. |
protected void |
removeInverseMapping(java.util.Map mapIndex, java.lang.Object oIxValue, java.lang.Object oKey) Remove the mapping from the given indexed value to the given key from the supplied index. |
protected void |
removeInverseMapping(java.lang.Object oIxValue, java.lang.Object oKey) Remove the mapping from the given indexed value to the given key from the inverse index. |
protected void |
removeUnits(java.lang.Object oValue) Decrease the size of the index by the estimated size of the specified removed value. |
java.lang.String |
toString() Returns a string representation of this SimpleMapIndex. |
java.lang.String |
toString(boolean fVerbose) Returns a string representation of this SimpleMapIndex. |
void |
update(java.util.Map.Entry entry) Update this index in response to an update operation on a cache. |
protected void |
updateInternal(java.util.Map.Entry entry) Update this index in response to an update operation on a cache. |
Field Detail |
---|
protected ValueExtractor m_extractor
protected java.util.Comparator m_comparator
protected boolean m_fOrdered
protected java.util.Map m_mapForward
protected java.util.Map m_mapInverse
protected boolean m_fSplitCollection
protected final java.util.concurrent.atomic.AtomicLong m_cUnits
protected ConfigurableCacheMap.UnitCalculator m_calculator
protected BackingMapContext m_ctx
context
associated with this index.Constructor Detail |
---|
public SimpleMapIndex(ValueExtractor extractor, boolean fOrdered, java.util.Comparator comparator, BackingMapContext ctx)
extractor
- the ValueExtractor that is used to extract an indexed value from a resource map entryfOrdered
- true iff the contents of the indexed information should be ordered; false otherwisecomparator
- the Comparator object which imposes an ordering on entries in the index map; or null if the entries' values natural ordering should be usedctx
- the context
associated with the indexed cacheprotected SimpleMapIndex(ValueExtractor extractor, boolean fOrdered, java.util.Comparator comparator, boolean fInit, BackingMapContext ctx)
extractor
- the ValueExtractor that is used to extract an indexed value from a resource map entryfOrdered
- true iff the contents of the indexed information should be ordered; false otherwisecomparator
- the Comparator object which imposes an ordering on entries in the index map; or null if the entries' values natural ordering should be usedfInit
- initialize the index if truectx
- the context
associated with the indexed cacheMethod Detail |
---|
public ValueExtractor getValueExtractor()
getValueExtractor
in interface MapIndex
public boolean isOrdered()
isOrdered
in interface MapIndex
public boolean isPartial()
IndexAwareFilter
implementations to determine the most optimal way to apply the index.isPartial
in interface MapIndex
public java.util.Comparator getComparator()
getComparator
in interface MapIndex
public java.util.Map getIndexContents()
The keys of the Map are the return values from the ValueExtractor operating against the indexed Map's values, and for each key, the corresponding value stored in the Map is a Set of keys to the indexed Map.
If the MapIndex is known to be ordered, then the returned Map object will be an instance of SortedMap
. The SortedMap may or may not have a Comparator
object associated with it; see SortedMap.comparator()
.
A client should assume that the returned Map object is read-only and must not attempt to modify it.
getIndexContents
in interface MapIndex
public java.lang.Object get(java.lang.Object oKey)
get
in interface MapIndex
oKey
- the key that specifies the object to extract the value frompublic void insert(java.util.Map.Entry entry)
insert
in interface MapIndex
entry
- the entry representing the object being insertedpublic void update(java.util.Map.Entry entry)
update
in interface MapIndex
entry
- the entry representing the object being updatedpublic void delete(java.util.Map.Entry entry)
delete
in interface MapIndex
entry
- the entry representing the object being removedpublic long getUnits()
protected java.util.concurrent.atomic.AtomicLong getUnitsCounter()
public ConfigurableCacheMap.UnitCalculator getCalculator()
protected void initialize()
protected java.util.Map.Entry getForwardEntry(java.lang.Object oKey)
oKey
- the keyprotected java.util.Map instantiateForwardIndex()
Note: To optimize the memory footprint of the forward index, any subclasses of the SimpleMapIndex that override this method must also implement the getForwardEntry(Object)
method accordingly.
protected java.util.Map instantiateInverseIndex(boolean fOrdered, java.util.Comparator comparator)
fOrdered
- true iff the contents of the indexed information should be ordered; false otherwisecomparator
- the Comparator object which imposes an ordering on entries in the index map; or null if the entries' values natural ordering should be usedprotected void insertInternal(java.util.Map.Entry entry)
entry
- the entry representing the object being insertedprotected void updateInternal(java.util.Map.Entry entry)
entry
- the entry representing the object being updatedprotected void deleteInternal(java.util.Map.Entry entry)
entry
- the entry representing the object being removedprotected java.lang.Object addInverseMapping(java.lang.Object oIxValue, java.lang.Object oKey)
oIxValue
- the indexed value (serves as a key in the inverse index)oKey
- the key to insert into the inverse indexprotected java.lang.Object addInverseMapping(java.util.Map mapIndex, java.lang.Object oIxValue, java.lang.Object oKey)
mapIndex
- the index to which to add the mappingoIxValue
- the indexed value (serves as a key in the inverse index)oKey
- the key to insert into the inverse indexprotected java.lang.Object addInverseCollectionMapping(java.util.Map mapIndex, java.lang.Object oIxValue, java.lang.Object oKey)
mapIndex
- the index to which to add the mappingoIxValue
- the indexed Collection value (each element serves as a key in the inverse index)oKey
- the key to insert into the inverse indexprotected void removeInverseMapping(java.lang.Object oIxValue, java.lang.Object oKey)
oIxValue
- the indexed valueoKey
- the keyprotected void removeInverseMapping(java.util.Map mapIndex, java.lang.Object oIxValue, java.lang.Object oKey)
mapIndex
- the index from which to remove the mappingoIxValue
- the indexed valueoKey
- the keyprotected java.util.Set instantiateSet()
protected ConfigurableCacheMap.UnitCalculator instantiateCalculator()
ConfigurableCacheMap.UnitCalculator
protected void removeUnits(java.lang.Object oValue)
oValue
- the value being removed from the indexprotected void addUnits(java.lang.Object oValue)
oValue
- the value being added to the index.public java.lang.String toString()
public java.lang.String toString(boolean fVerbose)
fVerbose
- if true then print the content of the index otherwise print the number of entriespublic boolean equals(java.lang.Object o)
o
- object to be compared for equality with this MapIndexpublic int hashCode()
|
Oracle® Coherence Java API Reference Release 3.7.1.0 E22843-01 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |