Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
PartitionerQueryOperator.cs
Go to the documentation of this file.
5
7
8internal sealed class PartitionerQueryOperator<TElement> : QueryOperator<TElement>
9{
10 private sealed class PartitionerQueryOperatorResults : QueryResults<TElement>
11 {
13
15
21
23 {
28 if (orderablePartitioner != null)
29 {
31 if (orderablePartitions == null)
32 {
34 }
36 {
38 }
39 for (int i = 0; i < value; i++)
40 {
42 if (enumerator == null)
43 {
45 }
47 }
48 }
49 else
50 {
52 if (partitions == null)
53 {
55 }
56 if (partitions.Count != value)
57 {
59 }
60 for (int j = 0; j < value; j++)
61 {
63 if (enumerator2 == null)
64 {
66 }
68 }
69 }
71 }
72 }
73
74 private sealed class OrderablePartitionerEnumerator : QueryOperatorEnumerator<TElement, int>
75 {
77
82
83 internal override bool MoveNext([MaybeNullWhen(false)][AllowNull] ref TElement currentElement, ref int currentKey)
84 {
85 if (!_sourceEnumerator.MoveNext())
86 {
87 return false;
88 }
90 currentElement = current.Value;
91 currentKey = checked((int)current.Key);
92 return true;
93 }
94
95 protected override void Dispose(bool disposing)
96 {
97 _sourceEnumerator.Dispose();
98 }
99 }
100
101 private sealed class PartitionerEnumerator : QueryOperatorEnumerator<TElement, int>
102 {
104
109
110 internal override bool MoveNext([MaybeNullWhen(false)][AllowNull] ref TElement currentElement, ref int currentKey)
111 {
112 if (!_sourceEnumerator.MoveNext())
113 {
114 return false;
115 }
117 currentKey = 0;
118 return true;
119 }
120
121 protected override void Dispose(bool disposing)
122 {
123 _sourceEnumerator.Dispose();
124 }
125 }
126
128
130
132
133 internal override bool LimitsParallelism => false;
134
140
141 internal override QueryResults<TElement> Open(QuerySettings settings, bool preferStriping)
142 {
143 return new PartitionerQueryOperatorResults(_partitioner, settings);
144 }
145
147 {
148 using IEnumerator<TElement> enumerator = _partitioner.GetPartitions(1)[0];
149 while (enumerator.MoveNext())
150 {
151 yield return enumerator.Current;
152 }
153 }
154
156 {
158 {
159 return OrdinalIndexState.Shuffled;
160 }
161 if (orderablePartitioner.KeysOrderedInEachPartition)
162 {
163 if (orderablePartitioner.KeysNormalized)
164 {
165 return OrdinalIndexState.Correct;
166 }
167 return OrdinalIndexState.Increasing;
168 }
169 return OrdinalIndexState.Shuffled;
170 }
171}
IList< IEnumerator< TSource > > GetPartitions(int partitionCount)
OrderablePartitionerEnumerator(IEnumerator< KeyValuePair< long, TElement > > sourceEnumerator)
override bool MoveNext([MaybeNullWhen(false)][AllowNull] ref TElement currentElement, ref int currentKey)
readonly IEnumerator< KeyValuePair< long, TElement > > _sourceEnumerator
override bool MoveNext([MaybeNullWhen(false)][AllowNull] ref TElement currentElement, ref int currentKey)
PartitionerQueryOperatorResults(Partitioner< TElement > partitioner, QuerySettings settings)
override void GivePartitionedStream(IPartitionedStreamRecipient< TElement > recipient)
override IEnumerable< TElement > AsSequentialQuery(CancellationToken token)
static OrdinalIndexState GetOrdinalIndexState(Partitioner< TElement > partitioner)
override QueryResults< TElement > Open(QuerySettings settings, bool preferStriping)
PartitionerQueryOperator(Partitioner< TElement > partitioner)
static string PartitionerQueryOperator_NullPartitionList
Definition SR.cs:36
static string PartitionerQueryOperator_NullPartition
Definition SR.cs:40
static string PartitionerQueryOperator_WrongNumberOfPartitions
Definition SR.cs:38
Definition SR.cs:7