- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
NiFi: Pass by Reference vs Copy on Write
- Labels:
-
Apache NiFi
Created on ‎12-10-2016 07:17 AM - edited ‎08-18-2019 06:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
Created ‎12-10-2016 03:18 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Created ‎12-10-2016 03:06 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Created ‎12-10-2016 03:18 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
