Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

NiFi: Pass by Reference vs Copy on Write

avatar
Expert Contributor

So, splitting to two separate processor with the same relationship "success" say from FetchFile processor, does the flowfile content gets replicated? It appears that it is true, as I observed the uuid values are different when compared between the two.

Is it safe to assume the changes to flowfile content on one flow (even on one end it gets discarded) would not have any impact to the other?

10209-flow.jpg

1 ACCEPTED SOLUTION

avatar
Guru

You can be 100% that one forked flow file will not effect another. When a flow file is passed from one processor to another, the upstream processor passes a reference (to flowfile in content repository) to the second processor. When one processor forks the same flow file to two different processors, the flow file in content repository is CLONED ... reference of one clone is passed to one processor and reference to the other clone is passed to the second processor.

Note that viewing the provenance of your flow live flow shows these reference-clone details.

This explains flowfile life cycle, including explanation here:

https://nifi.apache.org/docs/nifi-docs/html/nifi-in-depth.html#pass-by-reference

View solution in original post

2 REPLIES 2

avatar

A new flow file will be created, BUT they both will point to an immutable piece of data in the Content Repository. The HashContent step in your example will have replaced the content, but it will be a new FF pointing to a new piece of data in the content repository. The other branch of the flow is not affected in any way by this content change.

Read more here, for example: https://nifi.apache.org/docs/nifi-docs/html/nifi-in-depth.html#pass-by-reference

avatar
Guru

You can be 100% that one forked flow file will not effect another. When a flow file is passed from one processor to another, the upstream processor passes a reference (to flowfile in content repository) to the second processor. When one processor forks the same flow file to two different processors, the flow file in content repository is CLONED ... reference of one clone is passed to one processor and reference to the other clone is passed to the second processor.

Note that viewing the provenance of your flow live flow shows these reference-clone details.

This explains flowfile life cycle, including explanation here:

https://nifi.apache.org/docs/nifi-docs/html/nifi-in-depth.html#pass-by-reference