Learning
Documentation
Community
Open Exchange
Global Masters
Home > Class Reference > %SYS namespace > %Storage

%Library.Storage


abstract class %Library.Storage

Physical Storage Base Class

Inventory


Parameters Properties Methods Queries Indices ForeignKeys Triggers
4 78


Summary


Methods
%BuildIndices %PurgeIndices %SQLAcquireLock %SQLAcquireTableLock
%SQLAfterTriggers %SQLBeforeTriggers %SQLBuildIndices %SQLBuildPurgeIndexForRow
%SQLBuildPurgeIndices %SQLCheckUnique %SQLCheckUniqueIndices %SQLCheckUniqueKeys
%SQLCopyIcolIntoName %SQLCopyNameIntoIcol %SQLCreateInsDelTables %SQLDefineiDjVars
%SQLDelete %SQLDeleteChildren %SQLDeleteTempStreams %SQLEExit
%SQLExists %SQLFKeyDelLock %SQLFastInsert %SQLFieldValidate
%SQLGetLock %SQLGetOld %SQLGetOldAll %SQLGetOldIndex
%SQLInsert %SQLInsertComputes %SQLInsertStreams %SQLInvalid
%SQLInvalid2 %SQLMVDelete %SQLMVIndexDelete %SQLMVIndexInsert
%SQLMVIndexUpdate %SQLMVInsert %SQLMVUpdate %SQLMissing
%SQLNormalizeCompFields %SQLNormalizeFields %SQLPurgeIndices %SQLQuickBulkInsert
%SQLQuickBulkLoad %SQLQuickBulkSave %SQLQuickBulkUpdate %SQLQuickDelete
%SQLQuickDeleteChildren %SQLQuickFindPKeyByRowID %SQLQuickFindRowIDByPKey %SQLQuickInsert
%SQLQuickLoad %SQLQuickLoadChildren %SQLQuickLogicalToOdbc %SQLQuickOdbcToLogical
%SQLQuickUpdate %SQLReleaseLock %SQLReleaseTableLock %SQLStorageValidation
%SQLTrigDelTab %SQLTrigInsTab %SQLUnlock %SQLUnlock2
%SQLUnlockError %SQLUnlockRef %SQLUpdate %SQLUpdateComputes
%SQLUpdateStreams %SQLValidateCompFields %SQLValidateFields %SQLicompView
%SQLnBuild %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.

• private classmethod %DeleteData(id As %String, concurrency As %Integer) as %Status
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.
• private classmethod %KillExtentData(killstreams As %Boolean = 0) as %Status
%KillExtentData() - kills extent data in storage. This method is implemented by the storage class. If killstreams is true (default is false) it will also kill the default stream storage global.
• private method %LoadData(id As %String) as %Status
%LoadData() - loads an object from storage. This method is implemented by the storage class.
• 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 %SQLAcquireLock(%rowid As %String, s As %Boolean = 0, ByRef unlockref As %String = 0)
• classmethod %SQLAcquireTableLock(s As %Boolean = 0, ByRef SQLCODE As %Integer, to As %Integer = "")
• classmethod %SQLAfterTriggers()
• classmethod %SQLBeforeTriggers()
• classmethod %SQLBuildIndices(pIndices As %List = "", pLockFlag As %Integer = 0, pStartID As %RawString = "", pEndID As %RawString = "", pIgnoreIndexList As %RawString = "") as %Status
• classmethod %SQLBuildPurgeIndexForRow(pIndices As %List = "", pActions As %RawString = "BP", pLockRow As %Integer = 1, ByRef %d As %RawString, ByRef %e As %RawString, pIgnoreIndexList As %RawString = "") as %Status
%SQLBuildPurgeIndexForRow - given a list of indices (or all by default), an ID, and new and old values, purge and build the index entries for the row pIndices - $listbuild of index map names to purge/build. Default is "" and means purge/build all indices pActions - A string of action characters to perform. If pActions["P", the old index entries will be Purged/Deleted. If pActions["B", the new index entries will be Built/Defined. The default is pActions="BP". This can be overridden to provide a way to just Purge a row's index entries (delete) or to define a row's index entries (Insert). Any other characters in pActions besides "B" or "P" are ignored. pLockRow - 1/0 flag, default=1, 1 means acquire an exclusive, long-term lock on the row. 0 means no lock is acquired. %d() - Array subscripted by SqlColumnNumber which holds new values for indexed entries to be built %e() - Array subscripted by SqlColumnNumber which holds old values for indexed entries to be purged pIgnoreIndexList - $listbuild of index map names to not purge/build. Can be used in conjuction with pIndices to purge/build all indices except thise list. Default is "".
• classmethod %SQLBuildPurgeIndices(pIndices As %List = "", pBuild As %Boolean, pLockFlag As %Integer = 0, pStartID As %RawString = "", pEndID As %RawString = "", pIgnoreIndexList As %RawString = "") as %Status
• classmethod %SQLCheckUnique(pFromOrig As %Boolean = 0, %pID As %String, %pVals... As %String) as %Status
• classmethod %SQLCheckUniqueIndices(pIndices As %List, ByRef pOK As %Boolean)
• classmethod %SQLCheckUniqueKeys(pConNumber As %Integer, pFromOrig As %Boolean = 0, pUpdate As %Boolean = 0, pVals... As %String)
• classmethod %SQLCopyIcolIntoName()
• classmethod %SQLCopyNameIntoIcol()
• classmethod %SQLCreateInsDelTables(ByRef pInsTrigObj As %String, ByRef pDelTrigObj As %String)
• classmethod %SQLDefineiDjVars(ByRef %d As %String, ByRef subs As %String, master As %Boolean)
• classmethod %SQLDelete(%rowid, %check, %tstart=1, %mv=0, %polymorphic=0)
This class just holds stub methods that will be injected into the class definition by the table compiler. No implementation details here.
• classmethod %SQLDeleteChildren(%parent As %String, %check As %String, ByRef sqlcode As %Integer)
• classmethod %SQLDeleteTempStreams()
• classmethod %SQLEExit()
• classmethod %SQLExists(pLockOnly As %Boolean = 0, ByRef pUnlockRef As %String, %pVal... As %String)
• classmethod %SQLFKeyDelLock()
• classmethod %SQLFastInsert(%check As %Binary) as %String
• classmethod %SQLFieldValidate()
• classmethod %SQLGetLock(pRowId As %String, pShared As %Boolean = 0, ByRef pUnlockRef As %String)
• classmethod %SQLGetOld(%rowid As %String, ByRef %d As %String, ByRef %e As %String, ByRef sqlcode As %Integer)
• classmethod %SQLGetOldAll()
• classmethod %SQLGetOldIndex(%rowid As %String, ByRef %d As %String, ByRef pF As %String = 0, ByRef sqlcode As %Integer)
• classmethod %SQLInsert(ByRef %d As %String, %check As %Binary, %inssel, %vco, %tstart=1, %mv=0) as %String
• classmethod %SQLInsertComputes(view As %Boolean = 0)
• classmethod %SQLInsertStreams(pVal As %String, pClassname As %String, pProperty As %String, pField As %String, pChangeEmptyToNull As %Boolean, pOIDType As %Boolean, ByRef sqlcode As %Integer, ByRef %msg As %String)
• classmethod %SQLInvalid(pIcol As %Integer, pVal As %String) as %Integer
• classmethod %SQLInvalid2(ficol As %Integer, val As %String, char As %String)
• classmethod %SQLMVDelete(oref As %Binary, flags As %String, %rowid As %String, oldrec As %String)
• classmethod %SQLMVIndexDelete(ByRef %e As %String)
• classmethod %SQLMVIndexInsert(ByRef %d As %String)
• classmethod %SQLMVIndexUpdate(ByRef %d As %String, ByRef %e As %String)
• classmethod %SQLMVInsert(oref As %Binary, flags As %String, %rowid As %String, newrec As %String)
• classmethod %SQLMVUpdate(oref As %Binary, flags As %String, %rowid As %String, newrec As %String, oldrec As %String)
• classmethod %SQLMissing(fname As %String)
• classmethod %SQLNormalizeCompFields()
• classmethod %SQLNormalizeFields()
• classmethod %SQLPurgeIndices(pIndices As %List = "", pLockExtent As %Boolean = 0, pIgnoreIndexList As %RawString = "")
• classmethod %SQLQuickBulkInsert(%nolock As %Boolean = 0)
• classmethod %SQLQuickBulkLoad(%rowidlist As %List, %nolock As %Boolean = 0, pkey As %Boolean = 0)
• classmethod %SQLQuickBulkSave(%nolock As %Boolean = 0)
• classmethod %SQLQuickBulkUpdate(%nolock As %Boolean = 0)
• classmethod %SQLQuickDelete(%rowid As %String, %nolock As %Boolean = 0, pkey As %Boolean = 0)
• classmethod %SQLQuickDeleteChildren(%parent As %String, %nolock As %Boolean = 0, pkey As %Boolean = 0)
• classmethod %SQLQuickFindPKeyByRowID(%rowid As %String)
• classmethod %SQLQuickFindRowIDByPKey(pPKey As %String, pOutput As %Boolean = 1, pInternal As %Boolean = 0)
• classmethod %SQLQuickInsert(ByRef d As %String, %nolock As %Boolean = 0, pkey As %Boolean = 0, parentpkey As %Boolean = 0)
• classmethod %SQLQuickLoad(%rowid As %List, %nolock As %Boolean = 0, pkey As %Boolean = 0, qq As %Boolean = 0)
• classmethod %SQLQuickLoadChildren(%parref As %List, %nolock As %Boolean = 0, pkey As %Boolean = 0, returnpkey As %Boolean = 0)
• classmethod %SQLQuickLogicalToOdbc(ByRef %d As %String)
• classmethod %SQLQuickOdbcToLogical(ByRef %d As %String)
• classmethod %SQLQuickUpdate(%rowid As %String, ByRef d As %String, %nolock As %Boolean = 0, pkey As %Boolean = 0)
• classmethod %SQLReleaseLock(%rowid As %String, s As %Boolean = 0, i As %Boolean = 0, e As %Boolean = "")
• classmethod %SQLReleaseTableLock(s As %Boolean = 0, i As %Boolean = 0)
• classmethod %SQLStorageValidation()
• classmethod %SQLTrigDelTab()
• classmethod %SQLTrigInsTab()
• classmethod %SQLUnlock()
• classmethod %SQLUnlock2()
• classmethod %SQLUnlockError(cname As %String)
• classmethod %SQLUnlockRef()
• classmethod %SQLUpdate(%rowid As %String, %check As %Binary, ByRef %d, %vco, %tstart=1, %mv=0, %polymorphic=0, ByRef %soid As %String) as %String
• classmethod %SQLUpdateComputes(view As %Boolean = 0)
• classmethod %SQLUpdateStreams(pNew As %String, pOld As %String, pClassname As %String, pProperty As %String, pField As %String, pChangeEmptyToNull As %Boolean, pOIDType As %Boolean, ByRef sqlcode As %Integer, ByRef %msg As %String, pAllowOid As %Boolean = 0)
• classmethod %SQLValidateCompFields(ByRef sqlcode As %Integer)
• classmethod %SQLValidateFields(ByRef sqlcode As %Integer)
• classmethod %SQLicompView()
• classmethod %SQLnBuild()
• private method %SaveData(id As %String) as %Status
%SaveData() - saves an object to disk, checks uniqueness and referential integrity constraints, and maintains index structures. This method is implemented by the storage class.
• 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.