-
Notifications
You must be signed in to change notification settings - Fork 99
MINIFICPP-2650 - Processor c api #1987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
63 commits
Select commit
Hold shift + click to select a range
90a053f
WIP processor c api
adamdebreceni 9fe5993
Compatibility layer
adamdebreceni b22bf17
Restructure
adamdebreceni dc482dd
Refactor
adamdebreceni c3576fa
Rebase fix
adamdebreceni 8379307
Remove unused
adamdebreceni ea86d3c
Add version verification
adamdebreceni 4335f67
remove getReference from Property
martinzink 1f49fd0
build fix
martinzink b3d1dcb
verification of c libraries
martinzink 655e00c
Rebase fix
adamdebreceni df2e68a
Simplified c metrics
adamdebreceni e00950d
Refactor llama.cpp extension to use the c api
adamdebreceni e3dff33
Fix build
adamdebreceni 995bed2
Build fix
adamdebreceni c8e6c67
Add attribute manipulation
adamdebreceni a8a8801
Handle read/write error
adamdebreceni d26a71f
Change full name delimiter to '::'
adamdebreceni e96f3a8
Fix rpm package, fix win build
adamdebreceni f41a437
Rebase fix
adamdebreceni 708febf
clang-tidy and linter fixes for processor-c-api (#6)
martinzink 5459c16
Windows build fix
adamdebreceni 7c96b73
Windows build fix
adamdebreceni 58a2ab5
Windows build fix
adamdebreceni b78342f
clang tidy fixes (#7)
martinzink a4a3e39
Windows text fix
adamdebreceni 085a60c
Windows text fix
adamdebreceni 55e7882
Remove some interfaces
adamdebreceni 56eb587
clang tidy fixes (#8)
martinzink 757b40d
MINIFICPP-2565 - Windows fix
adamdebreceni 6c59e27
Rebase fix
adamdebreceni f8b4c72
Review changes
adamdebreceni d16d754
MINIFICPP-2650 - Review changes
adamdebreceni 4fec52a
MINIFICPP-2650 - Rebase fix
adamdebreceni 8997d3a
MINIFICPP-2650 - Explicit extension init
adamdebreceni 425d9b5
MINIFICPP-2650 - Fix build
adamdebreceni 721d10d
MINIFICPP-2650 - Set processors to empty for non-c extensions
adamdebreceni 140208c
MINIFICPP-2650 - Simplify registration
adamdebreceni 4e538c4
MINIFICPP-2650 - Remove log functions from c api
adamdebreceni 7db7d89
MINIFICPP-2650 - Revert MinifiOoutputStreamWrite
adamdebreceni 7469594
MINIFICPP-2650 - Add missing include
adamdebreceni 2e63846
MINIFICPP-2650 - Readd level query method
adamdebreceni f101359
MINIFICPP-2650 - Clang tidy fix
adamdebreceni 40616dc
MINIFICPP-2650 - Rebase fix
adamdebreceni b046a25
MINIFICPP-2650 - Win fix
adamdebreceni e9dd092
MINIFICPP-2650 - Review changes
adamdebreceni 5b45168
MINIFICPP-2650 - Review changes
adamdebreceni 50ae439
MINIFICPP-2650 - Review changes
adamdebreceni cd13d65
MINIFICPP-2650 - Own strings, vectors in ClassDescription
adamdebreceni 87ae81e
MINIFICPP-2650 - Remove includes
adamdebreceni d6fae76
MINIFICPP-2650 - Review changes
adamdebreceni 992a58c
MINIFICPP-2650 - Review changes
adamdebreceni e6e9574
MINIFICPP-2650 - Revert
adamdebreceni c3cb41d
MINIFICPP-2650 - Review changes
adamdebreceni 312f3b2
MINIFICPP-2650 - Add missing include
adamdebreceni 6ac6709
MINIFICPP-2650 - Require api version for extension creation
adamdebreceni cc64669
MINIFICPP-2650 - Add comment, clang-tidy fix
adamdebreceni 755a7c0
MINIFICPP-2650 - Linter fix
adamdebreceni 174ce8b
MINIFICPP-2650 - Rename cpp framework
adamdebreceni a1e042f
MINIFICPP-2650 - Add missing include
adamdebreceni e47d479
MINIFICPP-2650 - Review changes
adamdebreceni 958dc2f
MINIFICPP-2650 - Fix build
adamdebreceni 4af23b2
MINIFICPP-2650 - Remove unused
adamdebreceni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| file(GLOB SOURCES | ||
| src/*.cpp | ||
| src/core/*.cpp | ||
| src/core/extension/*.cpp | ||
| src/io/*.cpp | ||
| src/http/*.cpp | ||
| src/utils/*.cpp | ||
| src/utils/crypto/*.cpp | ||
| src/utils/crypto/ciphers/*.cpp | ||
| src/utils/crypto/property_encryption/*.cpp | ||
| src/utils/net/*.cpp | ||
| src/utils/file/*.cpp) | ||
|
|
||
| add_minifi_library(minifi-core-framework-common STATIC ${SOURCES}) | ||
| target_include_directories(minifi-core-framework-common PUBLIC include) | ||
| target_link_libraries(minifi-core-framework-common PUBLIC minifi-api-common ZLIB::ZLIB concurrentqueue RapidJSON spdlog Threads::Threads gsl-lite libsodium range-v3 expected-lite date::date date::tz asio magic_enum OpenSSL::Crypto OpenSSL::SSL CURL::libcurl RapidJSON) | ||
| if(NOT WIN32) | ||
| target_link_libraries(minifi-core-framework-common PUBLIC OSSP::libuuid++) | ||
| endif() | ||
| if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9) | ||
| target_link_libraries(minifi-core-framework-common PUBLIC stdc++fs) | ||
| endif() |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /** | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| #pragma once | ||
|
|
||
| #include "minifi-cpp/utils/Id.h" | ||
| #include "utils/Hash.h" | ||
|
|
||
| namespace std { | ||
| template<> | ||
| struct hash<org::apache::nifi::minifi::utils::Identifier> { | ||
| size_t operator()(const org::apache::nifi::minifi::utils::Identifier& id) const noexcept { | ||
| static_assert(sizeof(org::apache::nifi::minifi::utils::Identifier) % sizeof(size_t) == 0); | ||
| constexpr int slices = sizeof(org::apache::nifi::minifi::utils::Identifier) / sizeof(size_t); | ||
| const auto get_slice = [](const org::apache::nifi::minifi::utils::Identifier& id, size_t idx) -> size_t { | ||
| size_t result{}; | ||
| memcpy(&result, reinterpret_cast<const unsigned char*>(&id.data_) + idx * sizeof(size_t), sizeof(size_t)); | ||
| return result; | ||
| }; | ||
| size_t hash = get_slice(id, 0); | ||
| for (size_t i = 1; i < slices; ++i) { | ||
| hash = org::apache::nifi::minifi::utils::hash_combine(hash, get_slice(id, i)); | ||
| } | ||
| return hash; | ||
| } | ||
| }; | ||
| } // namespace std |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /** | ||
| * | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <atlbase.h> | ||
| #include <atlconv.h> | ||
| #include <string> | ||
|
|
||
| namespace org::apache::nifi::minifi::utils { | ||
|
|
||
| inline std::string to_string(const std::wstring& utf16_string) { | ||
| ATL::CW2A utf8_string(utf16_string.c_str(), CP_UTF8); | ||
| return {LPSTR{utf8_string}}; | ||
| } | ||
|
|
||
| inline std::wstring to_wstring(const std::string& utf8_string) { | ||
| ATL::CA2W utf16_string(utf8_string.c_str(), CP_UTF8); | ||
| return {LPWSTR{utf16_string}}; | ||
| } | ||
|
|
||
| } // namespace org::apache::nifi::minifi::utils |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| /** | ||
| * | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| #include "minifi-cpp/utils/Id.h" | ||
|
|
||
| #include "utils/StringUtils.h" | ||
| #include "minifi-cpp/utils/gsl.h" | ||
|
|
||
| namespace org::apache::nifi::minifi::utils { | ||
|
|
||
| Identifier::Identifier(const Data& data) : data_(data) {} | ||
|
|
||
| Identifier& Identifier::operator=(const Data& data) { | ||
| data_ = data; | ||
| return *this; | ||
| } | ||
|
|
||
| Identifier& Identifier::operator=(const std::string& idStr) { | ||
| const auto id = Identifier::parse(idStr); | ||
| if (!id) { | ||
| throw std::runtime_error("Couldn't parse UUID"); | ||
| } | ||
| *this = id.value(); | ||
| return *this; | ||
| } | ||
|
|
||
| bool Identifier::isNil() const { | ||
| return *this == Identifier{}; | ||
| } | ||
|
|
||
| bool Identifier::operator!=(const Identifier& other) const { | ||
| return !(*this == other); | ||
| } | ||
|
|
||
| bool Identifier::operator==(const Identifier& other) const { | ||
| return data_ == other.data_; | ||
| } | ||
|
|
||
| bool Identifier::operator<(const Identifier &other) const { | ||
| return data_ < other.data_; | ||
| } | ||
|
|
||
| SmallString<36> Identifier::to_string() const { | ||
| SmallString<36> uuidStr; | ||
| // xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx is 36 long: 16 bytes * 2 hex digits / byte + 4 hyphens | ||
| int byteIdx = 0; | ||
| int charIdx = 0; | ||
|
|
||
| // [xxxxxxxx]-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ||
| while (byteIdx < 4) { | ||
| uuidStr[charIdx++] = hex_lut[data_[byteIdx] >> 4]; | ||
| uuidStr[charIdx++] = hex_lut[data_[byteIdx++] & 0xf]; | ||
| } | ||
| // xxxxxxxx[-]xxxx-xxxx-xxxx-xxxxxxxxxxxx | ||
| uuidStr[charIdx++] = '-'; | ||
|
|
||
| // xxxxxxxx-[xxxx-xxxx-xxxx-]xxxxxxxxxxxx - 3x 2 bytes and a hyphen | ||
| for (int idx = 0; idx < 3; ++idx) { | ||
| uuidStr[charIdx++] = hex_lut[data_[byteIdx] >> 4]; | ||
| uuidStr[charIdx++] = hex_lut[data_[byteIdx++] & 0xf]; | ||
| uuidStr[charIdx++] = hex_lut[data_[byteIdx] >> 4]; | ||
| uuidStr[charIdx++] = hex_lut[data_[byteIdx++] & 0xf]; | ||
| uuidStr[charIdx++] = '-'; | ||
| } | ||
|
|
||
| // xxxxxxxx-xxxx-xxxx-xxxx-[xxxxxxxxxxxx] - the rest, i.e. until byte 16 | ||
| while (byteIdx < 16) { | ||
| uuidStr[charIdx++] = hex_lut[data_[byteIdx] >> 4]; | ||
| uuidStr[charIdx++] = hex_lut[data_[byteIdx++] & 0xf]; | ||
| } | ||
|
|
||
| // null terminator | ||
| uuidStr[charIdx] = 0; | ||
| return uuidStr; | ||
| } | ||
|
|
||
| std::optional<Identifier> Identifier::parse(const std::string &str) { | ||
| Identifier id; | ||
| // xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx is 36 long: 16 bytes * 2 hex digits / byte + 4 hyphens | ||
| if (str.length() != 36) return {}; | ||
| int charIdx = 0; | ||
| int byteIdx = 0; | ||
| auto input = reinterpret_cast<const uint8_t*>(str.c_str()); | ||
|
|
||
| // [xxxxxxxx]-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ||
| while (byteIdx < 4) { | ||
| if (!parseByte(id.data_, input, charIdx, byteIdx)) return {}; | ||
| } | ||
| // xxxxxxxx[-]xxxx-xxxx-xxxx-xxxxxxxxxxxx | ||
| if (input[charIdx++] != '-') return {}; | ||
|
|
||
| // xxxxxxxx-[xxxx-xxxx-xxxx-]xxxxxxxxxxxx - 3x 2 bytes and a hyphen | ||
| for (size_t idx = 0; idx < 3; ++idx) { | ||
| if (!parseByte(id.data_, input, charIdx, byteIdx)) return {}; | ||
| if (!parseByte(id.data_, input, charIdx, byteIdx)) return {}; | ||
| if (input[charIdx++] != '-') return {}; | ||
| } | ||
|
|
||
| // xxxxxxxx-xxxx-xxxx-xxxx-[xxxxxxxxxxxx] - the rest, i.e. until byte 16 | ||
| while (byteIdx < 16) { | ||
| if (!parseByte(id.data_, input, charIdx, byteIdx)) return {}; | ||
| } | ||
| return id; | ||
| } | ||
|
|
||
| bool Identifier::parseByte(Data &data, const uint8_t *input, int &charIdx, int &byteIdx) { | ||
| uint8_t upper = 0; | ||
| uint8_t lower = 0; | ||
| if (!string::from_hex(input[charIdx], upper) | ||
| || !string::from_hex(input[charIdx + 1], lower)) { | ||
| return false; | ||
| } | ||
| charIdx += 2; | ||
martinzink marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| data[byteIdx++] = (upper << 4) | lower; | ||
| return true; | ||
| } | ||
|
|
||
| } // namespace org::apache::nifi::minifi::utils | ||
File renamed without changes.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add the export macros in the C API extensions and not export all symbols. CMake's GenerateExportHeader can make it simpler. At least that's the vision, but maybe there are blockers preventing this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this only has utility in tests where we directly link the test to (in this case)
libminifi-llamacpp.dll, since we are directly driving the processor in the test (not waiting for the extension to register the callbacks) we need access to all member function symbols