NIFI-13393 Support passing in FF attributes to create Flow File #8968
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
method to avoid an extra flow file from being created
This PR is a proposal to see if the PMC agrees with this API change.
I have not written any new unit tests for this PR yet until I get buy-in on it.
I added two new create methods to the API of ProcessSession to allow the option of
passing in ff attributes to be added to the flow file being created. This is not
a breaking change because the original create methods are still there.
ProcessSession
FlowFile create(FlowFile parent, final Map<String, String> attributes);
FlowFile create(final Map<String, String> attributes);
Changing a core API is a very significant change but I hope people will see it
as worthwhile to allow us to to avoid creating an extra FlowFile object in many
places that FlowFiles are created. Not all places set attributes right after
FF creation, but very many of them do and could benefit.
There are 150+ places where these new methods can be used and I only changed the
GenerateTableFetch processor to call them so you how the new methods are used.
I expect using these new create methods has the potential to
avoid noticeable transient memory allocation like the earlier API addition of
SessionContext.isAutoTerminated did.
Also if this PR is approved, myself and others can change processors to call these
new methods in a future PRs (not as part of this PR).
Summary
NIFI-13393
Tracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-13393
NIFI-13393
Pull Request Formatting
main
branchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
mvn clean install -P contrib-check
Licensing
No new files or dependencies
Documentation
No documentation changes.