CalculateRelativeDifference only calculates change based on new upload#77
CalculateRelativeDifference only calculates change based on new upload#77Arjun-Parmani wants to merge 1 commit intoHyperfoil:mainfrom
Conversation
4ea184c to
697ca7e
Compare
stalep
left a comment
There was a problem hiding this comment.
Good work on the tests — they clearly demonstrate the expected behavior for both the recalculation and minPrevious scenarios.
A few things to consider:
Domain ordering in the range query
Setting domainNode and domainValue to null in the second findMatchingFingerprint call (line 417-418) removes the domain-based ordering for range values. The sliding window comparison (window + minPrevious values split into "previous" and "recent") depends on values being ordered by domain — without it, you might get values in an arbitrary order, and the window wouldn't represent the correct time-series segment.
Take a look at what findMatchingFingerprint does with domainNode and domainValue in ValueService — the domain node controls the ORDER BY, and the domain value controls the "preceding this point" cutoff. You want to keep that ordering but scope which domain points you iterate over.
Hint: The commented-out code block above your change (lines 388-414) was an earlier attempt at exactly this approach — it gets domain values scoped to the root, then for each one fetches range values with domain ordering preserved. That's the right structure. The reason it was commented out was the TODO about not handling values after previous detections, which is explicitly out of scope for this issue.
Test assertions
The value count assertions (Count: 11, Count: 17) verify the total number of values in the folder, which indirectly confirms change detection happened. A more direct assertion would check the actual change detection values — for example, verify the detection value contains the expected domain point or ratio. This would catch cases where the right number of values exist but the wrong changes were detected.
|
On Domain ordering in the range query Initially the comparison was done based on domain-value (v.data≤domainValue) to fetch previous range values. Because data is uploaded out of sequence (non-sequentially), this approach created a "visibility" bug: Upload x=3: The query finds no previous data. It assigns y=1.1. No change is detected due to insufficient data. Upload x=2: The query searches for v.data<=2. Since x=3 is the only record in the DB, the query returns null. The system assigns y=2.1 but fails to detect a change because it cannot "see" the x=3 record (since 3>2). Upload x=1: The query searches for v.data<=1. Again, it returns null, failing to detect a change against x=2 or x=3. The bug occurred because the v.data <= domain filter assumes that "previous" data always has a smaller domain value, which is false when uploads are unordered. Then When I passed null for both domain node and domain value, it checks if(domain value !=null || domain node!null) |
|
Good catch — you're right that the The fallback to One thing worth adding: a test that explicitly validates the out-of-order upload scenario you described. Your current tests upload in descending domain order (x=3, x=2, x=1) which does exercise this path, but a test that uploads in a scrambled order (e.g., x=2, x=4, x=1, x=3) and verifies the correct changes are detected would document this behavior more explicitly and protect against future regressions. |
…ire folder Domain values scanned based on current upload root id and not the entire folder Added test cases to verify the proper values are being produced at each iteration for ordered and unordered sequence of upload Rectified the typo. Assigned the proper variable now in the code for ratio3
b480924 to
1d1c6e9
Compare
|
I think this looks good, @willr3 any objections? |
The new implementation of NodeService.calculateRelativeDifferenceValues calculates the domain values based on the new upload (root id) for matching fingerprint values.