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 2020/11/03 16:26:36 UTC

[GitHub] [nifi-minifi-cpp] aminadinari19 opened a new pull request #934: MINIFICPP-1330-add conversion from microseconds

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


   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:
   - [Y] Is there a JIRA ticket associated with this PR? Is it referenced
        in the commit message?
   
   - [Y] 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.
   
   - [Y] Has your PR been rebased against the latest commit within the target branch (typically main)?
   
   - [Y] 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.

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



[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #934: MINIFICPP-1330-add conversion from microseconds

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



##########
File path: libminifi/test/unit/PropertyTests.cpp
##########
@@ -22,6 +22,39 @@
 #include "../../include/core/Property.h"
 #include "utils/StringUtils.h"
 #include "../TestBase.h"
+namespace {
+enum class ParsingStatus { ParsingFail , ParsingSuccessful , ValuesMatch };
+enum class ConversionTestTarget { MS, NS };
+
+ParsingStatus checkTimeValue(const std::string &input, int64_t t1, core::TimeUnit t2) {
+  int64_t TimeVal;
+  core::TimeUnit unit;
+  bool parsing_succeeded = org::apache::nifi::minifi::core::Property::StringToTime(input, TimeVal, unit);
+  if (parsing_succeeded) {
+    if (TimeVal == t1 && unit == t2) {
+      return ParsingStatus::ValuesMatch;
+    } else {
+      return ParsingStatus::ParsingSuccessful;
+    }
+  } else {
+    return ParsingStatus::ParsingFail;
+  }
+}
+
+bool conversionTest(uint64_t number, core::TimeUnit unit, uint64_t check, ConversionTestTarget conversionUnit) {
+  uint64_t out;
+  bool returnStatus;
+  if (conversionUnit == ConversionTestTarget::NS) {
+    returnStatus = org::apache::nifi::minifi::core::Property::ConvertTimeUnitToNS(number, unit, out);
+  } else if (conversionUnit == ConversionTestTarget::MS) {
+    returnStatus = org::apache::nifi::minifi::core::Property::ConvertTimeUnitToMS(number, unit, out);
+  }
+  if (returnStatus && out == check) {
+    return true;
+  } else {
+    return false;
+  }

Review comment:
       ```suggestion
    return returnStatus && out == 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.

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



[GitHub] [nifi-minifi-cpp] hunyadi-dev commented on a change in pull request #934: MINIFICPP-1330-add conversion from microseconds

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



##########
File path: libminifi/test/unit/PropertyTests.cpp
##########
@@ -22,6 +22,39 @@
 #include "../../include/core/Property.h"
 #include "utils/StringUtils.h"
 #include "../TestBase.h"
+namespace {

Review comment:
       It is a good practice to put all tests into anon namespaces.




----------------------------------------------------------------
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.

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



[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #934: MINIFICPP-1330-add conversion from microseconds

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



##########
File path: libminifi/test/unit/PropertyTests.cpp
##########
@@ -22,6 +22,39 @@
 #include "../../include/core/Property.h"
 #include "utils/StringUtils.h"
 #include "../TestBase.h"
+namespace {

Review comment:
       Thanks, I was just wondering if it was due to a linker error or some other reason.




----------------------------------------------------------------
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.

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



[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #934: MINIFICPP-1330-add conversion from microseconds

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



##########
File path: libminifi/test/unit/PropertyTests.cpp
##########
@@ -22,6 +22,39 @@
 #include "../../include/core/Property.h"
 #include "utils/StringUtils.h"
 #include "../TestBase.h"
+namespace {

Review comment:
       Do we need the anonymous namespace here?

##########
File path: libminifi/test/unit/PropertyTests.cpp
##########
@@ -22,6 +22,39 @@
 #include "../../include/core/Property.h"
 #include "utils/StringUtils.h"
 #include "../TestBase.h"
+namespace {
+enum class ParsingStatus { ParsingFail , ParsingSuccessful , ValuesMatch };
+enum class ConversionTestTarget { MS, NS };
+
+ParsingStatus checkTimeValue(const std::string &input, int64_t t1, core::TimeUnit t2) {
+  int64_t TimeVal;
+  core::TimeUnit unit;
+  bool parsing_succeeded = org::apache::nifi::minifi::core::Property::StringToTime(input, TimeVal, unit);
+  if (parsing_succeeded) {
+    if (TimeVal == t1 && unit == t2) {
+      return ParsingStatus::ValuesMatch;
+    } else {
+      return ParsingStatus::ParsingSuccessful;
+    }
+  } else {
+    return ParsingStatus::ParsingFail;
+  }
+}
+
+bool conversionTest(uint64_t number, core::TimeUnit unit, uint64_t check, ConversionTestTarget conversionUnit) {
+  uint64_t out;
+  bool returnStatus;

Review comment:
       Minor: I know these will be eventually filled by the parser function, but I would recommend giving an initial value for the primitive types.

##########
File path: libminifi/include/utils/ValueParser.h
##########
@@ -216,6 +216,7 @@ bool StringToTime(const std::string& input, Out& output, core::TimeUnit& timeuni
   }
 }
 
+

Review comment:
       Minor: unnecessary ws.

##########
File path: libminifi/test/unit/PropertyTests.cpp
##########
@@ -22,6 +22,39 @@
 #include "../../include/core/Property.h"
 #include "utils/StringUtils.h"
 #include "../TestBase.h"
+namespace {
+enum class ParsingStatus { ParsingFail , ParsingSuccessful , ValuesMatch };
+enum class ConversionTestTarget { MS, NS };
+
+ParsingStatus checkTimeValue(const std::string &input, int64_t t1, core::TimeUnit t2) {
+  int64_t TimeVal;
+  core::TimeUnit unit;
+  bool parsing_succeeded = org::apache::nifi::minifi::core::Property::StringToTime(input, TimeVal, unit);
+  if (parsing_succeeded) {
+    if (TimeVal == t1 && unit == t2) {
+      return ParsingStatus::ValuesMatch;
+    } else {
+      return ParsingStatus::ParsingSuccessful;
+    }
+  } else {
+    return ParsingStatus::ParsingFail;
+  }
+}
+
+bool conversionTest(uint64_t number, core::TimeUnit unit, uint64_t check, ConversionTestTarget conversionUnit) {
+  uint64_t out;
+  bool returnStatus;
+  if (conversionUnit == ConversionTestTarget::NS) {
+    returnStatus = org::apache::nifi::minifi::core::Property::ConvertTimeUnitToNS(number, unit, out);
+  } else if (conversionUnit == ConversionTestTarget::MS) {
+    returnStatus = org::apache::nifi::minifi::core::Property::ConvertTimeUnitToMS(number, unit, out);
+  }
+  if (returnStatus && out == check) {
+    return true;
+  } else {
+    return false;
+  }

Review comment:
       ```suggestion
    return returnreturnStatus && out == check;
   ```

##########
File path: libminifi/include/core/Property.h
##########
@@ -180,10 +180,15 @@ class Property {
 // Compare
   bool operator <(const Property & right) const;
 
-// Convert TimeUnit to MilliSecond

Review comment:
       :+1: I'm always for the idea of removing trivial comments




----------------------------------------------------------------
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.

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



[GitHub] [nifi-minifi-cpp] aminadinari19 commented on a change in pull request #934: MINIFICPP-1330-add conversion from microseconds

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



##########
File path: libminifi/test/unit/PropertyTests.cpp
##########
@@ -22,6 +22,39 @@
 #include "../../include/core/Property.h"
 #include "utils/StringUtils.h"
 #include "../TestBase.h"
+namespace {
+enum class ParsingStatus { ParsingFail , ParsingSuccessful , ValuesMatch };
+enum class ConversionTestTarget { MS, NS };
+
+ParsingStatus checkTimeValue(const std::string &input, int64_t t1, core::TimeUnit t2) {
+  int64_t TimeVal;
+  core::TimeUnit unit;
+  bool parsing_succeeded = org::apache::nifi::minifi::core::Property::StringToTime(input, TimeVal, unit);
+  if (parsing_succeeded) {
+    if (TimeVal == t1 && unit == t2) {
+      return ParsingStatus::ValuesMatch;
+    } else {
+      return ParsingStatus::ParsingSuccessful;
+    }
+  } else {
+    return ParsingStatus::ParsingFail;
+  }
+}
+
+bool conversionTest(uint64_t number, core::TimeUnit unit, uint64_t check, ConversionTestTarget conversionUnit) {
+  uint64_t out;
+  bool returnStatus;

Review comment:
       Yeah that is always a better method. Will keep that in mind :)




----------------------------------------------------------------
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.

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



[GitHub] [nifi-minifi-cpp] szaszm closed pull request #934: MINIFICPP-1330-add conversion from microseconds

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


   


----------------------------------------------------------------
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.

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



[GitHub] [nifi-minifi-cpp] aminadinari19 removed a comment on pull request #934: MINIFICPP-1330-add conversion from microseconds

Posted by GitBox <gi...@apache.org>.
aminadinari19 removed a comment on pull request #934:
URL: https://github.com/apache/nifi-minifi-cpp/pull/934#issuecomment-724690340


   Thank you. Will implement that tip in the future :)


----------------------------------------------------------------
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.

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



[GitHub] [nifi-minifi-cpp] aminadinari19 commented on pull request #934: MINIFICPP-1330-add conversion from microseconds

Posted by GitBox <gi...@apache.org>.
aminadinari19 commented on pull request #934:
URL: https://github.com/apache/nifi-minifi-cpp/pull/934#issuecomment-724690340


   Thank you. Will implement that tip in the future :)


----------------------------------------------------------------
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.

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