3using System.Threading.Tasks;
41 KeyValuePair<VariableReference, bool>[] Order,
ScriptNode Node)
44 KeyValuePair<VariableReference, bool>[] LeftOrder = await
Reduce(this.
Left, Order);
51 this.Combine(RightWhere,
this.Conditions),
Variables,
false);
54 KeyValuePair<VariableReference, bool>[] RightOrder2 = await
Reduce(this.
Right, Order);
61 this.Combine(LeftWhere2,
this.Conditions),
Variables,
true);
71 if (Top !=
int.MaxValue)
79 private readonly Dictionary<object, bool> reportedLeft =
new Dictionary<object, bool>();
82 private object current;
83 private bool leftMode;
88 this.rightEnum =
Right;
93 public object Current => this.current;
97 this.leftEnum.Dispose();
98 this.rightEnum.Dispose();
101 public bool MoveNext()
103 return this.MoveNextAsync().Result;
106 public async Task<bool> MoveNextAsync()
110 if (await this.leftEnum.MoveNextAsync())
112 this.current = this.leftEnum.Current;
113 this.reportedLeft[this.current] =
true;
117 this.leftMode =
false;
122 if (await this.rightEnum.MoveNextAsync())
123 this.current = this.rightEnum.Current;
127 while (this.reportedLeft.ContainsKey(
this.current));
134 this.reportedLeft.Clear();
136 this.leftMode =
true;
137 this.leftEnum.Reset();
138 this.rightEnum.Reset();
160 KeyValuePair<VariableReference, bool>[] LeftOrder = await
Reduce(this.
Left, Order);
165 if (Top !=
int.MaxValue)
171 if (!(Where is
null))
174 FullOuterJoinProcessor OuterProcessor =
new FullOuterJoinProcessor(Processor);
176 LeftOuterJoinedSource.OuterJoinLeftProcessor LeftProcessor =
178 this.Right,
this.Right.Name, Generic, RightWhere,
Variables,
false);
180 if (!await this.
Left.
Process(LeftProcessor, 0,
int.MaxValue, Generic,
187 KeyValuePair<VariableReference, bool>[] RightOrder = await
Reduce(this.
Right, Order);
192 LeftOuterJoinedSource.OuterJoinLeftProcessor RightProcessor =
194 this.Left,
this.Left.Name, Generic, LeftWhere,
Variables,
true);
196 OuterProcessor.LeftMode =
false;
198 if (!await this.
Right.
Process(RightProcessor, 0,
int.MaxValue, Generic,
199 RightWhere,
Variables, RightOrder, Node))
207 private class FullOuterJoinProcessor :
IProcessor<object>
209 private readonly Dictionary<object, bool> reportedLeft =
new Dictionary<object, bool>();
214 this.processor = Processor;
217 public bool LeftMode {
get;
set; } =
true;
219 public bool Flush() => this.processor.Flush();
220 public Task<bool> FlushAsync() => this.processor.FlushAsync();
222 public bool Process(
object Object)
226 this.reportedLeft[Object] =
true;
227 return this.processor.Process(Object);
231 if (!this.reportedLeft.ContainsKey(Object))
232 return this.processor.Process(Object);
238 public async Task<bool> ProcessAsync(
object Object)
242 this.reportedLeft[Object] =
true;
243 return await this.processor.ProcessAsync(Object);
247 if (!this.reportedLeft.ContainsKey(Object))
248 return await this.processor.ProcessAsync(Object);
Base class for all nodes in a parsed script tree.
Enumerator that only returns elements matching a set of conditions.
Enumerator that limits the return set to a maximum number of records.
Enumerator that skips a given number of result records.
Processor that only processes elements matching a set of conditions.
Processor that limits the return set to a maximum number of records.
Processor that skips a given number of result records.
Data source formed through an (FULL [OUTER]|OUTER) JOIN of two sources.
override async Task< bool > Process(IProcessor< object > Processor, int Offset, int Top, bool Generic, ScriptNode Where, Variables Variables, KeyValuePair< VariableReference, bool >[] Order, ScriptNode Node)
Processes objects matching filter conditions in Where .
override async Task< IResultSetEnumerator > Find(int Offset, int Top, bool Generic, ScriptNode Where, Variables Variables, KeyValuePair< VariableReference, bool >[] Order, ScriptNode Node)
Finds objects matching filter conditions in Where .
FullOuterJoinedSource(IDataSource Left, IDataSource Right, ScriptNode Conditions)
Data source formed through an (FULL [OUTER]|OUTER) JOIN of two sources.
Abstract base classes of joined sources.
ScriptNode Conditions
Conditions for join.
ScriptNode Combine(ScriptNode Where, ScriptNode On)
Combines one or two restrictions.
IDataSource Left
Left source
static async Task< ScriptNode > Reduce(IDataSource Source, ScriptNode Where)
Reduces a where clause to fit the current data source.
IDataSource Right
Right source
Data source formed through an LEFT [OUTER] JOIN of two sources.
Interface for processors of objects.
bool IsAsynchronous
If the processor operates asynchronously.
Interface for result-set enumerators.
Interface for data sources that can be used in SQL statements.
Task< bool > Process(IProcessor< object > Processor, int Offset, int Top, bool Generic, ScriptNode Where, Variables Variables, KeyValuePair< VariableReference, bool >[] Order, ScriptNode Node)
Processes objects matching filter conditions in Where .
Task< IResultSetEnumerator > Find(int Offset, int Top, bool Generic, ScriptNode Where, Variables Variables, KeyValuePair< VariableReference, bool >[] Order, ScriptNode Node)
Finds objects matching filter conditions in Where .
string Name
Collection name or alias.