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

Clean up ordinal map in default SSDV reader state #12454

Merged
merged 3 commits into from Nov 9, 2023

Conversation

stefanvodita
Copy link
Contributor

DefaultSortedSetDocValuesReaderState has a cache of ordinal maps, but it only has one ordinal map in it at most.

This PR preserves the functionality of the class, but removes cachedOrdMaps. We can't synchronise on the ordinal map itself, since it could be null, so we introduce an ordinal map lock instead.

Overall, I like the previous code a bit better, it's cleaner and more concise, although cachedOrdMaps looks confusing at first. Maybe it just needs a comment explaining why using a map is convenient (we can synchronize on it, we can call Accountables.namedAccountables with it)? I'd like to hear what others think.

@gsmiller
Copy link
Contributor

Overall, I like the previous code a bit better, it's cleaner and more concise, although cachedOrdMaps looks confusing at first. Maybe it just needs a comment explaining why using a map is convenient (we can synchronize on it, we can call Accountables.namedAccountables with it)? I'd like to hear what others think.

Personally, I agree with this. Maybe we clean up the documentation and leave as-is?

@stefanvodita stefanvodita marked this pull request as ready for review July 29, 2023 09:47
@stefanvodita
Copy link
Contributor Author

Thanks Greg! I’ve kept the hash map and did some clean-up.

long bytes = 0;
for (OrdinalMap map : cachedOrdMaps.values()) {
bytes += map.ramBytesUsed();
synchronized (cachedOrdMap) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We might not need this synchronization. Because the map has one entry at most and we're only writing it once, I don't think we can end up in an invalid state here, but it seemes wiser not to rely on that.

@stefanvodita
Copy link
Contributor Author

stefanvodita commented Sep 23, 2023

@gsmiller, I think this PR is ready. Is there anything else you'd like to see changed?

@gsmiller
Copy link
Contributor

gsmiller commented Nov 8, 2023

@gsmiller, I think this PR is ready. Is there anything else you'd like to see changed?

Gah! I'm sorry I missed this. I'll have a look here shortly. Apologies again.

Copy link
Contributor

@gsmiller gsmiller left a comment

Choose a reason for hiding this comment

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

Thanks and sorry for the long delay!

@gsmiller gsmiller merged commit 8665014 into apache:main Nov 9, 2023
4 checks passed
@stefanvodita
Copy link
Contributor Author

Thanks Greg! I think the delay is partially my fault, I had mentioned a different G. Miller in my message 😄

@mikemccand
Copy link
Member

Thanks Greg! I think the delay is partially my fault, I had mentioned a different G. Miller in my message 😄

Seems to be common mistake recently! See this recent hilarious example!

@gsmiller gsmiller added this to the 9.9.0 milestone Nov 9, 2023
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.

None yet

3 participants