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

SOLR-14680: Remove SimpleMap (affects NamedList) #2856

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

dsmiley
Copy link
Contributor

@dsmiley dsmiley commented Nov 9, 2024

and remove the rest of SolrJ org.apache.solr.cluster.api

NamedList:

  • new getOrDefault
  • remove forEachEntry, forEachKey, abortableForEachKey, abortableForEach
  • remove asMap, get(key, default)

https://issues.apache.org/jira/browse/SOLR-14680


This was a pain because SimpleMap was a little more entrenched. It deserves a CHANGES.txt calling out briefly that NamedList is impacted, since this is so omnipresent in Solr.

and the rest of SolrJ org.apache.solr.cluster.api

NamedList:
* new getOrDefault
* remove forEachEntry, forEachKey, abortableForEachKey, abortableForEach
* remove asMap, get(key, default)
Copy link
Contributor Author

@dsmiley dsmiley left a comment

Choose a reason for hiding this comment

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

I should have marked things for deletion instead of actually deleting them so that I can back-port the deprecations and some of the changes. So I'll do a 9x PR separately afterwards.

}

public String subtituteVal(String s) {
private static String substituteVal(String s) {
return PropertiesUtil.substitute(s, SUBSTITUTES.get());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This particular aspect of the design of ConfigNode framework is, um, ... really concerning to me: a ThreadLocal to hold the substitution rules. Wow, so depending on which thread is looking(using) the map, they get different answers?! @noblepaul can you offer an explanation as to why it's this way instead of a normal field on the ConfigNode? This design has me concerned with respect to this PR since there were some Map conversions (via asMap which surprisingly creates a new Map; isn't a view) that maybe are now a view; I need to check. The difference is that previously the value would be materialized using the ThreadLocal of whoever called asMap but now would be whoever is looking at the values. Subtle!

Copy link
Contributor

Choose a reason for hiding this comment

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

This was probbaly done to avoid changing the public APIs. We can change them now, not a big deal

Copy link
Contributor

Choose a reason for hiding this comment

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

re were some Map conversions (via asMap which surprisingly creates a new Map;

YEs. it has to be changed. But asMap is not used in many places

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay; I'll file a pair of JIRA issues tomorrow if you don't first:

  • Replace ConfigNode.SUBSTITUTES (ThreadLocal); redesign
  • Rename NamedList.asMap to something like toMapRecursively

@epugh
Copy link
Contributor

epugh commented Nov 9, 2024

I don't think I have the knowledge to weigh in here, but I did like that this removes 10x more lines than it adds!

solr/core/src/java/org/apache/solr/cli/ApiTool.java Outdated Show resolved Hide resolved
Map<String, Object> systemInfo =
solrClient
.request(new GenericSolrRequest(SolrRequest.METHOD.GET, CommonParams.SYSTEM_INFO_PATH))
.asMap();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

needless asMap call. @epugh you added this code a year ago, maybe because you don't like NamedList?

Copy link
Contributor

Choose a reason for hiding this comment

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

You are right that I don't like NamedList, it's always been a weird Solr specific data structure. Why did we feel the need to come up with a unique data structure that isn't in the JDK? Having said that, what you are proposing is clearly an improvement!

Copy link
Contributor

Choose a reason for hiding this comment

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

I also wish we just had a cleaner data structure for these GSR that return JSON. I love that in our tests we have assertJQ and JQ methods that lets us grab some json. In a perfect world, this call would have returned a JSON datastructure, and I would use a Json query line to pluck out the core_root. This would be more compelling if we had a much more nested Map data structure to go through!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think @gerlowskija would argue that the "perfect world" (we're slowly iterating towards) would not be JSON at this level of abstraction, it'd be a a machine-generated POJO generated from our OpenAPI that you call normal typed methods on. Correct me if I'm wrong Jason; I agree with that vision too.

But in the meantime Eric, get to know NamedList. It's not going anywhere anytime soon, and it's also not hard to use IMO. I wish it had the convenience methods that SolrParams has but not a big deal.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to the POJO! And yep.

}

public String subtituteVal(String s) {
private static String substituteVal(String s) {
return PropertiesUtil.substitute(s, SUBSTITUTES.get());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay; I'll file a pair of JIRA issues tomorrow if you don't first:

  • Replace ConfigNode.SUBSTITUTES (ThreadLocal); redesign
  • Rename NamedList.asMap to something like toMapRecursively

@dsmiley dsmiley requested a review from sigram November 17, 2024 06:59
@dsmiley
Copy link
Contributor Author

dsmiley commented Nov 17, 2024

If I should break this up, or file another JIRA, let me know. The SimpleMap part feels kind of separate, especially since it impacts the ubiquitous NamedList.

@dsmiley
Copy link
Contributor Author

dsmiley commented Nov 22, 2024

I plan to merge this next week with the following CHANGES.txt under 9.8
CHANGES.txt, 9.8:

OTHER
* SOLR-14680: NamedList, deprecating methods: forEachEntry, forEachKey, abortableForEachKey, abortableForEach,
 asMap (no-arg only), get(key, default).  Added getOrDefault.  Deprecated the SimpleMap interface as well as the,
 entirety of the SolrJ package org.apache.solr.cluster.api, which wasn't used except for SimpleMap.  (David Smiley)

Don't plan to say anything in 10 since removing deprecated code doesn't deserve a mention, generally.
I'll do the 9x deprecations and addition of getOrDefault in another commit on branch_9x.

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

Successfully merging this pull request may close these issues.

3 participants