Skip to main content

%Library.Storage

abstract class %Library.Storage

Physical Storage Base Class

Method Inventory

Parameters

parameter IDTYPE;
parameter SQLENABLED = 1;
parameter STORAGECOMPILERCLASS = %Compiler.Storage.Common;
parameter STORAGEINTERFACE;
STORAGEINTERFACE defines the type of serialization implemented by this class. The value has to match the classtype of the class that is inheriting the serialization interface.

Methods

classmethod %BuildIndices(pIndexList As %RawString = "", pAutoPurge As %Integer = 1, pLockFlag As %Integer = 0, pJournalFlag As %Integer = "", pStartID As %RawString = "", pEndID As %RawString = "", pIgnoreIndexList As %RawString = "") as %Status

Builds entries for each index specified in the idxlist argument. If pIndexList is empty then all indices that originate in the class are rebuilt. If no indexes are specified in pIndexList or there are other bitmap indexes specified in pIndexList and there is a bitmap extent index defined for the class and there are currently no entries in the bitmap extent index then it will be implicitly included in pIndexList. If there is an ID range specified in pStartID-pEndID and there are either no indexes specified in pIndexList or if indexes are specified then at least one of them is a bitmap index then the bitmap extent index will be implicitly included in pIndexList. If the bitmap extent index is included then the bitmap extent index for each subextent is also built.

If pAutoPurge is true then the indices contained in pIndexList will be purged before they are built as long as no range is specified, if a range is specified we will skip any purge. The default is TRUE (1).

If pLockFlag is one (1) then an extent lock will be acquired before the indices are built. If the lock cannot be acquired then an error is returned. The lock is released after the index build is completed. If it is two (2) then a lock is acquired prior to filing indexes for that instance and it is released as soon the indexes for that instance are filed. If it is zero (0) then no locks are used while filing the indexes. If it is three (3) then it an shared extent lock will be acquired before the indices are build.

If pJournalFlag is false then journaling is disabled for the processes used to build the indexes. If this flag is true then the journaling is enabled for the process used to build the indicies. The default value of this argument is "" meaning use the current process setting.

pStartID and pEndID define a range of IDs for which indexes will be built. The range is inclusive. If the starting ID is not passed a non-null value then the range begins at the first ID defined in the extent. If the ending ID is not passed a non-null value then the range ends at the last ID defined in the extent.

If pIgnoreIndexList is defined, it should be a $listbuild of index names that should not be built. This argument allows you to build all indices except those defined in pIgnoreIndexList. The default value of this argument is "", which means all indices, or all indices specified in pIndexList, will be built.

If %OnBeforeBuildIndices() is implemented and is runnable then it will be called just prior to purging and building any index structures. Refer to %OnBeforeBuildIndices() for more information.

If %OnAfterBuildIndices() is implemented and is runnable then it will be called after all index structures have been built completely. Refer to %OnAfterBuildIndices() for more information.

Returns a %Status value indicating success or failure. This method is normally generated by the storage class for persistent classes using %Storage.Persistent or %Storage.SQL.

If your index is corrupt running this function will not fix the corruption unless you rebuild the entire index and purge the existing indexes. If you have inserted some new items but have deferred building the index for these new items then you can run %BuildIndices on this range oif IDs to add the index entries for these new items.

classmethod %PurgeIndices(idxlist As %List = "", lockExtent As %Boolean = 0, pIgnoreIndexList As %RawString = "") as %Status
Deletes all entries from each index specified in the idxlist argument. If idxlist is empty then all indices that originate in the class are purged. The index definition remains intact.

If pIgnoreIndexList is defined, it should be a $listbuild of index names that should not be purged. This argument allows you to purge all indices except those defined in pIgnoreIndexList. The default value of this argument is "", which means all indices, or all indices specified in pIndexList, will be purged.

Returns a %Status value indicating success or failure. This method is normally generated by the storage class for persistent classes using %Storage.Persistent or %Storage.SQL. Persistent classes using some other storage class, such as %Library.CustomStorage must override this method.

classmethod %ValidateIndices(idxList As %List = "", autoCorrect As %Boolean = 0, lockOption As %Integer = 1, multiProcess As %Boolean = 1, ByRef mapList As %String, verbose As %Boolean = 1, ByRef errors As %String) as %Status
%ValidateIndices() - Validates indices for a class

Parameters:
idxList
Optional. "" to check all indices, or specify a $list of index names to check. Default=""
autoCorrect
Optional. If true, correct any errors found. Default=0
lockOption
Optional. Default = 1 0 - No locking is performed at all 1 - Shared locking as each row is checked 2 - exclusive lock on entire table for duration of the run
multiProcess
Optional. If true, parts of %ValidateIndices will use parallel processing when possible. Default=1
verbose
Optional. If true, display output to the current device. Default=1
errors
Optional. Passed by reference. Returns an array of errors found in the index(es) validated. If autoCorrect=1, this is an array of issues corrected.

Returns:

Status Code

Example:

  • Do $SYSTEM.OBJ.ValidateIndices("Sample.Person","",1,2)
  • Do $SYSTEM.OBJ.ValidateIndices("Sample.Company",$lb("NameIdx"),1,1)
  • Note::
    Indices may also be validated by calling the class method $SYSTEM.OBJ.ValidateIndices(classname,idxList,autoCorrect,lockOption).
    There is one main difference between validating indices through $SYSTEM.OBJ.ValidateIndices() and ##class(classname).%ValidateIndices().
    $SYSTEM.OBJ.ValidateIndices() will validate the indices for a table, and it will also validate any indices in collection child tables for that table.
    When using ##class(classname).%ValidateIndices(), collection child table indices must be checked with separate calls.
    Also, when calling $SYSTEM.OBJ.ValidateIndices(), multiProcess default is 0. When calling ##class(classname).%ValidateIndices(), multiProcess default is 1.

    classmethod %ValidateTable(lockOption As %Integer = 1, multiProcess As %Boolean = 1, verbose As %Boolean = 1, ByRef errors As %String) as %Status
    %ValidateTable() - Validates a table's data

    Parameters:
    lockOption
    Optional. Default = 1 0 - No locking is performed at all 1 - Shared locking as each row is checked 2 - exclusive lock on entire table for duration of the run
    multiProcess
    Optional. If true, parts of %ValidateIndices will use parallel processing when possible. Default=1
    verbose
    Optional. If true, display output to the current device. Default=1
    errors
    Optional. Passed by reference. Returns an array of errors found in the index(es) validated. If autoCorrect=1, this is an array of issues corrected.

    Returns:

    Status Code

    Example:

  • Do $SYSTEM.OBJ.ValidateTable("Sample.Person",1,2)
  • Do $SYSTEM.OBJ.ValidateTable("Sample.Company",1,1)
  • Subclasses

    FeedbackOpens in a new tab