| 22 | |
| 23 | namespace MIDAS { |
| 24 | struct NormalCore { |
| 25 | int timestamp = 1; |
| 26 | int* const index; // Pre-compute the index to-be-modified, thanks to the same structure of CMSs |
| 27 | CountMinSketch numCurrent, numTotal; |
| 28 | |
| 29 | NormalCore(int numRow, int numColumn): |
| 30 | index(new int[numRow]), |
| 31 | numCurrent(numRow, numColumn), |
| 32 | numTotal(numCurrent) { } |
| 33 | |
| 34 | virtual ~NormalCore() { |
| 35 | delete[] index; |
| 36 | } |
| 37 | |
| 38 | static float ComputeScore(float a, float s, float t) { |
| 39 | return s == 0 || t - 1 == 0 ? 0 : pow((a - s / t) * t, 2) / (s * (t - 1)); |
| 40 | } |
| 41 | |
| 42 | float operator()(int source, int destination, int timestamp) { |
| 43 | if (this->timestamp < timestamp) { |
| 44 | numCurrent.ClearAll(); |
| 45 | this->timestamp = timestamp; |
| 46 | } |
| 47 | numCurrent.Hash(index, source, destination); |
| 48 | numCurrent.Add(index); |
| 49 | numTotal.Add(index); |
| 50 | return ComputeScore(numCurrent(index), numTotal(index), timestamp); |
| 51 | } |
| 52 | }; |
| 53 | } |
nothing calls this directly
no outgoing calls
no test coverage detected