getClassAccessFrequencies
getClassAccessFrequencies(clsNumArray: IntegerArray; freqArray: Integer64Array input);
The getClassAccessFrequencies method of the System class returns access counts for specified classes. The class numbers of these classes are added to the array specified by the clsNumArray parameter before the method is called. The access counts for classes are held on the database server node, and are incremented every time an instance of that class or one of its subobjects is written to the database or fetched from the database. Only persistent object accesses are counted.
If the enableClassAccessFrequencies method of the Process class has not been called to enable the counting of accesses to classes an exception is raised.
The access counts do not directly indicate how many times applications have used objects. If an object resides in the persistent object cache, it may not have to be fetched from the database when used. The access counts reflect database activity, rather than application activity.
The access counts are returned as
The calling process is responsible for creating and deleting the two arrays used with this method.
The access counts are cumulative values, which do not get reset during the lifetime of the database server node, are held as 64-bit unsigned integer values, and are added to the freqArray array object as Integer64 values. The maximum value before they wrap around to negative values is therefore 2^63 - 1 (approximately 8 Exabytes).
When dealing with classes, retrieve the class number by using the number property of the
The following example shows the use of the getClassAccessFrequencies method.
showClassAccessFrequencies(); vars clsNumArray : IntegerArray; freqArray : Integer64Array; i : Integer; cls : Class; begin create clsNumArray transient; create freqArray transient; foreach i in 2048 to 10000 do //check user classes clsNumArray.add(i); endforeach; system.getClassAccessFrequencies(clsNumArray,freqArray); foreach i in 1 to clsNumArray.size do if freqArray[i] > 0 then cls := currentSchema.getClassByNumber(clsNumArray[i]); write "Schema " & cls.schema.name & " Class " & cls.name & " accesses= " & freqArray[i].String; endif; endforeach; epilog delete clsNumArray; delete freqArray; end;
The output from the getClassAccessFrequencies method shown in the previous example is as follows.
Schema CompilerSchemaImport Class GCompilerSchemaImport accesses= 1 Schema CompilerSchema Class C1 accesses= 6 Schema CompilerSchema Class GCompilerSchema accesses= 1 Schema CompilerSchemaSub Class GCompilerSchemaSub accesses= 1 Schema CompilerSchema Class C2 accesses= 4 Schema CompilerSchema Class C1Dict accesses= 2 Schema CompilerSchema Class C2Dict accesses= 4 Schema Martini Class GMartini accesses= 1 Schema Martini Class Root accesses= 1 Schema Martini Class SportsTeam accesses= 4 Schema CompilerVersioningTests Class GCompilerVersioningTests accesses= 1 Schema CompilerVersioningTests Class TestInfo accesses= 25