Show / Hide Table of Contents

Class SimpleCacheIndex

SimpleCacheIndex is an ICacheIndex implementation used to correlate property values extracted from resource cache entries with corresponding keys using what is commonly known as an Inverted Index algorithm..

Inheritance
object
SimpleCacheIndex
ConditionalIndex
Implements
ICacheIndex
Inherited Members
object.Equals(object, object)
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
Namespace: Tangosol.Net.Cache
Assembly: Coherence.dll
Syntax
public class SimpleCacheIndex : ICacheIndex

Constructors

SimpleCacheIndex(IValueExtractor, bool, IComparer)

Construct an index.

Declaration
public SimpleCacheIndex(IValueExtractor extractor, bool ordered, IComparer comparer)
Parameters
Type Name Description
IValueExtractor extractor

The IValueExtractor that is used to extract an indexed value from a resource cache entry.

bool ordered

true iff the contents of the indexed information should be ordered; false otherwise.

IComparer comparer

The IComparator object which imposes an ordering on entries in the index map; or null if the entries' values natural ordering should be used.

SimpleCacheIndex(IValueExtractor, bool, IComparer, bool)

Construct an index.

Declaration
public SimpleCacheIndex(IValueExtractor extractor, bool ordered, IComparer comparer, bool init)
Parameters
Type Name Description
IValueExtractor extractor

The IValueExtractor that is used to extract an indexed value from a resource cache entry.

bool ordered

true iff the contents of the indexed information should be ordered; false otherwise.

IComparer comparer

The IComparator object which imposes an ordering on entries in the index map; or null if the entries' values natural ordering should be used.

bool init

Initialize the index if true.

Fields

NO_VALUE

Marker object used to represent extractor failure.

Declaration
protected static readonly object NO_VALUE
Field Value
Type Description
object

m_cLogMissingIdx

The number of "missing inverse index" messages that have been logged.

Declaration
protected int m_cLogMissingIdx
Field Value
Type Description
int

m_fImmutableValues

Specifies whether or not the index is based on the immutable values (e.g. keys).

Declaration
protected bool m_fImmutableValues
Field Value
Type Description
bool

m_keysExcluded

A set of keys for the entries, which could not be included in the index.

Declaration
protected SafeHashSet m_keysExcluded
Field Value
Type Description
SafeHashSet

m_ldtLogMissingIdx

The time at which the most recent logging of "missing inverse index" messages started.

Declaration
protected long m_ldtLogMissingIdx
Field Value
Type Description
long

m_splitCollection

If a value extracted by the IValueExtractor is an ICollection, this property specifies whether or not it should be treated as a collection of contained attributes or indexed as a single composite attribute.

Declaration
protected bool m_splitCollection
Field Value
Type Description
bool

Properties

Comparer

IComparer used to sort the index. Used iff Ordered is true. Could be null, which implicates a natural order.

Declaration
public virtual IComparer Comparer { get; protected set; }
Property Value
Type Description
IComparer

IndexContents

The IDictionary that contains the index contents.

Declaration
public IDictionary IndexContents { get; protected set; }
Property Value
Type Description
IDictionary
Remarks

The keys of the IDictionary are the return values from the IValueExtractor operating against the indexed ICache's values, and for each key, the corresponding value stored in the IDictionary is an ICollection of keys to the indexed value.

If the ICacheIndex is known to be ordered, then the returned IDictionary object will be an instance of SortedList (or wrapper thereof). The SortedList may or may not have an IComparer object associated with it.

A client should assume that the returned IDictionary object is read-only and must not attempt to modify it.

IndexForward

IDictionary that contains the index values (forward index). The keys of the IDictionary are the keys to the indexed cache and the values are the extracted values. This map is used by IIndexAwareFilter implementations to avoid conversion and value extraction steps.

Declaration
protected IDictionary IndexForward { get; set; }
Property Value
Type Description
IDictionary

IsOrdered

Specifies whether or not this ICacheIndex orders the contents of the indexed information.

Declaration
public virtual bool IsOrdered { get; protected set; }
Property Value
Type Description
bool

IsPartial

Determine if indexed information for any entry in the indexed ICache has been excluded from this index. This information is used by IIndexAwareFilter implementations to determine the most optimal way to apply the index.

Declaration
public virtual bool IsPartial { get; }
Property Value
Type Description
bool

true if any entry of the indexed ICache has been excluded from the index, false otherwise

ValueExtractor

IValueExtractor object that this ICacheIndex uses to extract an indexable Object from a [converted] value stored in the Storage. This property is never null.

Declaration
public virtual IValueExtractor ValueExtractor { get; protected set; }
Property Value
Type Description
IValueExtractor

Methods

AddInverseCollectionMapping(IDictionary, ICollection, object)

Add new mappings from the elements of the given value to the given key in the supplied index.

Declaration
protected virtual void AddInverseCollectionMapping(IDictionary index, ICollection value, object key)
Parameters
Type Name Description
IDictionary index

the index to which to add the mapping

ICollection value

the indexed ICollection value (each element serves as a key in the inverse index)

object key

the key to insert into the inverse index

AddInverseMapping(IDictionary, object, object)

Add a new mapping from the given indexed value to the given key in the supplied index.

Declaration
protected virtual void AddInverseMapping(IDictionary index, object value, object key)
Parameters
Type Name Description
IDictionary index

the index to which to add the mapping

object value

the indexed value

object key

the key to insert into the inverse index

AddInverseMapping(object, object)

Add a new mapping from the given indexed value to the given key in the inverse index.

Declaration
protected virtual void AddInverseMapping(object value, object key)
Parameters
Type Name Description
object value

The index value (serves as a key in the inverse index).

object key

the key to insert into the inverse index

CollectRemoved(object, object)

Given that the old value is known to be a Collection or an array, collect all the enclosed elements that are not part of the new value.

Declaration
protected HashSet CollectRemoved(object valueOld, object valueNew)
Parameters
Type Name Description
object valueOld

The old value, must be a collection or an array.

object valueNew

The new value.

Returns
Type Description
HashSet

The set of values that are contained in the old collection or array, but not part of the new value.

Delete(ICacheEntry)

Update this index in response to a remove operation on a cache.

Declaration
public virtual void Delete(ICacheEntry entry)
Parameters
Type Name Description
ICacheEntry entry

The entry representing the object being removed.

DeleteInternal(ICacheEntry)

Update this index in response to a remove operation on a cache.

Declaration
protected virtual void DeleteInternal(ICacheEntry entry)
Parameters
Type Name Description
ICacheEntry entry

The entry representing the object being removed.

EnsureCollection(object)

Return a Collection representation of the specified value, which could be a Collection, Object[], scalar, or NO_VALUE.

Declaration
protected static ICollection EnsureCollection(object value)
Parameters
Type Name Description
object value

The value.

Returns
Type Description
ICollection

A Collection representation of the specified value, or an empty Collection if NO_VALUE.

Equals(object)

Determines whether the specified object is equal to this object.

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
object obj

The object to compare with this object.

Returns
Type Description
bool

true if the specified object is equal to this object; otherwise, false.

Overrides
object.Equals(object)

Equals(SimpleCacheIndex)

Compares this index with another index for equality.

Declaration
public virtual bool Equals(SimpleCacheIndex index)
Parameters
Type Name Description
SimpleCacheIndex index

index to compare this index with.

Returns
Type Description
bool

true if the two indexes are equal; false otherwise.

Remarks

This method returns true if this index and the specified index have exactly the same contents.

ExtractNewValue(ICacheEntry)

Extract the "new" value from the specified entry.

Declaration
protected object ExtractNewValue(ICacheEntry entry)
Parameters
Type Name Description
ICacheEntry entry

The entry to extract the "new" value from.

Returns
Type Description
object

The extracted "new" value, or NO_VALUE if the extraction failed

ExtractOldValue(CacheEntry)

Extract the "old" value from the specified entry.

Declaration
protected object ExtractOldValue(CacheEntry entry)
Parameters
Type Name Description
CacheEntry entry

The entry to extract the "old" value from.

Returns
Type Description
object

The extracted "old" value, or NO_VALUE if the extraction failed.

Get(object)

Using the index information if possible, get the value associated with the specified key. This is expected to be more efficient than using the IValueExtractor against an object containing the value, because the index should already have the necessary information at hand.

Declaration
public virtual object Get(object key)
Parameters
Type Name Description
object key

The key that specifies the object to extract the value from.

Returns
Type Description
object

The value that would be extracted by this ICacheIndex's IValueExtractor from the object specified by the passed key; NO_VALUE if the index does not have the necessary information.

GetForwardValue(object)

Get the forward index value associated with the specified key.

Declaration
protected virtual object GetForwardValue(object key)
Parameters
Type Name Description
object key

The key.

Returns
Type Description
object

The value associated with the key.

GetHashCode()

Returns a hash code for this object.

Declaration
public override int GetHashCode()
Returns
Type Description
int

A hash code for this object.

Overrides
object.GetHashCode()

Initialize(bool)

Initialize the index's data structures.

Declaration
protected virtual void Initialize(bool forwardIndex)
Parameters
Type Name Description
bool forwardIndex

true If forward index is supported; false otherwise.

Insert(ICacheEntry)

Update this index in response to a insert operation on a cache.

Declaration
public virtual void Insert(ICacheEntry entry)
Parameters
Type Name Description
ICacheEntry entry

The entry representing the object being inserted.

InsertInternal(ICacheEntry)

Update this index in response to a insert operation on a cache.

Declaration
protected virtual void InsertInternal(ICacheEntry entry)
Parameters
Type Name Description
ICacheEntry entry

The entry representing the object being inserted.

InstantiateForwardIndex()

Instantiate the forward index.

Declaration
protected virtual IDictionary InstantiateForwardIndex()
Returns
Type Description
IDictionary

The forward index.

InstatiateInverseIndex(bool, IComparer)

Instantiate the inverse index.

Declaration
protected virtual IDictionary InstatiateInverseIndex(bool ordered, IComparer comparer)
Parameters
Type Name Description
bool ordered

true iff the contents of the indexed information should be ordered; false otherwise.

IComparer comparer

The IComparator object which imposes an ordering on entries in the index; or null if the entries' values natural ordering should be used.

Returns
Type Description
IDictionary

The inverse index.

IsKeyExcluded(object)

Check if the entry with the given key is excluded from the index.

Declaration
protected bool IsKeyExcluded(object key)
Parameters
Type Name Description
object key

The key to test

Returns
Type Description
bool

True if the key is in the list of keys currently excluded from the index, false if the entry with the key is in the index.

LogMissingIdx(object, object)

Log messages for missing inverse index.

Declaration
protected void LogMissingIdx(object value, object key)
Parameters
Type Name Description
object value

the indexed value

object key

the key

RemoveForwardEntry(object)

Remove the forward index entry for the specified key.

Declaration
protected virtual void RemoveForwardEntry(object key)
Parameters
Type Name Description
object key

The key to remove the forward index entry for.

RemoveInverseMapping(IDictionary, object, object)

Remove the mapping from the given indexed value to the given key from the supplied index.

Declaration
protected virtual void RemoveInverseMapping(IDictionary index, object value, object key)
Parameters
Type Name Description
IDictionary index

the index from which to remove the mapping

object value

the indexed value

object key

the key

RemoveInverseMapping(object, object)

Remove the mapping from the given indexed value to the given key from the inverse index.

Declaration
protected virtual void RemoveInverseMapping(object value, object key)
Parameters
Type Name Description
object value

The indexed value, or NO_VALUE if unknown.

object key

The key

RemoveInverseMapping(object, object, ICollection)

Remove the mapping from the given indexed value to the given key from the inverse index.

Declaration
protected virtual void RemoveInverseMapping(object value, object key, ICollection colIgnore)
Parameters
Type Name Description
object value

The indexed value.

object key

The key.

ICollection colIgnore

The Collection of values to ignore (exclude from removal), or null.

ToString()

Returns string representation of this instance.

Declaration
public override string ToString()
Returns
Type Description
string

String representation of this instance.

Overrides
object.ToString()

Update(ICacheEntry)

Update this index in response to a update operation on a cache.

Declaration
public virtual void Update(ICacheEntry entry)
Parameters
Type Name Description
ICacheEntry entry

The entry representing the object being updated.

UpdateExcludedKeys(ICacheEntry, bool)

Check the entry against the set of entries not included in the index and update the set if necessary.

Declaration
protected void UpdateExcludedKeys(ICacheEntry entry, bool excluded)
Parameters
Type Name Description
ICacheEntry entry

The entry to be checked.

bool excluded

True if the insert or update of the entry into the index caused an exception.

UpdateInternal(ICacheEntry)

Update this index in response to a update operation on a cache.

Declaration
protected virtual void UpdateInternal(ICacheEntry entry)
Parameters
Type Name Description
ICacheEntry entry

The entry representing the object being updated.

Implements

ICacheIndex
In this article
Back to top Copyright © 2000, 2024, Oracle and/or its affiliates.