IRubricatorFactorExecutor.UseDeduplication

Fore Syntax

UseDeduplication: Boolean;

Fore.NET Syntax

UseDeduplication: boolean;

Description

The UseDeduplication property determines whether time series database supports deduplication.

Comments

Deduplication is executed on creating a matrix and is supported for rows and numeric values.

After deduplication, only different rows are stored in the matrix. Several matrix nodes can refer to one row. This reduces the size of the created matrix.

Available values:

Fore Example

Executing the example requires that the repository contains a time series database with the TSDB identifier containing an attribute series with the CITY identifier.

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

Sub UserProc;
Var
    MB: IMetabase;
    RubDesc: IMetabaseObjectDescriptor;
    RubrIn: IRubricatorInstance;
    Cub: ICubeInstance;
    Dest: ICubeInstanceDestination;
    FactorExec: IRubricatorFactorExecutor;
    FactsLookup: IRubricatorFactsLookup;
    MetaDLookup: IMetaDictionaryLookup;
    Key: Array Of Integer;
    i: Integer;
    Cond: IOrmCondition;
    Exec: ICubeInstanceDestinationExecutor;
    Mat: IMatrix;
    Ite: IMatrixIterator;
    SelSet: IDImSelectionSet;
Begin
    // Get current repository
    MB := MetabaseClass.Active;
    // Get time series database
    RubDesc := MB.ItemById("TSDB");
    // Open time series database
    RubrIn := RubDesc.Open(NullAs IRubricatorInstance;
    // Get default display version of time series database
    Cub := RubrIn As ICubeInstance;
    Dest := Cub.Destinations.DefaultDestination;
    // Create an object to extract data
    Exec := Dest.CreateExecutor;
    FactorExec := Exec As IRubricatorFactorExecutor;
    // Determine that deduplication is used
    FactorExec.UseDeduplication := True;
    // Set data selection parameters
    FactsLookup := RubrIn.CreateFactsLookup;
    MetaDLookup := FactsLookup.Lookup;
    // Value of the CITY attribute must be equal to 750
    Cond := MetaDLookup.Where.Add;
    Cond.AttributeName := "CITY";
    Cond.Value := 750;
    // Create an array for series keys that correspond to selection conditions
    i := FactsLookup.LookupFactors.Length;
    Key := New Integer[i];
    // Get array of series keys that correspond to selection conditions
    Key := FactsLookup.LookupFactors;
    // Specify that data must be obtained only from series with these keys
    FactorExec.SetFactorKeys(Key);
    // Specify that get values by the VL attribute,
    // that is, get series values
    FactorExec.ValueKind := MetaAttributeKind.Value;
    FactorExec.ValueId := "VL";
    // Specify that values must be obtained on the date of the last revision
    FactorExec.WhereRevisionBetween(-1, -1);
    // Get data
    Exec := FactorExec.AsCubeExecutor;
    Exec.PrepareExecute(Null);
    Exec.PerformExecute;
    // Get matrix with data
    Mat := Exec.Matrix;
    // Display element value before change
    Ite := Mat.CreateIterator;
    Ite.Move(IteratorDirection.Last);
    Debug.Write("Element value before change: ");
    Debug.WriteLine(Ite.Value);
    // Set selection, by which will change value
    SelSet := Dest.CreateDimSelectionSet;
    For i := 0 To SelSet.Count - 1 Do
        SelSet.Item(i).SelectElement(0False);
    End For;
    // Change element value
    Mat.SetValueBySelection(SelSet, 0.547);
    // Display element value after change
    Ite.Move(IteratorDirection.Last);
    Debug.Write("Element value after change: ");
    Debug.WriteLine(Ite.Value);
End Sub UserProc;

After executing the example a matrix is obtained by the following condition: value of the CITY attribute is equal to 750. Deduplication is used when data is obtained. Then the element value is changed. The console window displays value of this element before and after change.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.ForeSystem;
Imports Prognoz.Platform.Interop.Matrix;
Imports Prognoz.Platform.Interop.Orm;
Imports Prognoz.Platform.Interop.Rds;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    RubDesc: IMetabaseObjectDescriptor;
    RubrIn: IRubricatorInstance;
    Cub: ICubeInstance;
    Dest: ICubeInstanceDestination;
    FactorExec: IRubricatorFactorExecutor;
    FactsLookup: IRubricatorFactsLookup;
    MetaDLookup: IMetaDictionaryLookup;
    Key: System.Array;
    i: Integer;
    Cond: IOrmCondition;
    Exec: ICubeInstanceDestinationExecutor;
    Mat: IMatrix;
    Ite: IMatrixIterator;
    SelSet: IDImSelectionSet;
Begin
    // Get current repository
    MB := Params.Metabase;
    // Get time series database
    RubDesc := MB.ItemById["TSDB"];
    // Open time series database
    RubrIn := RubDesc.Open(NullAs IRubricatorInstance;
    // Get default display version of time series database
    Cub := RubrIn As ICubeInstance;
    Dest := Cub.Destinations.DefaultDestination;
    // Create an object to extract data
    Exec := Dest.CreateExecutor();
    FactorExec := Exec As IRubricatorFactorExecutor;
    // Determine that deduplication is used
    FactorExec.UseDeduplication := True;
    // Set data selection parameters
    FactsLookup := RubrIn.CreateFactsLookup();
    MetaDLookup := FactsLookup.Lookup;
    // Value of the CITY attribute must be equal to 750
    Cond := MetaDLookup.Where.Add();
    Cond.AttributeName := "CITY";
    Cond.Value := 750;
    // Create an array for series keys that correspond to selection conditions
    i := FactsLookup.LookupFactors().Length;
    Key := New Integer[i];
    // Get array of series keys that correspond to selection conditions
    Key := FactsLookup.LookupFactors();
    // Specify that data must be obtained only from series with these keys
    FactorExec.SetFactorKeys(Key);
    // Specify that get values by the VL attribute,
    // that is, get series values
    FactorExec.ValueKind := MetaAttributeKind.meakValue;
    FactorExec.ValueId := "VL";
    // Specify that values must be obtained on the date of the last revision
    FactorExec.WhereRevisionBetween(uinteger.MaxValue, uinteger.MaxValue);
    // Get data
    Exec := FactorExec.AsCubeExecutor();
    Exec.PrepareExecute(Null);
    Exec.PerformExecute(False);
    // Get matrix with data
    Mat := Exec.Matrix;
    // Display element value before change
    Ite := Mat.CreateIterator();
    Ite.Move(IteratorDirection.itdLast);
    System.Diagnostics.Debug.Write("Element value before change: ");
    System.Diagnostics.Debug.WriteLine(Ite.Value);
    // Set selection, by which will change value
    SelSet := Dest.CreateDimSelectionSet();
    For i := 0 To SelSet.Count - 1 Do
        SelSet.Item[i].SelectElement(0False);
    End For;
    // Change element value
    Mat.SetValueBySelection(SelSet, 0.547);
    // Display element value after change
    Ite.Move(IteratorDirection.itdLast);
    System.Diagnostics.Debug.Write("Element value after change: ");
    System.Diagnostics.Debug.WriteLine(Ite.Value);
End Sub;

See also:

IRubricatorFactorExecutor