Class Reference
IRIS for UNIX 2019.1
InterSystems: The power behind what matters   
Documentation  Search
  [%SYS] >  [%Library] >  [Storage]
Private  Storage   

abstract class %Library.Storage

Physical Storage Base Class

Inventory

Parameters Properties Methods Queries Indices ForeignKeys Triggers
4 78


Summary

Methods
%BuildIndices %PurgeIndices %ValidateIndices

Subclasses
%Library.CustomStorage %Storage.Persistent %Storage.SQL %Storage.Shard

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 = 1, 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 journal status is not altered during BuildIndices(). The default value of this argument is 1 (TRUE).

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) 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

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.



    Copyright (c) 2019 by InterSystems Corporation. Cambridge, Massachusetts, U.S.A. All rights reserved. Confidential property of InterSystems Corporation.