Deleting all instances of a concept (similar to truncate in databases) with minimal overhead/processing time.

Deleting all instances of a concept (similar to truncate in databases) with minimal overhead/processing time.

book

Article ID: KB0091969

calendar_today

Updated On:

Products Versions
TIBCO BusinessEvents Enterprise Edition -
Not Applicable -

Description

Resolution:
Description:
=========
Under some circumstances there may be  a requirement to delete all instances of a concept (similar to truncate in databases) in a TIBCO BusinessEvents (BE) project with minimal overhead/processing time. This article explains on how to achieve this.


Environment:
==========
TIBCO BusinessEvents - Version 3.x, 4.x
All OS

Cause:
=====
Requirement calls for deletion of all instances of a concept (similar to truncate in databases) in a TIBCO BusinessEvents (BE) project. Some implementations/logic may take more overhead/processing time.

Resolution:
=========
* You can create a Rule function that can be used as a filter to selectively delete the Concepts or pass null to delete all instances of the Concept.

* If you plan to use a Rule function filter then you will have to make the return value as Boolean for the function. This function will get invoked for each Concept in the Cache, so keep this quick and simple.

Return true to delete. False to retain the instance.

* This does not take care of contained or parent Concepts. It deletes the instance and nothing else. You will have to handle the relationships of contained or parent concepts yourself.

* It would be good to perform this operation quickly as you might not be able to lock anything in particular.

Sample delete Rule that deletes instance of a Concept "/Main":
--------------------------------------------------------------

System.debugOut("Attempting to delete objects");

String className = Coherence.C_ClassName("/Main");

Object[] args = {};

//Create the filter.

Object filter = Coherence.Filters.C_RuleFunction(className,
"/DeleteFilterRuleFunction", args);

String cacheName = Coherence.C_CacheName("/Main");

//Use the filter along with the Cache name you wish to perform the
operation on. Pass null when filter is not required.

int deletedCount =
Coherence.Query.C_CacheOnlyMode_DeleteConcepts(cacheName, filter);

System.debugOut("Deleted " + deletedCount + " " + cacheName +  " objects");

Issue/Introduction

Deleting all instances of a concept (similar to truncate in databases) with minimal overhead/processing time.