GetMatrix(Executor: ICubeInstanceDestinationExecutor; Selection: IDimSelectionSet; [Options: Integer = 0]): IMatrix;
Executor. Object used for data calculation.
Selection. Selection according to which calculation is executed.
Options. Cube calculation parameters.
The GetMatrix method returns matrix with data from cache according to the specified parameters of cube calculation.
To check, whether cache contains data for cube, use the CheckHasMatrix method.
Executing the example requires that the repository contains a cube with the STD_CUBE identifier. The cube contains 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(Null) As 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(0, False);
Else
DimS.SelectAll;
End If;
End For;
// Manager to work with In-Memory cache
InMem := New InMemManager.Create;
// Check whether there is data in cache
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;
On executing the example, it will be checked whether there is cached data for the specified cube. If there is cached data, the matrix with data will be obtained according to the specified selection. Obtained data will be displayed to the development environment console, after that data in cache will be updated according to the source data.
If there are no cached data, new matrix with data will be built and saved.
See also: