Class KeyAssociatedFilter
IFilter which limits the scope of another filter according to the key association information.
Inherited Members
Namespace: Tangosol.Util.Filter
Assembly: Coherence.dll
Syntax
public class KeyAssociatedFilter : IFilter, IPortableObject
Remarks
-
Make the ChildKey class implement KeyAssociation as follows:
and the ParentKey class implement KeyAssociation as follows:public Object AssociatedKey { get { return ParentId; } }
public Object AssociatedKey { get { return Id; } }
-
Implement a custom KeyAssociator as follows:
public object GetAssociatedKey(object key) { if (key is ChildKey) { return ((ChildKey) key).ParentId; } else if (key is ParentKey) { return ((ParentKey) key).Id; } else { return null; } }
ParentKey parentKey = new ParentKey(...);
Long parentId = parentKey.Id;
// this Filter will be applied to all Child objects in order to fetch
// those for which ParentId returns the specified Parent identifier
IFilter filterEq = new EqualsFilter("ParentId", parentId);
// this Filter will direct the query to the cluster node that
// currently owns the Parent object with the given identifier
IFilter filterAsc = new KeyAssociatedFilter(filterEq, parentId);
// run the optimized query to get the ChildKey objects
ICollection colChildKeys = cacheChildren.Keys(filterAsc);
// get all the Child objects at once
ICollection colChildren = cacheChildren.GetAll(colChildKeys);
To remove the Child objects you would then do the following:
cacheChildren.Keys.RemoveAll(colChildKeys);
Constructors
KeyAssociatedFilter()
Default constructor.
Declaration
public KeyAssociatedFilter()
KeyAssociatedFilter(IFilter, object)
Construct a key associated filter.
Declaration
public KeyAssociatedFilter(IFilter filter, object hostKey)
Parameters
Type | Name | Description |
---|---|---|
IFilter | filter | The underlying (wrapped) filter. |
object | hostKey | The host key that serves as an associated key for all keys that the wrapped filter will be applied to. |
Properties
Filter
Obtain the wrapped IFilter.
Declaration
public virtual IFilter Filter { get; }
Property Value
Type | Description |
---|---|
IFilter | The wrapped filter object. |
HostKey
Obtain the host key that serves as an associated key for all keys that the wrapped filter will be applied to.
Declaration
public virtual object HostKey { get; }
Property Value
Type | Description |
---|---|
object | The host key. |
Methods
Equals(object)
Compare the KeyAssociatedFilter with another object to determine equality.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The KeyAssociatedFilter to compare to. |
Returns
Type | Description |
---|---|
bool | true if this KeyAssociatedFilter and the passed object are equivalent KeyAssociatedFilter objects. |
Overrides
Remarks
Two KeyAssociatedFilter objects are considered equal if the wrapped filters and host keys are equal.
Evaluate(object)
Apply the test to the object.
Declaration
public virtual bool Evaluate(object o)
Parameters
Type | Name | Description |
---|---|---|
object | o | An object to which the test is applied. |
Returns
Type | Description |
---|---|
bool | true if the test passes, false otherwise. |
GetHashCode()
Determine a hash value for the KeyAssociatedFilter object according to the general object.GetHashCode() contract.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | An integer hash value for this KeyAssociatedFilter object. |
Overrides
ReadExternal(IPofReader)
Restore the contents of a user type instance by reading its state using the specified IPofReader object.
Declaration
public virtual void ReadExternal(IPofReader reader)
Parameters
Type | Name | Description |
---|---|---|
IPofReader | reader | The IPofReader from which to read the object's state. |
Exceptions
Type | Condition |
---|---|
IOException | If an I/O error occurs. |
ToString()
Return a human-readable description for this KeyAssociatedFilter.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A string description of the KeyAssociatedFilter. |
Overrides
WriteExternal(IPofWriter)
Save the contents of a POF user type instance by writing its state using the specified IPofWriter object.
Declaration
public virtual void WriteExternal(IPofWriter writer)
Parameters
Type | Name | Description |
---|---|---|
IPofWriter | writer | The IPofWriter to which to write the object's state. |
Exceptions
Type | Condition |
---|---|
IOException | If an I/O error occurs. |