@@ -1200,4 +1200,40 @@ ClassMethod PopulateFromStats(tableName As %String, rowCount As %Integer = 1000,
1200
1200
quit sc
1201
1201
}
1202
1202
1203
+ /// <p>This experimental method tries to verify whether the index <var>indexname</var> in class <var>classname</var>
1204
+ /// is empty, meaning it has just been added to the class and still needs building.</p>
1205
+ /// <p>This method does not verify whether the index is fully populated and entries are correct.
1206
+ /// You can use <method>%ValidateIndices</method> for that purpose.</p>
1207
+ ClassMethod IndexHasData (classname As %String , indexname As %String , Output status As %Status ) As %Boolean [ Internal , SqlName = IndexHasData , SqlProc ]
1208
+ {
1209
+ set status = $$$OK, hasData = 0
1210
+ try {
1211
+
1212
+ set cls = ##class (%Dictionary.CompiledClass ).%OpenId (classname ,, .status )
1213
+ quit :'$isobject (cls )
1214
+ set ss = ##class (%Dictionary.StorageDefinition ).%OpenId (classname _" ||" _cls .StorageStrategy ,, .status )
1215
+ quit :'$isobject (ss )
1216
+ if (ss .Type = " %Storage.Persistent" ) {
1217
+
1218
+ // use SQL lookup to address case sensitivity
1219
+ set location = " " , parent = classname _" ||" _ss .Name
1220
+ &SQL (SELECT Location INTO :location FROM %Dictionary .CompiledStorageIndex WHERE parent = :parent AND UPPER (Name ) = UPPER (:indexname ))
1221
+ if (SQLCODE '= 0 ) || (location = " " ) {
1222
+ set status = $$$ERROR($$$GeneralError, " Unable to find index '" _indexname _" ' in class '" _classname _" ' - " _SQLCODE )
1223
+ quit
1224
+ }
1225
+
1226
+ set hasData = $d (@location )>0
1227
+
1228
+ } else {
1229
+ set status = $$$ERROR($$$GeneralError, " Unsupported storage type: '" _ss .Type _" '" )
1230
+ quit
1231
+ }
1232
+
1233
+ } catch (e ) {
1234
+ set status = e .AsStatus ()
1235
+ }
1236
+ return hasData
1237
+ }
1238
+
1203
1239
}
0 commit comments