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

Replace LinkedHashMap by HashMap or Map #266

Merged
merged 1 commit into from
Feb 12, 2020

Conversation

jpbempel
Copy link
Member

Configurations come mostly as LinkedHashMap from Yaml or Json parsers
But usage inside JMXFetch is mostly as HashMap.
As LinkedHashMap is heavier regarding memory footprint, we prefer to
avoid its usage by just replacing by HashMap. Also it does not seem
That order matters in the case of JMXFetch usage.
I have changed also the type to use Map interface as it will be easier
to change the implementation if required in the future without
changing this type everywhere.

@jpbempel jpbempel requested a review from a team February 11, 2020 16:39
@@ -849,16 +848,16 @@ public void init(boolean forceNewConnection) {
it.remove();
}

ArrayList<LinkedHashMap<String, Object>> configInstances =
((ArrayList<LinkedHashMap<String, Object>>) yamlConfig.getYamlInstances());
ArrayList<Map<String, Object>> configInstances =
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this is outside the scope of your changes, and is more a style thing, but since we are changing to the interface with Map maybe we should do the same with List?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is effectively outside of the scope and it will be addressed in a next PR :)
I think there are already enough changes for a PR 😅

Copy link
Member

@truthbk truthbk left a comment

Choose a reason for hiding this comment

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

I didn't see anything wrong with this, I agree that order doesn't matter in general, not for instance ordering, not for config settings, not for bean collection order, etc. So no objections.

We do have some checkstyle errors apparently (I related to import lexicographical order from what I could see), so we should fix those before merging, but other than that, this looks good! Thank you for all the cleanup too! 🙇

Configurations come mostly as LinkedHashMap from Yaml or Json parsers
But usage inside JMXFetch is mostly as HashMap.
As LinkedHashMap is heavier regarding memory footprint, we prefer to
avoid its usage by just replacing by HashMap. Also it does not seem
That order matters in the case of JMXFetch usage.
I have changed also the type to use Map interface as it will be easier
To change the implementation if required in the future without
changing this type everywhere.
@jpbempel jpbempel force-pushed the jpbempel/replaceLinkedHashMap branch from def2491 to 9405f32 Compare February 12, 2020 08:43
@jpbempel jpbempel merged commit 5fbff55 into DataDog:master Feb 12, 2020
@jpbempel jpbempel deleted the jpbempel/replaceLinkedHashMap branch February 12, 2020 08:49
@truthbk truthbk added this to the 0.35.0 milestone Feb 18, 2020
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.

3 participants