Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1.2.17 - Full recalc bugfixes & FIRST/LAST quality of life updates #96

Merged
merged 30 commits into from
May 11, 2021

Conversation

jamessimone
Copy link
Owner

  • Fixes WhereFieldEvaluator too permissive on updates #95 by fixing restrictiveness level for RollupEvaluator, which helps full recalc rollups kick off correctly
  • Updated FIRST/LAST order by field to be optional, and default to Rollup Field On Calc Item (like DLRS). When I originally built this feature out, I hadn't architected things to make the default value easy, but things are better now

@codecov
Copy link

codecov bot commented May 6, 2021

Codecov Report

Merging #96 (d3db359) into main (e0bc123) will decrease coverage by 0.23%.
The diff coverage is 97.31%.

❗ Current head d3db359 differs from pull request most recent head 6ed11e2. Consider uploading reports for the commit 6ed11e2 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main      #96      +/-   ##
==========================================
- Coverage   96.86%   96.63%   -0.24%     
==========================================
  Files           9        9              
  Lines        2742     2821      +79     
==========================================
+ Hits         2656     2726      +70     
- Misses         86       95       +9     
Impacted Files Coverage Δ
rollup/core/classes/RollupEvaluator.cls 96.26% <88.46%> (-0.73%) ⬇️
rollup/core/classes/RollupCalculator.cls 98.79% <98.14%> (-0.71%) ⬇️
rollup/core/classes/Rollup.cls 95.98% <98.40%> (+0.11%) ⬆️
...ollup/core/classes/RollupFullBatchRecalculator.cls 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e0bc123...6ed11e2. Read the comment docs.

… adding this manually and including branch in package version tagging process from now on
@jamessimone jamessimone temporarily deployed to Test May 7, 2021 03:01 Inactive
@jamessimone jamessimone temporarily deployed to Test May 7, 2021 15:43 Inactive
@jamessimone jamessimone temporarily deployed to Test May 7, 2021 15:52 Inactive
@jamessimone jamessimone temporarily deployed to Test May 7, 2021 17:53 Inactive
@jamessimone jamessimone temporarily deployed to Test May 7, 2021 18:03 Inactive
@jamessimone jamessimone temporarily deployed to Test May 9, 2021 01:25 Inactive
…pended to the package version name prevented the new package version from being found
@jamessimone jamessimone temporarily deployed to Test May 9, 2021 01:32 Inactive
@jamessimone jamessimone temporarily deployed to Test May 9, 2021 01:58 Inactive
@jamessimone jamessimone temporarily deployed to Test May 10, 2021 00:14 Inactive
jamessimone and others added 3 commits May 10, 2021 00:18
* First take on addendum for v1.2.17, patching holes in current RollupCalculator functionality for full recalculation routes that weren't already covered (so, everything besides average/first/last)

* Added baseBaseCalculation method in RollupCalculator to deal with the possibility of rollups where the evaluator filters out all calc items necessitating a full recalc - which would not have happened for String and Number-based rollups previously
@jamessimone jamessimone temporarily deployed to Test May 11, 2021 02:14 Inactive
@jamessimone jamessimone temporarily deployed to Test May 11, 2021 02:18 Inactive
@jamessimone jamessimone temporarily deployed to Test May 11, 2021 02:31 Inactive
Co-authored-by: Michael Cleaver <Mike@gravitylab.nz>
@jamessimone jamessimone temporarily deployed to Test May 11, 2021 13:32 Inactive
@jamessimone jamessimone temporarily deployed to Test May 11, 2021 13:36 Inactive
@jamessimone jamessimone linked an issue May 11, 2021 that may be closed by this pull request
@jamessimone jamessimone merged commit 7988c78 into main May 11, 2021
@jamessimone jamessimone deleted the v1.2.17 branch May 11, 2021 13:45
Integer lookupHash = String.isBlank(this.lookupKey) ? 1 : this.lookupKey.hashCode();
Integer valHash = this.rollupValue == null ? 2 : this.rollupValue.hashCode();
try {
hashToReturn = idHash + lookupHash + valHash;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, so this is the main problem here. You never really want to just add hashes together. This is how you get collisions. Basically you're going to want another class to do this math for you.

  1. Your hash should always start non-zero (I choose 17 for mine).
  2. For every item you want to add to the hash you should do (currentHash * PRIME_NUMBER) + hashOfThingYouWantToAdd

I don't know the mathematics behind it, but the prime number and non-zero starting point essentially just makes it distribute better. Theres a good chapter in Effective Java by Joshua Bloch on implementing correct hash codes.

If you want I can update my hash code util class to fix its current bugs and you can just use that for this. I'll have to reread to see how he handles overflow.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gdoenlen thanks so much for this. I only noticed the potential for overflow this morning while examining some hashes, but then I had to rush this out the door before work actually started. I read through your util class and I'd be happy to take from that (with proper attribution of course), but if you aren't feeling like putting any more work into it I also totally understand. Either way, I'll look to cut over to the proper hash handling in the next few days - thank you again!

Integer hashToReturn;
Integer idHash = this.Id == null ? 0 : ((Object) this.Id).hashCode();
Integer lookupHash = String.isBlank(this.lookupKey) ? 1 : this.lookupKey.hashCode();
Integer valHash = this.rollupValue == null ? 2 : this.rollupValue.hashCode();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the significance of 1 and 2 here? Typically for null keys you always want 0. And for the empty string case I would just take the hashCode that SFDC has already define for it.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No significance at all, I was just running out of steam this morning and was numbering down the constructor (hence 0, 1, 2). I'm going to run with your first comment and dig myself out of this hole.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

System.SObjectException: Field xxx is not editable WhereFieldEvaluator too permissive on updates
3 participants