MINIFICPP-269 Implement ApplyTemplate processor#157
MINIFICPP-269 Implement ApplyTemplate processor#157calebj wants to merge 3 commits intoapache:masterfrom
Conversation
|
The code looks very clean and straightforward. Great work. I can definitely see the utility in such a processor for efficiently generating arbitrary textual formats from structured inputs. I will build and test this and get back to you if I notice any issues. |
| std::shared_ptr<core::Processor> processor = std::make_shared<org::apache::nifi::minifi::processors::ApplyTemplate>("processorname"); | ||
| REQUIRE(processor->getName() == "processorname"); | ||
| uuid_t processoruuid; | ||
| REQUIRE(true == processor->getUUID(processoruuid)); |
There was a problem hiding this comment.
Minor nit: simplify to REQUIRE(processor->getUUID(processoruuid));
| std::stringstream output_buf; | ||
| output_buf << output_file.rdbuf(); | ||
| std::string output_contents = output_buf.str(); | ||
| REQUIRE(output_contents == EXPECT_OUTPUT); |
There was a problem hiding this comment.
Nice, concise test condition.
|
There are a few clang-tidy issues that come up, which are mostly valid if minor. Other than that, looks good to me. |
5600f29 to
f1ee73a
Compare
libminifi/CMakeLists.txt
Outdated
| include_directories(../thirdparty/civetweb-1.9.1/include) | ||
| include_directories(../thirdparty/jsoncpp/include) | ||
| include_directories(../thirdparty/concurrentqueue/) | ||
| include_directories(../thirdparty/bustache/include) |
There was a problem hiding this comment.
You shouldn't need to include this here, but rather in the your extension's CMakeLists
extensions/bustache/ApplyTemplate.h
Outdated
| private: | ||
| //! Logger | ||
| std::shared_ptr<logging::Logger> logger_; | ||
| core::ProcessContext *_ctx; |
There was a problem hiding this comment.
Please use the google code style.
http://google.github.io/styleguide/cppguide.html#Variable_Names
extensions/bustache/ApplyTemplate.h
Outdated
| private: | ||
| //! Logger | ||
| std::shared_ptr<logging::Logger> logger_; | ||
| core::ProcessContext *_ctx; |
There was a problem hiding this comment.
Avoid the use of storing the raw pointer. Functors exist to provide on trigger and onschedule with the shared pointers. Please use those instead.
extensions/bustache/ApplyTemplate.h
Outdated
| ApplyTemplate(std::string name, uuid_t uuid = NULL) | ||
| : Processor(name, uuid) | ||
| { | ||
| logger_ = logging::LoggerFactory<ApplyTemplate>::getLogger(); |
There was a problem hiding this comment.
With logger_ we should consider using the initializer list
4989cec to
5f582dd
Compare
| setSupportedRelationships(relationships); | ||
| } | ||
|
|
||
| void ApplyTemplate::onTrigger(core::ProcessContext *context, core::ProcessSession *session) { |
There was a problem hiding this comment.
The shared ptr variants of these have for a while, so let's move to that for new processors. While the raw pointers exist I want to ensure new processors used the shared pointer calls.
| flowFile_ = flowFile; | ||
| } | ||
|
|
||
| int64_t ApplyTemplate::WriteCallback::process(std::shared_ptr<io::BaseStream> stream) { |
There was a problem hiding this comment.
It won't let me declare a different prototype than the virtual one in OutputStreamCallback
[ 85%] Building CXX object extensions/bustache/CMakeFiles/minifi-bustache-extensions.dir/ApplyTemplate.cpp.o
/home/ubuntu/workspace/extensions/bustache/ApplyTemplate.cpp: In member function ‘virtual void org::apache::nifi::minifi::processors::ApplyTemplate::onTrigger(const std::shared_ptr<org::apache::nifi::minifi::core::ProcessContext>&, const std::shared_ptr<org::apache::nifi::minifi::core::ProcessSession>&)’:
/home/ubuntu/workspace/extensions/bustache/ApplyTemplate.cpp:66:19: error: cannot declare variable ‘cb’ to be of abstract type ‘org::apache::nifi::minifi::processors::ApplyTemplate::WriteCallback’
WriteCallback cb(templateFile, std::shared_ptr<core::FlowFile>(flowFile));
^
In file included from /home/ubuntu/workspace/extensions/bustache/ApplyTemplate.cpp:32:0:
/home/ubuntu/workspace/extensions/bustache/ApplyTemplate.h:61:11: note: because the following virtual functions are pure within ‘org::apache::nifi::minifi::processors::ApplyTemplate::WriteCallback’:
class WriteCallback : public OutputStreamCallback {
^
In file included from /home/ubuntu/workspace/extensions/bustache/../../libminifi/include/core/ProcessSession.h:31:0,
from /home/ubuntu/workspace/extensions/bustache/../../libminifi/include/core/Processor.h:42,
from /home/ubuntu/workspace/extensions/bustache/ApplyTemplate.h:25,
from /home/ubuntu/workspace/extensions/bustache/ApplyTemplate.cpp:32:
/home/ubuntu/workspace/extensions/bustache/../../libminifi/include/FlowFileRecord.h:97:19: note: virtual int64_t org::apache::nifi::minifi::OutputStreamCallback::process(std::shared_ptr<org::apache::nifi::minifi::io::BaseStream>)
virtual int64_t process(std::shared_ptr<io::BaseStream> stream) = 0;
^
make[2]: *** [extensions/bustache/CMakeFiles/minifi-bustache-extensions.dir/ApplyTemplate.cpp.o] Error 1
make[1]: *** [extensions/bustache/CMakeFiles/minifi-bustache-extensions.dir/all] Error 2
make: *** [all] Error 2
| class WriteCallback : public OutputStreamCallback { | ||
| public: | ||
| WriteCallback(const std::string& templateFile, std::shared_ptr<core::FlowFile> flowFile); | ||
| int64_t process(std::shared_ptr<io::BaseStream> stream); |
There was a problem hiding this comment.
const ref shared pointers here, please.
extensions/bustache/TemplateLoader.h
Outdated
| } | ||
|
|
||
| virtual std::unique_ptr<ObjectFactory> assign(const std::string &class_name) { | ||
| std::string name = class_name; |
There was a problem hiding this comment.
seems like dead code here.
8e10ed3 to
f09be82
Compare
11cf1e8 to
ed79c61
Compare
|
Is there an estimate as to when this can be merged? |
CMakeLists.txt
Outdated
|
|
||
| ## Bustache/template extensions | ||
| option(DISABLE_BUSTACHE "Disables Bustache (ApplyTemplate) support." OFF) | ||
| if (NOT DISABLE_BUSTACHE) |
There was a problem hiding this comment.
Let's make this ENABLE_BUSTACHE
ed79c61 to
98089ca
Compare
4cc44a8 to
40f9237
Compare
54cbeb6 to
b7fcca1
Compare
b7fcca1 to
ac18494
Compare
| endif() | ||
|
|
||
| ## Bustache/template extensions | ||
| option(ENABLE_BUSTACHE "Enables Bustache (ApplyTemplate) support." OFF) |
There was a problem hiding this comment.
Your conditional is DISABLE_BUSTACHE. Your option is ENABLE_BUSTACHE. It seems to only be enabled if you DISABLE_BUSTACHE per the conditional below?
There was a problem hiding this comment.
Ah, my bad. Fixing that uncovered a missing include, but both issues are resolved in the latest push.
There was a problem hiding this comment.
Thanks. I'll merge shortly
edit: I'll wait for travis. I had a build failure on my mac:
/Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits:4291:23: error: calling 'operator()' with incomplete return type 'bustache::value'
_LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/include/c++/v1/__config:392:15: note: expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits:4188:23: note: expanded from macro '_LIBCPP_INVOKE_RETURN'
noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) \
^~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits:4308:9: note: in instantiation of exception specification for '__invoke<std::__1::function<bustache::value (const std::__1::vector<bustache::ast::content,
std::__1::allocator<bustache::ast::content> > &)> &, const std::__1::vector<bustache::ast::content, std::__1::allocator<bustache::ast::content> > &>' requested here
_VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/__config:392:15: note: expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/functional:1591:33: note: in instantiation of template class 'std::__1::__invokable_r<void, std::__1::function<bustache::value (const std::__1::vector<bustache::ast::content,
std::__1::allocator<bustache::ast::content> > &)> &, const std::__1::vector<bustache::ast::content, std::__1::allocator<bustache::ast::content> > &>' requested here
__invokable<_Fp&, _ArgTypes...>::value>
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/functional:1616:9: note: in instantiation of default argument for '__callable<std::__1::function<bustache::value (const std::__1::vector<bustache::ast::content,
std::__1::allocator<bustache::ast::content> > &)> >' required here
__callable<_Fp>::value && !is_same<_Fp, function>::value
^~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/include/c++/v1/functional:1618:5: note: in instantiation of default argument for 'function<std::__1::function<bustache::value (const std::__1::vector<bustache::ast::content,
std::__1::allocator<bustache::ast::content> > &)> >' required here
function(_Fp);
^~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/include/c++/v1/functional:1578:28: note: while substituting deduced template arguments into function template 'function' [with _Fp = std::__1::function<bustache::value (const
std::__1::vector<bustache::ast::content, std::__1::allocator<bustache::ast::content> > &)>, $1 = (no value)]
class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/functional:1670:9: note: 'operator()' declared here
_Rp operator()(_ArgTypes...) const;
^
/Users/mparisi/code/apache/nifi-minifi-cpp/thirdparty/bustache/include/bustache/model.hpp:56:11: note: definition of 'bustache::value' is not complete until the closing '}'
class value : public variant_base<value>
^
6c72d27 to
acae2d3
Compare
|
@calebj change your root env in travis to be
Unless this is a linux only extension. Is it? If it is you'll have to include the previous CMAKE_BUILD_OPTIONS. As it is now linux is ignoring PCAP because you defined it in linux and overwrote the env option. |
|
@calebj I saw that your Travis imp run didn't build bustache, so I tried it myself. I added global to the root env https://github.com/phrocker/nifi-minifi-cpp/blob/ApplyTemplate/.travis.yml It seemed to run and build it. I then noticed Travis passed while my build continues to Fail. Would you be okay adding A "Known Issues" referencing https://bugs.llvm.org/show_bug.cgi?id=34298 in regards to bustache not building on certain versions of os x? @apiri have any thoughts on this? |
4d514f6 to
c9e4e90
Compare
|
@phrocker Sure, I'll do that when I get a chance to. |
bfcff1d to
0892bb5
Compare
Move ENABLE_BUSTACHE to travis root env This closes apache#157. Signed-off-by: Marc Parisi <phrocker@apache.org>
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 MINIFI-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 master)?
Is your initial contribution a single, squashed commit?
For code changes:
For documentation related changes:
Note:
Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.