ICubeCombinedExecutor.AddCube

Syntax

AddCube(Cube: ICubeInstance; Selection: IDimSelectionSet);

AddCube(Cube: Prognoz.Platform.Interop.Cubes.ICubeInstance; Selection: Prognoz.Platform.Interop.Dimensions.IDimSelectionSet);

Parameters

Cube. The opened cube instance that must be added for calculation.

Selection. The dimension selection, according to which calculation is executed.

Description

The AddCube method adds a cube to the list for parallel calculation.

Comments

The cube must meet the requirements presented in description of the ICubeCombinedExecutor interface.

Example

Executing the example requires that the repository contains two standard cubes with the STD_CUBE1 and STD_CUBE2 identifiers. Cube settings meet the specified requirements. Each cube contains three dimensions.

Add links to the Cubes, Dimensions, ForeSystem, Matrix, Metabase system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    CubeInst: ICubeInstance;
    Dest: ICubeInstanceDestination;
    Sels: IDimSelectionSet;
    CCE: ICubeCombinedExecutor;
    Item: ICubeCombinedExecutorItem;
    M: IMatrix;
    Iter: IMatrixIterator;
    i: Integer;
Begin
    MB := MetabaseClass.Active;
    CCE := 
New CubeCombinedExecutor.Create;
    
//Open the first cube, set selection and add for parallel calculation
    CubeInst := MB.ItemById("STD_CUBE1").Open(NullAs ICubeInstance;
    Dest := CubeInst.Destinations.DefaultDestination;
    Sels := Dest.CreateDimSelectionSet;
    Sels.Item(
0).SelectAll;
    Sels.Item(
1).SelectAll;
    Sels.Item(
2).SelectAll;
    CCE.AddCube(CubeInst, Sels);
    
//Open the second cube, set selection and add for parallel calculation
    CubeInst := MB.ItemById("STD_CUBE2").Open(NullAs ICubeInstance;
    Dest := CubeInst.Destinations.DefaultDestination;
    Sels := Dest.CreateDimSelectionSet;
    Sels.Item(
0).SelectAll;
    Sels.Item(
1).SelectAll;
    Sels.Item(
2).SelectAll;
    CCE.AddCube(CubeInst, Sels);
    
//Calculate added cubes
    CCE.Execute;
    
//Display result for each cube
    For i := 0 To CCE.Count - 1 Do
        Item := CCE.Item(i);
        Debug.WriteLine(
"Cube: " + (Item.Cube.Cube As IMetabaseObject).Id + ". MultiExecuted: " + Item.MultiExecuted.ToString);
        
//Matrix with data
        M := Item.Matrix;
        
//Display matrix elements
        Iter := M.CreateIterator;
        Iter.Move(IteratorDirection.First);
        
While Iter.Valid Do
            Debug.Write(Iter.Value + 
" ");
            Iter.Move(IteratorDirection.Next);
        
End While;
        Debug.WriteLine(
"");
    
End For;
End Sub UserProc;

Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.ForeSystem;
Imports Prognoz.Platform.Interop.Matrix;
Imports Prognoz.Platform.Interop.Metabase;

Public Shared Sub Main1(Params: StartParams);
Var
    MB: IMetabase;
    CubeInst: ICubeInstance;
    Dest: ICubeInstanceDestination;
    Sels: IDimSelectionSet;
    CCE: ICubeCombinedExecutor = 
New CubeCombinedExecutorClass();
    Item: ICubeCombinedExecutorItem;
    M: IMatrix;
    Iter: IMatrixIterator;
    i: Integer;
Begin
    MB := Params.Metabase;
    
//Open the first cube, set selection and add for parallel calculation
    CubeInst := MB.ItemById["STD_CUBE1"].Open(NullAs ICubeInstance;
    Dest := CubeInst.Destinations.DefaultDestination;
    Sels := Dest.CreateDimSelectionSet();
    Sels.Item[
0].SelectAll();
    Sels.Item[
1].SelectAll();
    Sels.Item[
2].SelectAll();
    CCE.AddCube(CubeInst, Sels);
    
//Open the second cube, set selection and add for parallel calculation
    CubeInst := MB.ItemById["STD_CUBE2"].Open(NullAs ICubeInstance;
    Dest := CubeInst.Destinations.DefaultDestination;
    Sels := Dest.CreateDimSelectionSet();
    Sels.Item[
0].SelectAll();
    Sels.Item[
1].SelectAll();
    Sels.Item[
2].SelectAll();
    CCE.AddCube(CubeInst, Sels);
    
//Calculate added cubes
    CCE.Execute();
    
//Display result for each cube
    For i := 0 To CCE.Count - 1 Do
        Item := CCE.Item[i];
        System.Diagnostics.Debug.WriteLine(
"Cube: " + (Item.Cube.Cube As IMetabaseObject).Id + ". MultiExecuted: " + Item.MultiExecuted.ToString());
        
//Matrix with data
        M := Item.Matrix;
        
//Display matrix elements
        Iter := M.CreateIterator();
        Iter.Move(IteratorDirection.itdFirst);
        
While Iter.Valid Do
            System.Diagnostics.Debug.Write(Iter.Value + 
" ");
            Iter.Move(IteratorDirection.itdNext);
        
End While;
        System.Diagnostics.Debug.WriteLine(
"");
    
End For;
End Sub;

Executing the example calculates two cubes at the same time. Calculation results are displayed in the development environment console.

See also:

ICubeCombinedExecutor