3using System.Threading.Tasks;
20 private readonly
bool[] groupByAsynchronous;
22 private readonly
bool[] iteratorUsesElement;
23 private readonly
bool[] iteratorAsynchronous;
26 private readonly
int iteratorCount;
27 private bool processLast =
false;
44 this.e = ItemEnumerator;
46 this.groupBy = GroupBy;
47 this.groupNames = GroupNames;
51 this.groupByAsynchronous =
new bool[c];
53 for (i = 0; i < c; i++)
54 this.groupByAsynchronous[i] = GroupBy[i].IsAsynchronous;
58 if (!(Columns is
null))
60 for (i = 0, c = Columns.
Length; i < c; i++)
66 this.iterators = Iterators.
ToArray();
67 this.iteratorCount = this.iterators.Length;
69 this.iteratorUsesElement =
new bool[this.iteratorCount];
70 this.iteratorAsynchronous =
new bool[this.iteratorCount];
72 for (i = 0; i < this.iteratorCount; i++)
74 this.iteratorUsesElement[i] = this.iterators[i].UsesElement;
75 this.iteratorAsynchronous[i] = this.iterators[i].IsAsynchronous;
110 object[] Last =
null;
111 int i, j, c = this.groupBy.Length;
115 while (this.processLast || await this.e.MoveNextAsync())
117 this.processLast =
false;
119 if (this.objectVariables is
null)
120 this.objectVariables =
new ObjectProperties(this.e.Current,
this.variables);
122 this.objectVariables.Object = this.e.Current;
126 Last =
new object[c];
128 for (i = 0; i < c; i++)
130 if (this.groupByAsynchronous[i])
131 E = await this.groupBy[i].EvaluateAsync(this.objectVariables);
133 E = this.groupBy[i].Evaluate(this.objectVariables);
138 if (this.iteratorCount > 0)
140 for (j = 0; j < this.iteratorCount; j++)
141 this.iterators[j].RestartEvaluator();
146 for (i = 0; i < c; i++)
148 if (this.groupByAsynchronous[i])
149 E = await this.groupBy[i].EvaluateAsync(this.objectVariables);
151 E = this.groupBy[i].Evaluate(this.objectVariables);
156 if (o1 is
null ^ o2 is
null)
159 if (!(o1 is
null) && !o1.Equals(o2))
165 this.processLast =
true;
170 if (this.iteratorCount > 0)
172 for (j = 0; j < this.iteratorCount; j++)
174 Iterator = this.iterators[j];
176 if (this.iteratorUsesElement[j])
178 if (this.iteratorAsynchronous[j])
181 E = Iterator.
Evaluate(this.objectVariables);
198 for (i = 0; i < this.iteratorCount; i++)
200 Iterator = this.iterators[i];
205 this.current =
new GroupObject(Last, Aggregates, this.groupNames, this.variables);
216 this.processLast =
false;
A chunked list is a linked list of chunks of objects of type T .
T[] ToArray()
Returns an array containing all elements of the collection.
Base class for all nodes in a parsed script tree.
int Length
Length of expression covered by node.
static readonly ObjectValue Null
Null value.
Enumerator that groups items into groups, and returns aggregated elements.
void Reset()
IEnumerator.Reset
void Dispose()
IDisposable.Dispose"/>
bool MoveNext()
IEnumerator.MoveNext
async Task< bool > MoveNextAsync()
Advances the enumerator to the next element of the collection.
GroupEnumerator(IResultSetEnumerator ItemEnumerator, Variables Variables, ScriptNode[] GroupBy, ScriptNode[] GroupNames, ScriptNode[] Columns, ref ScriptNode Having)
Enumerator that groups items into groups, and returns aggregated elements.
object Current
IEnumerator.Current
Represents a collection of objects grouped together useing a GROUP BY construct.
Processor that groups items into groups, and processes aggregated elements.
Basic interface for all types of elements.
object AssociatedObjectValue
Associated object value.
An interative evaluator of a function supporting the IIterativeEvaluation interface.
IElement GetAggregatedResult()
Gets the aggregated result.
Task< IElement > EvaluateAsync(Variables Variables)
Evaluates the evaluator, using the variables provided in the Variables collection and an object inst...
IElement Evaluate(Variables Variables)
Evaluates the evaluator, using the variables provided in the Variables collection and an object inst...
void AggregateElement(IElement Element)
Aggregates one new element.
void RestartEvaluator()
Restarts the evaluator.
Interface for result-set enumerators.