public virtual void OnInput2(Weighted <S2> entry, T time) { var k = key2(entry.record); BinaryKeyIndices state; if (!keyIndices.TryGetValue(k, out state)) { state = new BinaryKeyIndices(); } if (state.unprocessed1 == 0 && state.unprocessed2 == 0) { if (!this.KeysToProcessAtTimes.ContainsKey(time)) { this.KeysToProcessAtTimes.Add(time, new HashSet <K>()); } this.KeysToProcessAtTimes[time].Add(k); } inputTrace2.Introduce(ref state.unprocessed2, value2(entry.record), entry.weight, internTable.Intern(time)); keyIndices[k] = state; }
public JoinIntKeyed(int index, Stage <T> collection, bool input1Immutable, bool input2Immutable, Expression <Func <S1, Int32> > k1, Expression <Func <S2, Int32> > k2, Expression <Func <S1, V1> > v1, Expression <Func <S2, V2> > v2, Expression <Func <Int32, V1, V2, R> > r) : base(index, collection, input1Immutable, input2Immutable, k1, k2, v1, v2) { resultSelector = r.Compile(); // Inhibits verbose serialization of the parent's keyIndices. keyIndices = new BinaryKeyIndices[0][]; JoinKeys = new JoinIntKeyIndices[65536][]; this.parts = collection.Placement.Count; }
protected virtual void NewOutputMinusOldOutput(int index, BinaryKeyIndices keyIndex, int timeIndex) { Reduce(index, keyIndex, timeIndex); // this suggests we want to init updateToOutput with -output outputCollection.Clear(); outputTrace.EnumerateCollectionAt(keyIndex.output, timeIndex, outputCollection); for (int i = 0; i < outputCollection.Count; i++) { outputTrace.Introduce(ref outputWorkspace, outputCollection.Array[i].record, -outputCollection.Array[i].weight, timeIndex); } }
protected virtual NaiadList <int> InterestingTimes(BinaryKeyIndices keyIndex) { deltaList.Clear(); inputTrace1.EnumerateTimes(keyIndex.unprocessed1, deltaList); inputTrace2.EnumerateTimes(keyIndex.unprocessed2, deltaList); truthList.Clear(); inputTrace1.EnumerateTimes(keyIndex.processed1, truthList); inputTrace2.EnumerateTimes(keyIndex.processed2, truthList); timeList.Clear(); this.internTable.InterestingTimes(timeList, truthList, deltaList); return(timeList); }
public virtual void OnInput2(Weighted <S2> entry, T time) { var k = key2(entry.record); var index = (int)(k / this.Stage.Placement.Count); if (keyIndices[index / 65536] == null) { keyIndices[index / 65536] = new BinaryKeyIndices[65536]; } keysToProcess.Add(index); inputTrace2.Introduce(ref keyIndices[index / 65536][index % 65536].unprocessed2, value2(entry.record), entry.weight, internTable.Intern(time)); }
protected virtual void UpdateTime(int index, BinaryKeyIndices keyIndex, int timeIndex) { // subtract out prior records before adding new ones outputTrace.SubtractStrictlyPriorDifferences(ref outputWorkspace, timeIndex); NewOutputMinusOldOutput(index, keyIndex, timeIndex); var outputTime = this.internTable.times[timeIndex]; outputCollection.Clear(); outputTrace.EnumerateDifferenceAt(outputWorkspace, timeIndex, outputCollection); for (int i = 0; i < outputCollection.Count; i++) { this.Output.Send(outputCollection.Array[i], outputTime); } }
public virtual void OnInput1(Weighted <S1> entry, T time) { var k = key1(entry.record); BinaryKeyIndices state; if (!keyIndices.TryGetValue(k, out state)) { state = new BinaryKeyIndices(); } if (state.unprocessed1 == 0 && state.unprocessed2 == 0) { keysToProcess.Add(k); } inputTrace1.Introduce(ref state.unprocessed1, value1(entry.record), entry.weight, internTable.Intern(time)); keyIndices[k] = state; }
protected override void Reduce(K key, BinaryKeyIndices keyIndices, int time) { collection1.Clear(); if (keyIndices.processed1 != 0) { inputTrace1.EnumerateCollectionAt(keyIndices.processed1, time, collection1); } collection2.Clear(); if (keyIndices.processed2 != 0) { inputTrace2.EnumerateCollectionAt(keyIndices.processed2, time, collection2); } if (weightedReducer != null) { if (collection1.Count > 0 || collection2.Count > 0) { foreach (var r in weightedReducer(key, EnumerateCollection1(), EnumerateCollection2())) { outputTrace.Introduce(ref outputWorkspace, r.record, r.weight, time); } } } else { if (collection1.Count > 0 || collection2.Count > 0) { foreach (var r in reducer(key, EnumerateCollection1().SelectMany(x => Enumerable.Repeat(x.record, (int)x.weight)), EnumerateCollection2().SelectMany(x => Enumerable.Repeat(x.record, (int)x.weight)))) { outputTrace.Introduce(ref outputWorkspace, r, 1, time); } } } }
// expected to populate resultList to match reduction(collection.source) protected virtual void Reduce(int index, BinaryKeyIndices keyIndex, int time) { //var key = index * this.Stage.Placement.Count + this.VertexId; }
// expected to populate resultList to match reduction(collection.source) protected virtual void Reduce(K key, BinaryKeyIndices keyIndex, int time) { }