Show / Hide Table of Contents

Class ConditionalRemove

ConditionalRemove is an IEntryProcessor that performs an Remove(bool) operation if the specified condition is satisfied.

Inheritance
object
AbstractProcessor
ConditionalRemove
Implements
IEntryProcessor
IPortableObject
Inherited Members
object.Equals(object, object)
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
Namespace: Tangosol.Util.Processor
Assembly: Coherence.dll
Syntax
public class ConditionalRemove : AbstractProcessor, IEntryProcessor, IPortableObject
Remarks

While the ConditionalRemove processing could be implemented via direct key-based IQueryCache operations, it is more efficient and enforces concurrency control without explicit locking.

For example, the following operations are functionally similar, but the IInvocableDictionary versions (a) perform significantly better for partitioned caches; (b) provide all necessary concurrency control (which is ommited from the IQueryCache examples):

  
IInvocableCache IQueryCache
cache.invoke(key, new ConditionalRemove(filter)); if (filter.Evaluate(cache[key]) cache.Remove(key);
cache.InvokeAll(colKeys, new ConditionalRemove(filter)); foreach (object key in colKeys) if (filter.Evaluate(cache.[key]) cache.Remove(key);
cache.InvokeAll(filter1, new ConditionalRemove(filter2); foreach (object key in cache.GetKeys(filter1)) if (filter2.Evaluate(cache[key]) cache.Remove(key);
cache.InvokeAll(filter, new ConditionalRemove(AlwaysFilter.INSTANCE)); ICollection colKeys = cache.GetKeys(filter); cache.Keys.RemoveAll(colKeys);

Constructors

ConditionalRemove()

Default constructor.

Declaration
public ConditionalRemove()

ConditionalRemove(IFilter)

Construct a ConditionalRemove processor that removes an IInvocableCacheEntry if and only if the filter applied to the entry evaluates to true.

Declaration
public ConditionalRemove(IFilter filter)
Parameters
Type Name Description
IFilter filter

The filter to evaluate an entry.

Remarks

The result of the Process(IInvocableCacheEntry) invocation does not return any result.

ConditionalRemove(IFilter, bool)

Construct a ConditionalRemove processor that removes an IInvocableCacheEntry if and only if the filter applied to the entry evaluates to true.

Declaration
public ConditionalRemove(IFilter filter, bool ret)
Parameters
Type Name Description
IFilter filter

The filter to evaluate an entry.

bool ret

Specifies whether or not the processor should return the current value if it has not been removed.

Remarks

This processor may optionally return the current value as a result of the invocation if it has not been removed (the filter evaluated to false).

Fields

m_filter

The underlying filter.

Declaration
protected IFilter m_filter
Field Value
Type Description
IFilter

m_return

Specifies whether or not a return value is required.

Declaration
protected bool m_return
Field Value
Type Description
bool

Methods

Equals(object)

Compare the ConditionalRemove with another object to determine equality.

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

The object to compare with.

Returns
Type Description
bool

true iff this ConditionalRemove and the passed object are equivalent ConditionalRemove.

Overrides
object.Equals(object)

GetHashCode()

Determine a hash value for the ConditionalRemove object according to the general GetHashCode() contract.

Declaration
public override int GetHashCode()
Returns
Type Description
int

An integer hash value for this ConditionalRemove object.

Overrides
object.GetHashCode()

Process(IInvocableCacheEntry)

Process an IInvocableCacheEntry.

Declaration
public override object Process(IInvocableCacheEntry entry)
Parameters
Type Name Description
IInvocableCacheEntry entry

The IInvocableCacheEntry to process.

Returns
Type Description
object

The result of the processing, if any.

Overrides
AbstractProcessor.Process(IInvocableCacheEntry)

ProcessAll(ICollection)

Process a collection of IInvocableCacheEntry objects.

Declaration
public override IDictionary ProcessAll(ICollection entries)
Parameters
Type Name Description
ICollection entries

A read-only collection of IInvocableCacheEntry objects to process.

Returns
Type Description
IDictionary

A dictionary containing the results of the processing, up to one entry for each IInvocableCacheEntry that was processed, keyed by the keys of the dictionary that were processed, with a corresponding value being the result of the processing for each key.

Overrides
AbstractProcessor.ProcessAll(ICollection)

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 ConditionalRemove.

Declaration
public override string ToString()
Returns
Type Description
string

A String description of the ConditionalRemove.

Overrides
object.ToString()

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.

Implements

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