SetIterator(Value: IRdsElementsIterator);
Value. Iterator.
The SetIterator method sets the iterator, in which element search is executed.
The IRdsDictionaryElementsSearch.IsIterator property returns if the search is executed in iterator elements.
On getting the iterator, the search object forms a tree of elements, that is why RAM resources may be insufficient when the sample size is too large. The following error message appears: Not enough memory to complete operation.
Executing the example requires that the repository contains an MDM dictionary with the RDS_DICT identifier.
Add links to the Dimensions, Metabase, and Rds system assemblies.
Sub UserProc;
Var
Mb: IMetabase;
RdsInst: IRdsDictionaryInstance;
elSearch: IRdsDictionaryElementsSearch;
Dict: IRdsDictionary;
Filter: IRdsDictionaryFilterConditions;
Condition: IRdsDictionaryFilterCondition;
Iter: IRdsElementsIterator;
Crit: IDimTextCriteria;
Res: IRdsDictionaryElementList;
i: Integer;
Begin
Mb := MetabaseClass.Active;
// Open the dictionary, in which search will be executed
RdsInst := Mb.ItemById("RDS_DICT").Open(Null) As IRdsDictionaryInstance;
Dict := RdsInst.Dictionary;
// Create an object for dictionary search
elSearch := RdsInst.CreateSearch;
// Check whether search is performed among the elements obtained from the iterator
If Not elSearch.IsIterator Then
// Create a filter for the iterator
Filter := New RdsDictionaryFilterConditions.Create;
Condition := Filter.Add(Dict.Attributes.FindById("NAME"));
Condition.Operation := RdsConditionOperation.Like;
Condition.Value := "%1%";
// Create an iterator
Iter := RdsInst.BigElements.CreateIterator(1, RdsInst.Elements.Count, Filter, Null);
// Set the created iterator for the object that performs search
elSearch.SetIterator(Iter);
// Cast iterator to the first element
Iter.First;
// Display iterator elements in the console window
Debug.WriteLine("Iterator elements:");
While Iter.Next Do
Debug.WriteLine(Iter.Element.Name);
End While;
End If;
// Define search criteria
elSearch.Attributes.Attributes := "NAME";
Crit := New DimTextCriteria.Create;
Crit.CriteriaOptions := TextCriteriaOptions.SearchStringAttributes;
Crit.Text := "a";
elSearch.SetTextCriteria(Crit);
// Search
Res := elSearch.FindAllList;
// Show results in console window
Debug.WriteLine("Search result:");
For i := 0 To Res.Count - 1 Do
Debug.WriteLine(Res.Item(i).Name);
End For;
End Sub UserProc;
After executing the example, search is executed in MDM dictionary elements. Search options:
All elements containing character "a" in their name are searched.
Search is executed in the elements obtained from the dictionary iterator.
Elements containing character "1" are included in the iterator.
The found elements and iterator elements are displayed in the console window.
See also: