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

Rework federation merge functions to utilise advantages of Streams #3075

Open
tb06904 opened this issue Nov 10, 2023 · 0 comments
Open

Rework federation merge functions to utilise advantages of Streams #3075

tb06904 opened this issue Nov 10, 2023 · 0 comments
Labels
enhancement Improvement to existing functionality/feature federated-store Specific to/touches the federated-store module tech-debt Relates to Technical Debt

Comments

@tb06904
Copy link
Member

tb06904 commented Nov 10, 2023

Currently the merge functions utilised by the federated store don't use any of the Java Stream classes. These could bring performance enhancements due cheaper per element cost to spliterators or simplify code with methods like concat(), flatMap() and reduce().

Proposal is to refactor/rework these functions to take advantage of the Stream library where applicable. As an example you can merge two streams like:

Stream<Object> currentStream = StreamSupport.stream(current.spliterator(), false);
Stream<Object> updateStream = StreamSupport.stream(update.spliterator(), false);
// This cast satisfies the Iterable interface requirement to support an arbitrary number of iterations
Iterable<Object> merged = () -> Stream.concat(currentStream, updateStream).iterator();
return merged;

Originally posted by @GCHQDeveloper314 in #3072 (comment)

@tb06904 tb06904 added tech-debt Relates to Technical Debt federated-store Specific to/touches the federated-store module labels Nov 10, 2023
@t92549 t92549 added the enhancement Improvement to existing functionality/feature label Nov 10, 2023
@GCHQDeveloper314 GCHQDeveloper314 added this to the Medium Term Backlog milestone Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement to existing functionality/feature federated-store Specific to/touches the federated-store module tech-debt Relates to Technical Debt
Projects
None yet
Development

No branches or pull requests

3 participants