IInMemManager.GetMatrix

Syntax

GetMatrix(Executor: ICubeInstanceDestinationExecutor; Selection: IDimSelectionSet; [Options: Integer = 0]): IMatrix;

Parameters

Executor. Object used for cube calculation.

Selection. Selection, according to which calculation is executed.

Options. Cube calculation options.

Description

The GetMatrix method returns matrix with data from cache according to the specified cube calculation options.

Comments

To check if cache contains cube data, use the CheckHasMatrix method.

Example

Executing the example requires that the repository contains a cube with the STD_CUBE identifier. The cube contains a dimension with the Country identifier. The repository uses In-Memory caching mechanism.

Add links to the Cubes and Metabase system assemblies.

Sub UserProc;
Var
    Mb: IMetabase;
    CubeInst: ICubeInstance;
    DestInst: ICubeInstanceDestination;
    InMem: IInMemManager;
    DimSS: IDimSelectionSet;
    DimS: IDimSelection;
    Matr: IMatrix;
Begin
    Mb := MetabaseClass.Active;
    
// Open cube
    CubeInst := Mb.ItemById("STD_CUBE").Open(NullAs ICubeInstance;
    DestInst := CubeInst.Destinations.DefaultDestination;
    
// Selection, according to which work is executed
    DimSS := DestInst.CreateDimSelectionSet;
    
For Each DimS In DimSS Do
        
If DimS.Dimension.Ident = "COUNTRY" Then
            DimS.SelectElement(
0False);
        
Else
            DimS.SelectAll;
        
End If;
    
End For;
    
// Manager for working with In-Memory cache
    InMem := New InMemManager.Create;
    
// Check if cache contains data
    If InMem.CheckHasMatrix(DestInst) Then
        
// Get matrix with data
        Matr := InMem.GetMatrix(DestInst.CreateExecutor, DimSS);
        
// Get matrix
        ShowMatrix(Matr);
        
// Update data in cache from source
        InMem.UpdateBySelection(DestInst, DimSS);
    
Else
        InMem.PrepareMatrixPartial(DestInst, DimSS);
    
End If;
End Sub UserProc;

Sub ShowMatrix(Matr: IMatrix);
Var
    Iter: IMatrixIterator;
Begin
    
If Matr.Count <> 0 Then
        Iter := Matr.CreateIterator;
        Iter.Move(IteratorDirection.First);
        
While Iter.Valid Do
            Debug.Write(Iter.Value + 
" ");
            Iter.Move(IteratorDirection.Next);
        
End While;
        Debug.WriteLine(
"");
    
Else
        Debug.WriteLine(
"Empty");
    
End If;
End Sub ShowMatrix;

After executing the example it is checked if there is cached data for the specified cube. If there is cached data, the matrix with data is obtained according to the specified selection. The obtained data is displayed in the development environment console, after which cached data is updated according to the source data.

If there are no cached data, a new matrix with data is built and saved.

See also:

IInMemManager