-
Notifications
You must be signed in to change notification settings - Fork 76
added Avro support for KafkaAdapter #645
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
Open
mildek
wants to merge
12
commits into
main
Choose a base branch
from
feat/add-kafka-avro-protocol
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+4,303
−432
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e3ea18f
added Avro support for KafkaAdapter
mildek 8ce67ec
Merge remote-tracking branch 'origin/main' into feat/add-kafka-avro-p…
mildek 7396b22
ruffed scripts
mildek aa8a87b
conditionally skip avro installation for arm macos
mildek 7eaf32a
fixed bugs, enabled osx-arm wheel
mildek 1f4ab48
fix: linted docs
mildek 26b6b99
fix: add /utf-8 flag for Windows MSVC builds
mildek cbdb742
fix: add workaround for avro-cpp fmt::formatter incompatibility on Wi…
mildek 63bfb8b
fix: pin fmt to v11.x for avro-cpp compatibility on Windows
mildek e0d5cd9
fix: workaround for avro-cpp fmt formatter on Windows instead of pinning
mildek e9d65cb
fix: workaround for avro-cpp fmt formatter on Windows
mildek acd75a1
fix: patch avro-cpp headers at configure time for fmt v12 compatibili…
mildek 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ channels: | |
| - nodefaults | ||
| dependencies: | ||
| - astor | ||
| - avrocpp | ||
| - bison | ||
| - brotli | ||
| - bump-my-version | ||
|
|
||
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,109 @@ | ||
| find_path(Avro_INCLUDE_DIR NAMES avro/Encoder.hh) | ||
| find_library(Avro_LIBRARY NAMES avrocpp libavrocpp) | ||
|
|
||
| # ============================================================================= | ||
| # Workaround for conda-forge avro-cpp fmt::formatter incompatibility on Windows | ||
| # ============================================================================= | ||
| # conda-forge's avro-cpp has fmt::formatter specializations with non-const | ||
| # format() methods, but fmt v12+ requires const. This causes MSVC error C2766. | ||
| # | ||
| # Solution: On Windows, we check if the avro headers have this bug, and if so, | ||
| # we create patched versions in the build directory and prepend them to the | ||
| # include path so they shadow the broken originals. | ||
| # | ||
| # This workaround can be removed once conda-forge updates avro-cpp. | ||
| # ============================================================================= | ||
|
|
||
| set(CSP_AVRO_PATCHED_INCLUDE_DIR "") | ||
|
|
||
| if(WIN32 AND Avro_INCLUDE_DIR AND NOT CSP_USE_VCPKG) | ||
| # Check if avro/Node.hh has the non-const format() bug | ||
| # The buggy pattern is: "auto format(...) {" without "const" before the brace | ||
| set(_avro_node_hh "${Avro_INCLUDE_DIR}/avro/Node.hh") | ||
| set(_avro_types_hh "${Avro_INCLUDE_DIR}/avro/Types.hh") | ||
| set(_needs_patching FALSE) | ||
|
|
||
| if(EXISTS "${_avro_node_hh}") | ||
| file(READ "${_avro_node_hh}" _node_hh_content) | ||
|
|
||
| # Check if the file contains fmt::formatter and non-const format() | ||
| # We look for "auto format" followed by ")" then whitespace then "{" | ||
| # without "const" in between | ||
| string(FIND "${_node_hh_content}" "fmt::formatter<avro::Name>" _has_formatter) | ||
| if(NOT _has_formatter EQUAL -1) | ||
| # Check specifically for the non-const pattern | ||
| # Buggy: auto format(const avro::Name &n, FormatContext &ctx) { | ||
| # Fixed: auto format(const avro::Name &n, FormatContext &ctx) const { | ||
| string(REGEX MATCH "auto format\\(const avro::Name[^)]+\\)[^c]*\\{" _buggy_pattern "${_node_hh_content}") | ||
| if(_buggy_pattern) | ||
| set(_needs_patching TRUE) | ||
| endif() | ||
| endif() | ||
| endif() | ||
|
|
||
| if(_needs_patching) | ||
| message(STATUS "Detected avro-cpp with non-const fmt::formatter bug - applying build-time patch") | ||
|
|
||
| # Create patched headers directory structure | ||
| set(CSP_AVRO_PATCHED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/_patched_avro_headers") | ||
| set(_patched_avro_dir "${CSP_AVRO_PATCHED_INCLUDE_DIR}/avro") | ||
| file(MAKE_DIRECTORY "${_patched_avro_dir}") | ||
|
|
||
| # Patch Node.hh | ||
| # Replace: auto format(const avro::Name &n, FormatContext &ctx) { | ||
| # With: auto format(const avro::Name &n, FormatContext &ctx) const { | ||
| string(REGEX REPLACE | ||
| "(auto format\\(const avro::Name[^)]+\\))[ \t\r\n]*(\\{)" | ||
| "\\1 const \\2" | ||
| _patched_node_content | ||
| "${_node_hh_content}" | ||
| ) | ||
| file(WRITE "${_patched_avro_dir}/Node.hh" "${_patched_node_content}") | ||
| message(STATUS " Patched: avro/Node.hh -> ${_patched_avro_dir}/Node.hh") | ||
|
|
||
| # Patch Types.hh if it exists and has the same bug | ||
| if(EXISTS "${_avro_types_hh}") | ||
| file(READ "${_avro_types_hh}" _types_hh_content) | ||
| string(FIND "${_types_hh_content}" "fmt::formatter<avro::Type>" _has_type_formatter) | ||
| if(NOT _has_type_formatter EQUAL -1) | ||
| string(REGEX MATCH "auto format\\(avro::Type[^)]+\\)[^c]*\\{" _types_buggy "${_types_hh_content}") | ||
| if(_types_buggy) | ||
| string(REGEX REPLACE | ||
| "(auto format\\(avro::Type[^)]+\\))[ \t\r\n]*(\\{)" | ||
| "\\1 const \\2" | ||
| _patched_types_content | ||
| "${_types_hh_content}" | ||
| ) | ||
| file(WRITE "${_patched_avro_dir}/Types.hh" "${_patched_types_content}") | ||
| message(STATUS " Patched: avro/Types.hh -> ${_patched_avro_dir}/Types.hh") | ||
| endif() | ||
| endif() | ||
| endif() | ||
| endif() | ||
| endif() | ||
|
|
||
| if (NOT TARGET Avro::avrocpp) | ||
| add_library(Avro::avrocpp SHARED IMPORTED) | ||
|
|
||
| # On Windows, IMPORTED_IMPLIB is the .lib file, IMPORTED_LOCATION is the .dll | ||
| # On other platforms, IMPORTED_LOCATION is the shared library | ||
| if(WIN32) | ||
| set_property(TARGET Avro::avrocpp PROPERTY IMPORTED_IMPLIB "${Avro_LIBRARY}") | ||
| else() | ||
| set_property(TARGET Avro::avrocpp PROPERTY IMPORTED_LOCATION "${Avro_LIBRARY}") | ||
| endif() | ||
|
|
||
| # If we have patched headers, prepend them to include path so they shadow originals | ||
| if(CSP_AVRO_PATCHED_INCLUDE_DIR) | ||
| target_include_directories(Avro::avrocpp INTERFACE | ||
| ${CSP_AVRO_PATCHED_INCLUDE_DIR} # Patched headers first (shadows originals) | ||
| ${Avro_INCLUDE_DIR} # Original headers for everything else | ||
| ) | ||
| else() | ||
| target_include_directories(Avro::avrocpp INTERFACE ${Avro_INCLUDE_DIR}) | ||
| endif() | ||
| endif() | ||
|
|
||
| include(FindPackageHandleStandardArgs) | ||
| find_package_handle_standard_args(Avro DEFAULT_MSG Avro_LIBRARY Avro_INCLUDE_DIR) | ||
| mark_as_advanced(Avro_INCLUDE_DIR Avro_LIBRARY Avro::avrocpp) |
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,18 @@ | ||
| #ifndef _IN_CSP_ADAPTERS_UTILS_AVROINCLUDES_H | ||
| #define _IN_CSP_ADAPTERS_UTILS_AVROINCLUDES_H | ||
|
|
||
| // Centralized avro includes. | ||
| // On Windows conda-forge builds, headers are patched at CMake configure time | ||
| // (see FindAvro.cmake) to fix fmt v12 compatibility. | ||
|
|
||
| #include <avro/Compiler.hh> | ||
| #include <avro/Decoder.hh> | ||
| #include <avro/Encoder.hh> | ||
| #include <avro/Generic.hh> | ||
| #include <avro/GenericDatum.hh> | ||
| #include <avro/Node.hh> | ||
| #include <avro/Schema.hh> | ||
| #include <avro/Stream.hh> | ||
| #include <avro/ValidSchema.hh> | ||
|
|
||
| #endif |
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.
Uh oh!
There was an error while loading. Please reload this page.