repairCollection
repairCollection(coll: Collection input);
The repairCollection method of the Application class removes invalid object references and fixes up dictionary keys in the collection specified in the coll parameter. The repairCollection method enables you to perform an online repair of a collection while it is concurrently updated, as shown in the following example.
app.repairCollection(aColl);
The repairCollection method implemented by the Application class creates and executes a background process that invokes a CollClass method to perform the repair.
To perform a repair synchronously, you can invoke the CollClass method directly, as shown in the following example.
Collection.repairCollection(aColl);
The repairCollection method records progress information and information about entries that have been corrected, in the jommsg.log file.
This method iterates the collection specified in the coll parameter and performs the following actions.
-
Sets, arrays, and external key dictionaries:
Removes references to non-existent objects or references that are not type-compatible with the membership of the collection.
-
Member key dictionaries and dynamic dictionaries (DynaDictionary instances).
Removes references to non-existent objects or references that are not type-compatible with the membership and checks that dictionary keys match the member keys. When they do not, the entry is removed and reinserted with the correct keys.
No action is taken with arrays of primitive types.
The repairCollection method differs from the Collection::rebuild method used by the JADE Logical Certifier utility in the following ways.
-
Does not have to be enclosed in a transaction to repair persistent collections but instead it iterates the target collection and performs a database transaction for each entry that requires repair.
-
Does not attempt to restore structural integrity of the collection itself as it deals only with entries within the collection.
When there are a relatively small number of entries to be repaired in a large collection, the Application class repairCollection method is significantly faster than the Collection::rebuild method used by the JADE Logical Certifier utility and it is designed to be invoked online.
Use the Application::repairCollection method only when you know that the collection is structurally sound and that only the entries in that collection are invalid. You can obtain an indication of the structural integrity of the collection by iterating the collection and counting entries. If the iteration completes without encountering an exception and the number of entries is equal to the value of the Collection::size property, it is likely the collection is structurally sound. When in doubt about the structural integrity, use the JADE Logical Certifier utility, which uses the Collection::rebuild method. For details, see Chapter 5, "
Because the repair is done by a background process, you can use the repairCollection method only with committed persistent or shared transient collections.