compactDynamicPropertyClusters

compactDynamicPropertyClusters(interval:   Integer):
                               receiver:   Object;
                               callback:   Method;
                               statistics: JadeDynamicObject);

The compactDynamicPropertyClusters method of the Class class compacts dynamic property clusters in which dynamic property instances were deleted. This method iterates all instances of the receiving class and subclass. For each instance, it locates any clusters that may contain deleted dynamic property values. If such a cluster exists, deleted values are removed and the cluster is compacted.

You can use this method to reduce the size of dynamic property clusters that contain values for dynamic property definitions that have been deleted.

The interval, receiver, and callback parameters enable you to invoke your own callback to allow the transaction to be committed and restarted periodically. The values of these parameters can all be null, in which case no callback is invoked. The interval parameter specifies the period in milliseconds between successive calls to the callback. The receiver parameter specifies the receiver of the callback.

The statistics parameter, which is also optional, enables some simple statistics to be returned (for example, the number of instances, the number of deleted values, and so on).

The signature of the callback method is:

callback(count: Integer): Boolean;

The count parameter specifies the number of instances in the current class that have been read. The return value is a continue or stop indicator; that is, continue when true or stop when false.

The following is an example of the compactDynamicPropertyClusters method.

vars
    statistics    : JadeDynamicObject;
    instanceCount : Integer;
    deletedValues : Integer;
begin
    create statistics;
    beginTransaction;
    // must be in transaction state
        MyClass.compactDynamicPropertyClusters(60000, app,  Application::callback, 
                 statistics);
    commitTransaction;
    instanceCount := statistics.getPropertyValue("instanceCount").Integer64;
    // number of instances of MyClass processed
    deletedValues := statistics.getPropertyValue("deletedValues").Integer64;
    // number of deleted dynamic properties removed
end;

The following is an example of the callback method defined in the Application class.

callback(count: Integer): Boolean;
// callback called once a minute (60,000 milliseconds) when compacting
// dynamic property clusters
vars
    continueProcessing : Boolean;
begin
    continueProcessing := true;
    // limit the number of updates in the current transaction: close
    // and re-start the transaction
    commitTransaction;
    beginTransaction;
    // display progress information
    // allow the operation to be cancelled
    return continueProcessing;
end;