get the curation statuses faster: no expensive get calls#12552
Open
ffritze wants to merge 1 commit into
Open
Conversation
qqmyers
requested changes
Jul 22, 2026
qqmyers
left a comment
Member
There was a problem hiding this comment.
The code looks correct (it should work), but I'm a bit surprised that it would do anything. CurationStatus.getCreateTime simply returns an existing value -
dataverse/src/main/java/edu/harvard/iq/dataverse/CurationStatus.java
Lines 80 to 82 in df71344
If we do merge, I suggest a little cleanup to avoid repeating the multiline update cache statement several times.
| CurationStatus::getCreateTime, | ||
| (a, b) -> a, | ||
| IdentityHashMap::new | ||
| )); |
Member
There was a problem hiding this comment.
Can you make this a method to avoid repeating the code several times? (I see it's one line, but it would be nice to not have to check that the multiple uses are all the same.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
Setting a new curation label can take very long and could lead to an internal server error.
Which issue(s) this PR closes:
This pull request addresses the following issue: #12399
Special notes for your reviewer:
It is tested on my dev machine. This machine does not have to handle very high load. It was not possible to test in a real scenario with heavy load on the Payara server.
Suggestions on how to test this:
Does this PR introduce a user interface change? If mockups are available, please link/include them here:
No
Is there a release notes update needed for this change?:
Additional documentation:
This fix has been developed with the help of Claude code. It says: The original approach sorted the list by calling
getCreateTime()directly inside the comparator. The drawback is that a comparison-based sort calls the comparator roughlyn·log(n)times fornelements, so the getter ends up being invoked far more often than there are actual objects.The optimization introduces a key cache: before sorting, the code walks the list once and builds a lookup structure that maps each object to its
createTimevalue, calling the getter exactly once per element. The sort then reads from this cache instead of calling the getter again, turning each comparison into a cheap lookup rather than a repeated method call.I assume that the original sorting logic was to expensive and so I co-developed with Claude this fix.