GetKeysRaw(Attributes: Array;
Dimensions: Array;
Result: IMatrixModel;
Options: Integer;
Attribute: String);
Attributes. Array of series attributes' names.
Dimensions. Array of series dimensions corresponding to attributes.
Result. The matrix, to which search results are loaded.
Options. Indicates whether aggregate function is used in search.
Attribute. Name of the attribute, which values are put into the Result matrix.
The GetKeysRaw method returns time series database elements by defined dimensions.
The Attributes array must contain string values, and Dimensions must contain values of the Variant type. The names order in the Attributes array must correspond to the dimensions order in the Dimensions array, that is, the first element of the Attributes array sets the attribute's name, and the first element of the Dimensions array sets the dimension of this attribute, and so on.
The number of dimensions in the Result resulting matrix must match with the number of dimensions in the time series database, in which the search is executed.
To apply aggregate functions to the values of the Attribute attribute, use the Options and Attribute parameters. Acceptable values of the Options parameter:
0. The aggregate function MIN or MAX is applied to the values of the attribute. Set function text in the Attribute parameter as follows: <function><attribute_name>. For example: GetKeysRaw(Atts, Dims, mModel, 0, "MAX(DL)");
1. Aggregate functions are not applied. For example: GetKeysRaw(Atts, Dims, mModel, 1, "MNEMO").
Executing the example requires that the repository must contain a time series database with the TSDB identifier, which contains mandatory attributes of time series with the COUNTRY and INDICATOR identifiers. These attributes are links to the dictionary.
Add links to the Metabase, Cube, Rds, Matrix, Orm and Dimensions system assemblies.
Sub UserProc;
Var
MB: IMetabase;
RubDesc: IMetabaseObjectDescriptor;
RubrIn: IRubricatorInstance;
DictInst: IMetaDictionaryInstance;
MetaDLookup: IMetaDictionaryLookup;
DictAtts: IMetaAttributes;
Dims: Array[2] Of Variant;
Atts: Array[2] Of String;
Conditions: IOrmConditions;
Cond: IOrmCondition;
mf: MatrixFactory;
mModel: IMatrixModel;
Iter: IMatrixModelIterator;
i: Integer;
Begin
MB := MetabaseClass.Active;
// Get time series database
RubDesc := MB.ItemById("TSDB");
RubrIn := RubDesc.Open(Null) As IRubricatorInstance;
// Get time series dictionary
DictInst := RubrIn.Facts;
// Create object used to search in time series dictionary
MetaDLookup := DictInst.CreateLookup("");
// Define dimensions by which the search is done
DictAtts := DictInst.Dictionary.Attributes;
Dims[0] := DictAtts.FindById("COUNTRY").ValuesObject.Open(Null) As IDimInstance;
Dims[1] := DictAtts.FindById("INDICATOR").ValuesObject.Open(Null) As IDimInstance;
// Set time series attributes corresponding to dimensions
Atts[0] := "COUNTRY";
Atts[1] := "INDICATOR";
// Define search criteria
Conditions := MetaDLookup.CustomWhere;
Cond := Conditions.Add;
Cond.AttributeName := "COUNTRY";
Cond.Value := 512;
// Create matrix to which results are loaded
mf := New MatrixFactory.Create;
mModel := mf.CreateMatrixModel(2);
// Search
MetaDLookup.GetKeysRaw(Atts, Dims, mModel, 1, "MNEMO");
// Show results in console window
Iter := mModel.CreateModelIterator;
Iter.Move(IteratorDirection.First);
i := 0;
While Iter.Valid Do
Debug.WriteLine(Iter.Value + " ");
Iter.Move(IteratorDirection.Next);
End While;
End Sub UserProc;
After executing the example time series are searched by the dimensions of the COUNTRY and INDICATOR attributes. Search criterion: value of the COUNTRY attribute for the time series is 512. Search results are displayed in the console window.
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.Matrix;
Imports Prognoz.Platform.Interop.Orm;
Imports Prognoz.Platform.Interop.Rds;
Imports Prognoz.Platform.Interop.ForeSystem;
Imports Prognoz.Platform.Interop.Dimensions;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
RubDesc: IMetabaseObjectDescriptor;
RubrIn: IRubricatorInstance;
DictInst: IMetaDictionaryInstance;
MetaDLookup: IMetaDictionaryLookup;
DictAtts: IMetaAttributes;
Dims: Array[2] Of object;
Atts: Array[2] Of String;
Conditions: IOrmConditions;
Cond: IOrmCondition;
mf: MatrixFactory;
mModel: IMatrixModel;
Iter: IMatrixModelIterator;
i: Integer;
Begin
MB := Params.Metabase;
// Get time series database
RubDesc := MB.ItemById["TSDB"];
RubrIn := RubDesc.Open(Null) As IRubricatorInstance;
// Get time series dictionary
DictInst := RubrIn.Facts;
// Create object used to search in time series dictionary
MetaDLookup := DictInst.CreateLookup("");
// Define dimensions by which the search is done
DictAtts := DictInst.Dictionary.Attributes;
Dims[0] := DictAtts.FindById("COUNTRY").ValuesObject.Open(Null) As IDimInstance;
Dims[1] := DictAtts.FindById("INDICATOR").ValuesObject.Open(Null) As IDimInstance;
// Set time series attributes corresponding to dimensions
Atts[0] := "COUNTRY";
Atts[1] := "INDICATOR";
// Define search criteria
Conditions := MetaDLookup.CustomWhere;
Cond := Conditions.Add();
Cond.AttributeName := "COUNTRY";
Cond.Value := 512;
// Create matrix to which results are loaded
mf := New MatrixFactory.Create();
mModel := mf.CreateMatrixModel(2);
// Search
MetaDLookup.GetKeysRaw(Atts, Dims, mModel, 1, "MNEMO");
// Show results in console window
Iter := mModel.CreateModelIterator();
Iter.Move(IteratorDirection.itdFirst);
i := 0;
While Iter.Valid Do
System.Diagnostics.Debug.WriteLine(Iter.Value + " ");
Iter.Move(IteratorDirection.itdNext);
End While;
End Sub;
See also: