You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2021/12/13 09:07:56 UTC

[GitHub] [nifi-minifi-cpp] martinzink opened a new pull request #1226: MINIFICPP-1673: ProcessSession::write/ProcessSession::append should o…

martinzink opened a new pull request #1226:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1226


   …nly operate on flowfiles marked as new/modified
   
   Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [ ] Is there a JIRA ticket associated with this PR? Is it referenced
        in the commit message?
   
   - [ ] Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
   
   - [ ] Has your PR been rebased against the latest commit within the target branch (typically main)?
   
   - [ ] Is your initial contribution a single, squashed commit?
   
   ### For code changes:
   - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
   - [ ] If applicable, have you updated the LICENSE file?
   - [ ] If applicable, have you updated the NOTICE file?
   
   ### For documentation related changes:
   - [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
   
   ### Note:
   Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #1226: MINIFICPP-1673: ProcessSession::write/ProcessSession::append should o…

Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on a change in pull request #1226:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1226#discussion_r768631049



##########
File path: libminifi/src/core/ProcessSession.cpp
##########
@@ -212,6 +212,10 @@ void ProcessSession::transfer(const std::shared_ptr<core::FlowFile> &flow, Relat
 }
 
 void ProcessSession::write(const std::shared_ptr<core::FlowFile> &flow, OutputStreamCallback *callback) {
+  gsl_ExpectsAudit(_updatedFlowFiles.contains(flow->getUUID())

Review comment:
       as we provide access to the session to custom code through the script extension, this feels like an invariant we should always check, turning the `std::map`s (and the `_clonedFlowFiles` vector) into `std::unordered_map`s would make the check an `O(1)` operation




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] martinzink commented on a change in pull request #1226: MINIFICPP-1673: ProcessSession::write/ProcessSession::append should o…

Posted by GitBox <gi...@apache.org>.
martinzink commented on a change in pull request #1226:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1226#discussion_r768512438



##########
File path: libminifi/src/core/ProcessSession.cpp
##########
@@ -212,6 +212,10 @@ void ProcessSession::transfer(const std::shared_ptr<core::FlowFile> &flow, Relat
 }
 
 void ProcessSession::write(const std::shared_ptr<core::FlowFile> &flow, OutputStreamCallback *callback) {
+  gsl_Expects(_updatedFlowFiles.contains(flow->getUUID())
+              || _addedFlowFiles.contains(flow->getUUID())
+              || std::any_of(_clonedFlowFiles.begin(), _clonedFlowFiles.end(), [&flow](const auto& cloned_flow_file) { return flow == cloned_flow_file; }));
+

Review comment:
       good idea, changed it in https://github.com/apache/nifi-minifi-cpp/pull/1226/commits/300532be1a9347d2926c139185bbf46edb619102




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #1226: MINIFICPP-1673: ProcessSession::write/ProcessSession::append should o…

Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on a change in pull request #1226:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1226#discussion_r768656719



##########
File path: libminifi/src/core/ProcessSession.cpp
##########
@@ -212,6 +212,10 @@ void ProcessSession::transfer(const std::shared_ptr<core::FlowFile> &flow, Relat
 }
 
 void ProcessSession::write(const std::shared_ptr<core::FlowFile> &flow, OutputStreamCallback *callback) {
+  gsl_ExpectsAudit(_updatedFlowFiles.contains(flow->getUUID())

Review comment:
       we wrap the session in a `PyProcessSession` which could handle the check if it had access to the internals of the `ProcessSession` (not probable) or had its own flowfile registry (would be duplicating the session's internal registry)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] szaszm closed pull request #1226: MINIFICPP-1673: ProcessSession::write/ProcessSession::append should o…

Posted by GitBox <gi...@apache.org>.
szaszm closed pull request #1226:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1226


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #1226: MINIFICPP-1673: ProcessSession::write/ProcessSession::append should o…

Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #1226:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1226#discussion_r768640855



##########
File path: libminifi/src/core/ProcessSession.cpp
##########
@@ -212,6 +212,10 @@ void ProcessSession::transfer(const std::shared_ptr<core::FlowFile> &flow, Relat
 }
 
 void ProcessSession::write(const std::shared_ptr<core::FlowFile> &flow, OutputStreamCallback *callback) {
+  gsl_ExpectsAudit(_updatedFlowFiles.contains(flow->getUUID())

Review comment:
       I prefer the narrow contract (we can document preconditions to scripting users, too), but if you decide to have a wide contract, then please use if + throw or something similar to implement it, not gsl_Expects (which is meant to declare preconditions).




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #1226: MINIFICPP-1673: ProcessSession::write/ProcessSession::append should o…

Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #1226:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1226#discussion_r767623866



##########
File path: libminifi/src/core/ProcessSession.cpp
##########
@@ -212,6 +212,10 @@ void ProcessSession::transfer(const std::shared_ptr<core::FlowFile> &flow, Relat
 }
 
 void ProcessSession::write(const std::shared_ptr<core::FlowFile> &flow, OutputStreamCallback *callback) {
+  gsl_Expects(_updatedFlowFiles.contains(flow->getUUID())
+              || _addedFlowFiles.contains(flow->getUUID())
+              || std::any_of(_clonedFlowFiles.begin(), _clonedFlowFiles.end(), [&flow](const auto& cloned_flow_file) { return flow == cloned_flow_file; }));
+

Review comment:
       This check looks like it's on the more expensive side. Consider changing it to [`gsl_ExpectsAudit`](https://github.com/gsl-lite/gsl-lite#contract-checking-configuration-macros) to remove the check from non-CI builds that don't define `gsl_CONFIG_CONTRACT_CHECKING_AUDIT`. (same in append)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #1226: MINIFICPP-1673: ProcessSession::write/ProcessSession::append should o…

Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #1226:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1226#discussion_r768552299



##########
File path: libminifi/src/core/ProcessSession.cpp
##########
@@ -212,6 +212,10 @@ void ProcessSession::transfer(const std::shared_ptr<core::FlowFile> &flow, Relat
 }
 
 void ProcessSession::write(const std::shared_ptr<core::FlowFile> &flow, OutputStreamCallback *callback) {
+  gsl_Expects(_updatedFlowFiles.contains(flow->getUUID())
+              || _addedFlowFiles.contains(flow->getUUID())
+              || std::any_of(_clonedFlowFiles.begin(), _clonedFlowFiles.end(), [&flow](const auto& cloned_flow_file) { return flow == cloned_flow_file; }));
+

Review comment:
       Consider extracting the lambda to a variable to avoid the error with clang. It will start working once they implement the C++20 feature "Lambdas in unevaluated contexts".
   This is the disabled implementation of the macro:
   ```
   # define gsl_ELIDE_( x )  static_assert( ::std::is_constructible<bool, decltype( x )>::value, "argument of contract check must be convertible to bool" )
   ```
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #1226: MINIFICPP-1673: ProcessSession::write/ProcessSession::append should o…

Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #1226:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1226#discussion_r768641854



##########
File path: libminifi/src/core/ProcessSession.cpp
##########
@@ -212,6 +212,10 @@ void ProcessSession::transfer(const std::shared_ptr<core::FlowFile> &flow, Relat
 }
 
 void ProcessSession::write(const std::shared_ptr<core::FlowFile> &flow, OutputStreamCallback *callback) {
+  gsl_ExpectsAudit(_updatedFlowFiles.contains(flow->getUUID())

Review comment:
       Is it feasible to keep the precondition in the C++ world and make the scripting wrapper have an internal check?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #1226: MINIFICPP-1673: ProcessSession::write/ProcessSession::append should o…

Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on a change in pull request #1226:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1226#discussion_r768662563



##########
File path: libminifi/src/core/ProcessSession.cpp
##########
@@ -212,6 +212,10 @@ void ProcessSession::transfer(const std::shared_ptr<core::FlowFile> &flow, Relat
 }
 
 void ProcessSession::write(const std::shared_ptr<core::FlowFile> &flow, OutputStreamCallback *callback) {
+  gsl_ExpectsAudit(_updatedFlowFiles.contains(flow->getUUID())

Review comment:
       I prefer having the checks if possible (unless they are too costly and in the hot path) instead of the "read-the-docs" hands-off strategy, as the scripting processor is not really used, I'm fine with leaving it as-is, but IMO it is something we should revisit if need arises 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #1226: MINIFICPP-1673: ProcessSession::write/ProcessSession::append should o…

Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #1226:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1226#discussion_r768640855



##########
File path: libminifi/src/core/ProcessSession.cpp
##########
@@ -212,6 +212,10 @@ void ProcessSession::transfer(const std::shared_ptr<core::FlowFile> &flow, Relat
 }
 
 void ProcessSession::write(const std::shared_ptr<core::FlowFile> &flow, OutputStreamCallback *callback) {
+  gsl_ExpectsAudit(_updatedFlowFiles.contains(flow->getUUID())

Review comment:
       I prefer the narrow contract, but if you decide to have a wide contract, then please use if + throw or something similar to implement it, not gsl_Expects (which is meant to declare preconditions).




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #1226: MINIFICPP-1673: ProcessSession::write/ProcessSession::append should o…

Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #1226:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1226#discussion_r768666904



##########
File path: libminifi/src/core/ProcessSession.cpp
##########
@@ -212,6 +212,10 @@ void ProcessSession::transfer(const std::shared_ptr<core::FlowFile> &flow, Relat
 }
 
 void ProcessSession::write(const std::shared_ptr<core::FlowFile> &flow, OutputStreamCallback *callback) {
+  gsl_ExpectsAudit(_updatedFlowFiles.contains(flow->getUUID())

Review comment:
       I would not be against a public member function that can check if a flow file can be written to. I don't know a good name though. Maybe `bool canBeWrittenTo(const core::FlowFile&) const noexcept;`? If we did that, `PyProcessSession` could check that and `write`/`append` could have that as their precondition.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org