ICubeCacheItem.GetCubeInstance

Syntax

GetCubeInstance: ICubeInstance;

Description

The GetCubeInstance method returns the opened cube instance, for which cache is saved.

Example

Executing the example requires a standard cube with the STD_CUBE identifier. A data set is cache for the cube.

Add links to the Cubes, Matrix, and Metabase system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    MDesc, CacheDesc: IMetabaseObjectDescriptor;
    CubeInst: ICubeInstance;
    DestInst: ICubeInstanceDestination;
    CacheSaver: ICubeCacheSaver;
    Items: ICubeCacheItems;
    Item: ICubeCacheItem;
    Matr: IMatrix;
Begin
    MB := MetabaseClass.Active;
    MDesc := MB.ItemById("STD_CUBE");
    // Get cache storage
    CacheDesc := GetCache(MDesc);
    If CacheDesc <> Null Then
        CacheSaver := CacheDesc.Edit As ICubeCacheSaver;
        // Cache instances from DBMS
        Items := CacheSaver.GetItemsFromDatabase;
        If Items.Count > 0 Then
            Item := Items.Item(0);
            CubeInst := Item.GetCubeInstance;
            Debug.WriteLine("Cube: " + (CubeInst.Cube As IMetabaseObject).Name);
            DestInst := Item.GetCubeInstanceDestination;
            Debug.WriteLine("Destination: " + DestInst.Name);
            Item.LoadMatrix;
            Matr := Item.GetMatrix;
            Debug.WriteLine("Matrix count values: " + Matr.Count.ToString);
        End If;
    End If;
End Sub UserProc;

Function GetCache(MObj: IMetabaseObjectDescriptor): IMetabaseObjectDescriptor;
Var
    Desc: IMetabaseObjectDescriptor;
Begin
    For Each Desc In MObj.Children Do
        If Desc.ClassId = MetabaseObjectClass.KE_CLASS_CUBE_CACHE_SAVER Then
            Return Desc;
        End If;
    End For;
    Return Null;
End Function GetCache;

After executing the example, cache instance will be obtained for the specified cube. Based on the first cache instance, the development environment console will display information about the cube and cube display version, for which data was cached, and also the number of elements in the matrix saved in the cache.

See also:

ICubeCacheItem