-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Represent lists as actual lists inside Settings #26878
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
Conversation
Today we represent each value of a list setting with it's own dedicated key that ends with the index of the value in the list. Aside of the obvious weirdness this has several issues especially if lists are massive since it causes massive runtime penalties when validating settings. Like a list of 100k words will literally cause a create index call to timeout and in-turn massive slowdown on all subsequent validations runs. With this change we use a simple string list to represent the list. This change also forbids to add a settings that ends with a .0 which was internally used to detect a list setting. Once this has been rolled out for an entire major version all the internal .0 handling can be removed since all settings will be converted. Relates to elastic#26723
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, one suggestion.
* @param defaultArray The default array to use if no value is specified | ||
* @param commaDelimited Whether to try to parse a string as a comma-delimited value | ||
* @return The setting array values | ||
*/ | ||
public String[] getAsArray(String settingPrefix, String[] defaultArray, Boolean commaDelimited) throws SettingsException { | ||
public String[] getAsArray(String key, String[] defaultArray, Boolean commaDelimited) throws SettingsException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are still going to have getAsArray, maybe we should store as an array instead of List? Then this method is really just a check + cast.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so my plan was rather to change the return type in a followup to List<String>
since I really don't want to return a mutable object. Makes sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does, I had not thought about the mutability of an array!
@@ -468,21 +468,21 @@ public void testDiff() throws IOException { | |||
ClusterSettings settings = new ClusterSettings(Settings.EMPTY, new HashSet<>(Arrays.asList(fooBar, fooBarBaz, foorBarQuux, | |||
someGroup, someAffix))); | |||
Settings diff = settings.diff(Settings.builder().put("foo.bar", 5).build(), Settings.EMPTY); | |||
assertEquals(4, diff.size()); // 4 since foo.bar.quux has 3 values essentially | |||
assertEquals(2, diff.size()); // 4 since foo.bar.quux has 3 values essentially |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these comments are no longer relevant i think? The essentially part was because each list element was it's own settings value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah correct I will remove it
Today we represent each value of a list setting with it's own dedicated key that ends with the index of the value in the list. Aside of the obvious weirdness this has several issues especially if lists are massive since it causes massive runtime penalties when validating settings. Like a list of 100k words will literally cause a create index call to timeout and in-turn massive slowdown on all subsequent validations runs. With this change we use a simple string list to represent the list. This change also forbids to add a settings that ends with a .0 which was internally used to detect a list setting. Once this has been rolled out for an entire major version all the internal .0 handling can be removed since all settings will be converted. Relates to #26723
List settings are not correctly filtered out in 5.6 and 6.0. This has been detected by a failing packaging test after #26878 has been merged.
List settings are not correctly filtered out in 5.6 and 6.0. This has been detected by a failing packaging test after #26878 has been merged.
Today we represent each value of a list setting with it's own dedicated key
that ends with the index of the value in the list. Aside of the obvious
weirdness this has several issues especially if lists are massive since it
causes massive runtime penalties when validating settings. Like a list of 100k
words will literally cause a create index call to timeout and in-turn massive
slowdown on all subsequent validations runs.
With this change we use a simple string list to represent the list. This change
also forbids to add a settings that ends with a .0 which was internally used to
detect a list setting. Once this has been rolled out for an entire major
version all the internal .0 handling can be removed since all settings will be
converted.
Relates to #26723