Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
HashJoinQueryOperatorEnumerator.cs
Go to the documentation of this file.
3
5
6internal sealed class HashJoinQueryOperatorEnumerator<TLeftInput, TLeftKey, TRightInput, TRightKey, THashKey, TOutput, TOutputKey> : QueryOperatorEnumerator<TOutput, TOutputKey>
7{
22
24
26
27 private readonly Func<TLeftInput, TRightInput, TOutput> _resultSelector;
28
30
32
34
43
44 internal override bool MoveNext([MaybeNullWhen(false)][AllowNull] ref TOutput currentElement, [AllowNull] ref TOutputKey currentKey)
45 {
46 Mutables mutables = _mutables;
47 if (mutables == null)
48 {
49 mutables = (_mutables = new Mutables());
50 mutables._rightHashLookup = _rightLookupBuilder.BuildHashLookup(_cancellationToken);
51 }
53 if (currentRightMatches != null && mutables._currentRightMatchesIndex == currentRightMatches.Count)
54 {
55 mutables._currentRightMatches = currentRightMatches.Next;
56 mutables._currentRightMatchesIndex = 0;
57 }
58 if (mutables._currentRightMatches == null)
59 {
61 TLeftKey currentKey2 = default(TLeftKey);
62 while (_leftSource.MoveNext(ref currentElement2, ref currentKey2))
63 {
64 if ((mutables._outputLoopCount++ & 0x3F) == 0)
65 {
67 }
69 TLeftInput first = currentElement2.First;
70 THashKey second = currentElement2.Second;
71 if (second != null && mutables._rightHashLookup.TryGetValue(second, ref value))
72 {
73 mutables._currentRightMatches = value.Tail;
74 mutables._currentRightMatchesIndex = 0;
75 currentElement = _resultSelector(first, value.Head.First);
76 currentKey = _outputKeyBuilder.Combine(currentKey2, value.Head.Second);
77 if (value.Tail != null)
78 {
79 mutables._currentLeft = first;
80 mutables._currentLeftKey = currentKey2;
81 }
82 return true;
83 }
84 }
85 return false;
86 }
88 currentElement = _resultSelector(mutables._currentLeft, pair.First);
89 currentKey = _outputKeyBuilder.Combine(mutables._currentLeftKey, pair.Second);
91 return true;
92 }
93
94 protected override void Dispose(bool disposing)
95 {
96 _leftSource.Dispose();
98 }
99}
bool TryGetValue(THashKey key, ref HashLookupValueList< TElement, TOrderKey > value)
HashJoinHashLookup< THashKey, TRightInput, TRightKey > _rightHashLookup
override bool MoveNext([MaybeNullWhen(false)][AllowNull] ref TOutput currentElement, [AllowNull] ref TOutputKey currentKey)
readonly Func< TLeftInput, TRightInput, TOutput > _resultSelector
readonly QueryOperatorEnumerator< Pair< TLeftInput, THashKey >, TLeftKey > _leftSource
readonly HashJoinOutputKeyBuilder< TLeftKey, TRightKey, TOutputKey > _outputKeyBuilder
readonly HashLookupBuilder< TRightInput, TRightKey, THashKey > _rightLookupBuilder
HashJoinQueryOperatorEnumerator(QueryOperatorEnumerator< Pair< TLeftInput, THashKey >, TLeftKey > leftSource, HashLookupBuilder< TRightInput, TRightKey, THashKey > rightLookupBuilder, Func< TLeftInput, TRightInput, TOutput > resultSelector, HashJoinOutputKeyBuilder< TLeftKey, TRightKey, TOutputKey > outputKeyBuilder, CancellationToken cancellationToken)
HashJoinHashLookup< THashKey, TElement, TOrderKey > BuildHashLookup(CancellationToken cancellationToken)
ListChunk< TInputOutput > Next
Definition ListChunk.cs:16