Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UnionQueryOperator.cs
Go to the documentation of this file.
4
6
7internal sealed class UnionQueryOperator<TInputOutput> : BinaryQueryOperator<TInputOutput, TInputOutput, TInputOutput>
8{
9 private sealed class UnionQueryOperatorEnumerator<TLeftKey, TRightKey> : QueryOperatorEnumerator<TInputOutput, int>
10 {
12
14
16
18
20
22
30
31 internal override bool MoveNext([MaybeNullWhen(false)][AllowNull] ref TInputOutput currentElement, ref int currentKey)
32 {
33 if (_hashLookup == null)
34 {
37 }
38 if (_leftSource != null)
39 {
40 TLeftKey currentKey2 = default(TLeftKey);
42 int num = 0;
44 {
45 if ((num++ & 0x3F) == 0)
46 {
48 }
50 {
52 return true;
53 }
54 }
55 _leftSource.Dispose();
56 _leftSource = null;
57 }
58 if (_rightSource != null)
59 {
63 {
64 if ((_outputLoopCount.Value++ & 0x3F) == 0)
65 {
67 }
69 {
71 return true;
72 }
73 }
74 _rightSource.Dispose();
75 _rightSource = null;
76 }
77 return false;
78 }
79
80 protected override void Dispose(bool disposing)
81 {
82 if (_leftSource != null)
83 {
84 _leftSource.Dispose();
85 }
86 if (_rightSource != null)
87 {
88 _rightSource.Dispose();
89 }
90 }
91 }
92
93 private sealed class OrderedUnionQueryOperatorEnumerator<TLeftKey, TRightKey> : QueryOperatorEnumerator<TInputOutput, ConcatKey<TLeftKey, TRightKey>>
94 {
96
98
100
102
103 private readonly bool _leftOrdered;
104
105 private readonly bool _rightOrdered;
106
108
110
125
127 {
128 if (_outputEnumerator == null)
129 {
133 TLeftKey currentKey2 = default(TLeftKey);
134 int num = 0;
136 {
137 if ((num++ & 0x3F) == 0)
138 {
140 }
143 if (!dictionary.TryGetValue(key, out var value) || _keyComparer.Compare(concatKey, value.Second) < 0)
144 {
146 }
147 }
150 {
151 if ((num++ & 0x3F) == 0)
152 {
154 }
157 if (!dictionary.TryGetValue(key2, out var value2) || _keyComparer.Compare(concatKey2, value2.Second) < 0)
158 {
160 }
161 }
163 }
164 if (_outputEnumerator.MoveNext())
165 {
167 currentElement = value3.First;
168 currentKey = value3.Second;
169 return true;
170 }
171 return false;
172 }
173
174 protected override void Dispose(bool disposing)
175 {
176 _leftSource.Dispose();
177 _rightSource.Dispose();
178 }
179 }
180
182
183 internal override bool LimitsParallelism => false;
184
186 : base(left, right)
187 {
189 _outputOrdered = base.LeftChild.OutputOrdered || base.RightChild.OutputOrdered;
190 }
191
193 {
194 QueryResults<TInputOutput> leftChildQueryResults = base.LeftChild.Open(settings, preferStriping: false);
195 QueryResults<TInputOutput> rightChildQueryResults = base.RightChild.Open(settings, preferStriping: false);
197 }
198
213
227
229 {
230 if (base.LeftChild.OutputOrdered || base.RightChild.OutputOrdered)
231 {
234 for (int i = 0; i < partitionCount; i++)
235 {
236 partitionedStream[i] = new OrderedUnionQueryOperatorEnumerator<TLeftKey, TRightKey>(leftHashStream[i], rightHashStream[i], base.LeftChild.OutputOrdered, base.RightChild.OutputOrdered, _comparer, keyComparer, cancellationToken);
237 }
239 }
240 else
241 {
243 for (int j = 0; j < partitionCount; j++)
244 {
246 }
248 }
249 }
250
252 {
253 IEnumerable<TInputOutput> first = CancellableEnumerable.Wrap(base.LeftChild.AsSequentialQuery(token), token);
254 IEnumerable<TInputOutput> second = CancellableEnumerable.Wrap(base.RightChild.AsSequentialQuery(token), token);
255 return first.Union(second, _comparer);
256 }
257}
void ICollection< T >. Add(T item)
Definition HashSet.cs:225
readonly QueryOperatorEnumerator< Pair< TInputOutput, NoKeyMemoizationRequired >, TLeftKey > _leftSource
override bool MoveNext([MaybeNullWhen(false)][AllowNull] ref TInputOutput currentElement, ref ConcatKey< TLeftKey, TRightKey > currentKey)
OrderedUnionQueryOperatorEnumerator(QueryOperatorEnumerator< Pair< TInputOutput, NoKeyMemoizationRequired >, TLeftKey > leftSource, QueryOperatorEnumerator< Pair< TInputOutput, NoKeyMemoizationRequired >, TRightKey > rightSource, bool leftOrdered, bool rightOrdered, IEqualityComparer< TInputOutput > comparer, IComparer< ConcatKey< TLeftKey, TRightKey > > keyComparer, CancellationToken cancellationToken)
readonly QueryOperatorEnumerator< Pair< TInputOutput, NoKeyMemoizationRequired >, TRightKey > _rightSource
IEnumerator< KeyValuePair< Wrapper< TInputOutput >, Pair< TInputOutput, ConcatKey< TLeftKey, TRightKey > > > > _outputEnumerator
readonly IComparer< ConcatKey< TLeftKey, TRightKey > > _keyComparer
override bool MoveNext([MaybeNullWhen(false)][AllowNull] ref TInputOutput currentElement, ref int currentKey)
QueryOperatorEnumerator< Pair< TInputOutput, NoKeyMemoizationRequired >, TRightKey > _rightSource
UnionQueryOperatorEnumerator(QueryOperatorEnumerator< Pair< TInputOutput, NoKeyMemoizationRequired >, TLeftKey > leftSource, QueryOperatorEnumerator< Pair< TInputOutput, NoKeyMemoizationRequired >, TRightKey > rightSource, IEqualityComparer< TInputOutput > comparer, CancellationToken cancellationToken)
QueryOperatorEnumerator< Pair< TInputOutput, NoKeyMemoizationRequired >, TLeftKey > _leftSource
readonly IEqualityComparer< TInputOutput > _comparer
UnionQueryOperator(ParallelQuery< TInputOutput > left, ParallelQuery< TInputOutput > right, IEqualityComparer< TInputOutput > comparer)
override void WrapPartitionedStream< TLeftKey, TRightKey >(PartitionedStream< TInputOutput, TLeftKey > leftStream, PartitionedStream< TInputOutput, TRightKey > rightStream, IPartitionedStreamRecipient< TInputOutput > outputRecipient, bool preferStriping, QuerySettings settings)
void WrapPartitionedStreamFixedLeftType< TLeftKey, TRightKey >(PartitionedStream< Pair< TInputOutput, NoKeyMemoizationRequired >, TLeftKey > leftHashStream, PartitionedStream< TInputOutput, TRightKey > rightStream, IPartitionedStreamRecipient< TInputOutput > outputRecipient, int partitionCount, CancellationToken cancellationToken)
void WrapPartitionedStreamFixedBothTypes< TLeftKey, TRightKey >(PartitionedStream< Pair< TInputOutput, NoKeyMemoizationRequired >, TLeftKey > leftHashStream, PartitionedStream< Pair< TInputOutput, NoKeyMemoizationRequired >, TRightKey > rightHashStream, IPartitionedStreamRecipient< TInputOutput > outputRecipient, int partitionCount, CancellationToken cancellationToken)
override IEnumerable< TInputOutput > AsSequentialQuery(CancellationToken token)
override QueryResults< TInputOutput > Open(QuerySettings settings, bool preferStriping)