-
-
Notifications
You must be signed in to change notification settings - Fork 14
JSONL streaming with GZIP support #2357
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
Binary file not shown.
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,126 @@ | ||
| if(NOT ZLIB_FOUND) | ||
| set(ZLIB_DIR "${PROJECT_SOURCE_DIR}/vendor/zlib") | ||
| set(ZLIB_PUBLIC_HEADER "${ZLIB_DIR}/zlib.h") | ||
| set(ZLIB_PRIVATE_HEADERS "${ZLIB_DIR}/zconf.h") | ||
|
|
||
| add_library(zlib | ||
| "${ZLIB_PUBLIC_HEADER}" ${ZLIB_PRIVATE_HEADERS} | ||
| "${ZLIB_DIR}/adler32.c" | ||
| "${ZLIB_DIR}/compress.c" | ||
| "${ZLIB_DIR}/crc32.c" | ||
| "${ZLIB_DIR}/crc32.h" | ||
| "${ZLIB_DIR}/deflate.c" | ||
| "${ZLIB_DIR}/deflate.h" | ||
| "${ZLIB_DIR}/gzclose.c" | ||
| "${ZLIB_DIR}/gzguts.h" | ||
| "${ZLIB_DIR}/gzlib.c" | ||
| "${ZLIB_DIR}/gzread.c" | ||
| "${ZLIB_DIR}/gzwrite.c" | ||
| "${ZLIB_DIR}/infback.c" | ||
| "${ZLIB_DIR}/inffast.c" | ||
| "${ZLIB_DIR}/inffast.h" | ||
| "${ZLIB_DIR}/inffixed.h" | ||
| "${ZLIB_DIR}/inflate.c" | ||
| "${ZLIB_DIR}/inflate.h" | ||
| "${ZLIB_DIR}/inftrees.c" | ||
| "${ZLIB_DIR}/inftrees.h" | ||
| "${ZLIB_DIR}/trees.c" | ||
| "${ZLIB_DIR}/trees.h" | ||
| "${ZLIB_DIR}/uncompr.c" | ||
| "${ZLIB_DIR}/zutil.c" | ||
| "${ZLIB_DIR}/zutil.h") | ||
|
|
||
| target_compile_definitions(zlib PUBLIC NO_FSEEKO) | ||
| target_compile_definitions(zlib PUBLIC _LARGEFILE64_SOURCE=1) | ||
|
|
||
| if(SOURCEMETA_COMPILER_MSVC) | ||
| target_compile_options(zlib PRIVATE /W3 /MP /wd4996) | ||
| target_compile_definitions(zlib PRIVATE _CRT_SECURE_NO_WARNINGS) | ||
| else() | ||
| target_compile_options(zlib PRIVATE | ||
| -Wall | ||
| -Wextra | ||
| -Wpedantic | ||
| -Werror | ||
| -Wdouble-promotion | ||
| -Wfloat-equal | ||
| -Wmissing-declarations | ||
| -Wshadow | ||
| -Wwrite-strings | ||
| -Wno-cast-align | ||
| -Wno-cast-qual | ||
| -Wno-format-nonliteral | ||
| -Wno-sign-conversion | ||
| -Wno-shorten-64-to-32 | ||
| -Wno-implicit-int-conversion | ||
| -Wno-comma | ||
| -Wno-implicit-fallthrough) | ||
|
|
||
| if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
| target_compile_options(zlib PRIVATE | ||
| -funroll-loops | ||
| -fstrict-aliasing | ||
| -ftree-vectorize | ||
| -fno-math-errno | ||
| -fwrapv) | ||
| endif() | ||
|
|
||
| # Disable LTO for zlib to work around GCC LTO linker plugin not | ||
| # properly rescanning this archive for transitive dependencies | ||
| if(SOURCEMETA_COMPILER_GCC) | ||
| target_compile_options(zlib PRIVATE -fno-lto) | ||
| endif() | ||
| endif() | ||
|
|
||
| target_include_directories(zlib PUBLIC | ||
| "$<BUILD_INTERFACE:${ZLIB_DIR}>" | ||
| "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>") | ||
|
|
||
| add_library(ZLIB::ZLIB ALIAS zlib) | ||
|
|
||
| set_target_properties(zlib | ||
| PROPERTIES | ||
| OUTPUT_NAME zlib | ||
| PUBLIC_HEADER "${ZLIB_PUBLIC_HEADER}" | ||
| PRIVATE_HEADER "${ZLIB_PRIVATE_HEADERS}" | ||
| C_STANDARD 11 | ||
| C_STANDARD_REQUIRED ON | ||
| C_EXTENSIONS OFF | ||
| POSITION_INDEPENDENT_CODE ON | ||
| C_VISIBILITY_PRESET "default" | ||
| C_VISIBILITY_INLINES_HIDDEN FALSE | ||
| VISIBILITY_INLINES_HIDDEN OFF | ||
| WINDOWS_EXPORT_ALL_SYMBOLS TRUE | ||
| EXPORT_NAME ZLIB) | ||
|
|
||
| if(SOURCEMETA_CORE_INSTALL) | ||
| include(GNUInstallDirs) | ||
| install(TARGETS zlib | ||
| EXPORT zlib | ||
| PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" | ||
| COMPONENT sourcemeta_core_dev | ||
| PRIVATE_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" | ||
| COMPONENT sourcemeta_core_dev | ||
| RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" | ||
| COMPONENT sourcemeta_core | ||
| LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" | ||
| COMPONENT sourcemeta_core | ||
| NAMELINK_COMPONENT sourcemeta_core_dev | ||
| ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" | ||
| COMPONENT sourcemeta_core_dev) | ||
| install(EXPORT zlib | ||
| DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/zlib" | ||
| NAMESPACE ZLIB:: | ||
| COMPONENT sourcemeta_core_dev) | ||
|
|
||
| file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/zlib-config.cmake | ||
| "include(\"\${CMAKE_CURRENT_LIST_DIR}/zlib.cmake\")\n" | ||
| "check_required_components(\"zlib\")\n") | ||
| install(FILES | ||
| "${CMAKE_CURRENT_BINARY_DIR}/zlib-config.cmake" | ||
| DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/zlib" | ||
| COMPONENT sourcemeta_core_dev) | ||
| endif() | ||
|
|
||
| set(ZLIB_FOUND ON) | ||
| endif() | ||
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,46 @@ | ||
| #ifndef SOURCEMETA_CORE_GZIP_STREAMBUF_H_ | ||
| #define SOURCEMETA_CORE_GZIP_STREAMBUF_H_ | ||
|
|
||
| #ifndef SOURCEMETA_CORE_GZIP_EXPORT | ||
| #include <sourcemeta/core/gzip_export.h> | ||
| #endif | ||
|
|
||
| #include <istream> // std::istream | ||
| #include <memory> // std::unique_ptr | ||
| #include <streambuf> // std::streambuf | ||
|
|
||
| namespace sourcemeta::core { | ||
|
|
||
| /// @ingroup gzip | ||
| /// A stream buffer that performs streaming GZIP decompression (RFC 1952) over | ||
| /// an input stream. | ||
| class SOURCEMETA_CORE_GZIP_EXPORT GZIPStreamBuffer : public std::streambuf { | ||
| public: | ||
| GZIPStreamBuffer(std::istream &compressed_stream); | ||
| ~GZIPStreamBuffer() override; | ||
|
|
||
| GZIPStreamBuffer(const GZIPStreamBuffer &) = delete; | ||
| auto operator=(const GZIPStreamBuffer &) -> GZIPStreamBuffer & = delete; | ||
| GZIPStreamBuffer(GZIPStreamBuffer &&) = delete; | ||
| auto operator=(GZIPStreamBuffer &&) -> GZIPStreamBuffer & = delete; | ||
|
|
||
| protected: | ||
| auto underflow() -> int_type override; | ||
|
|
||
| private: | ||
| // Exporting symbols that depends on the standard C++ library is considered | ||
| // safe. | ||
| // https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4275?view=msvc-170&redirectedfrom=MSDN | ||
| #if defined(_MSC_VER) | ||
| #pragma warning(disable : 4251) | ||
| #endif | ||
| struct Internal; | ||
| std::unique_ptr<Internal> internal; | ||
| #if defined(_MSC_VER) | ||
| #pragma warning(default : 4251) | ||
| #endif | ||
| }; | ||
|
|
||
| } // namespace sourcemeta::core | ||
|
|
||
| #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.