abstract class %Library.IndexBuilderThe purpose of this class is to allow one or more indices to be added to a class on a system that can afford little downtime, and the normal %BuildIndices process would take a very long time because the large amount of data in the class/table. %Library.IndexBuilder implements an interface to build indices for a class using multiple processes.
-- The preferred index building utilty is now the %BuildIndices method of each persistent class, not %Library.IndexBuilder/%ConstructIndicesParallel().
-- %Library.IndexBuilder/%ConstructIndicesParallel() may only be used with classes that have positive INTEGER ID values.
-- The only feature %Library.IndexBuilder/%ConstructIndicesParallel() has that %BuildIndices does not is the SortBegin flag.
Construct Index Parallel
The %Library.IndexBuilder class contains methods that can be inherited into persistent classes that will allow indices defined in the class to be built using multiple processes. The class allows one or more indices to be added to a class on a system that can afford little down-time, and the normal %BuildIndices process would take a very long time because the amount of data in the class/table.
To add the IndexBuilder methods to your class, your class definition must list %Library.IndexBuilder as a superclass. There is also a class parameter recognized by the methods of %Library.IndexBuilder called INDEXBUILDERFILTER. INDEXBUILDERFILTER parameter is a string value of index names delimited by a comma if there is more than one name. INDEXBUILDERFILTER is looked at to determine which indices should be built by the %ConstructIndicesParallel method. For example, suppose you add the NameIDX index to class Sample.Person and would like to build only that Index. Define the INDEXBUILDERFILTER parameter as follows:
Parameter INDEXBUILDERFILTER = "NameIDX";
Then when %ConstructIndicesParallel() method is called, only the NameIDX index will be built.
If INDEXBUILDERFILTER is not defined or set to "", all indices in the class will be built.
When you are ready to build the index, call the %ConstructIndicesParallel() method of the class you want to build the index for. Above we added the NameIDX index to Sample.Person, so you would make the following call:
The arguments to %ConstructIndicesParallel are as follows:
1) TaskId - For internal use only. For direct, interactive callers, leave this undefined. 2) StartId - ID of the table to start building the ID for. Default is 1 3) EndId - ID of the table you want to end the Index build on. Default is -1 which means end at the last ID of the table 4) Sortbegin - 1/0 Flag which determines if the index build will use the SortBegin feature. 5) DroneCount - Number of background jobs to use to build the indices. Default is 0, in which case the code will determine the number of Drones to use based on the number of CPUs and the range of rows being indexed. 6) LockFlag - Flag that determines locking behavior for the index build. 0 = No locking performed for the index build 1 = Extent locking - Acquires an exclusive lock on the entire extent for the duration of the index build 2 = Row level locking - Acquires a shared lock for each row as it is processed and the index defined for the entry. When index build for this row is complete, an immediate unlock of this row is performed. 7) JournalFlag - 0/1 flag. 1 means the index building will be journalled. 0 means turn off journalling for this index build
The following example will build the NameIDX of the Sample.Person table for all rows:
This builds the index entry for the NameIDX for all rows with ID 1 through the last ID of the class/table. It uses SortBegin, performs Extent level locking, and the index build is journalled.
This builds the index entry for the NameIDX for all rows with ID 1 through 50,000,000 of the class/table. It uses SortBegin, performs row level level locking, and the index build is not journalled.
Method Inventory (Including Private)
Methods (Including Private)
%ConstructIndicesParallel() will build the indices of this class (optionally filtered by the INDEXBUILDERFILTER class parameter)
Arguments: pTaskId - TaskID of the background job - leave blank/undefined for the interactive caller pStartId - ID of the tabl