Skip to content

Commit 9f1be10

Browse files
committed
Non-functional OpenZL prototype
1 parent 598077e commit 9f1be10

File tree

9 files changed

+842
-0
lines changed

9 files changed

+842
-0
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ if(ENABLE_ROARING_TESTS AND BASH AND NOT EMSCRIPTEN)
163163
else()
164164
message(STATUS "Amalgamation tests disabled")
165165
endif()
166+
option(ROARING_OPENZL "Enable OpenZL integration" OFF)
167+
if(ROARING_OPENZL)
168+
add_subdirectory(openzl)
169+
endif()
170+
166171
option(ENABLE_ROARING_MICROBENCHMARKS "Enable microbenchmarks" OFF)
167172
if(ENABLE_ROARING_MICROBENCHMARKS)
168173
add_subdirectory(microbenchmarks)

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Portable Roaring bitmaps in C (and C++) with full support for your favorite comp
4040
- [Mailing list/discussion group](#mailing-listdiscussion-group)
4141
- [Contributing](#contributing)
4242
- [References about Roaring](#references-about-roaring)
43+
- [OpenZL Integration](#openzl-integration)
4344

4445
# Introduction
4546

@@ -1189,6 +1190,27 @@ A compiler or static-analyzer warning is not a bug. Do not report such cases as
11891190

11901191
[![Star History Chart](https://api.star-history.com/svg?repos=RoaringBitmap/CRoaring&type=Date)](https://www.star-history.com/#RoaringBitmap/CRoaring&Date)
11911192

1193+
# OpenZL Integration
1194+
1195+
The `openzl/` subdirectory provides an [OpenZL](https://github.com/facebook/openzl) integration with an SDDL description of the [Roaring Bitmap serialization format](https://github.com/RoaringBitmap/RoaringFormatSpec). This enables format-aware compression of serialized Roaring Bitmap data using OpenZL's specialized compressor.
1196+
1197+
To enable OpenZL support, set the `ROARING_OPENZL` flag during configuration:
1198+
1199+
```
1200+
cmake -DROARING_OPENZL=ON -B build
1201+
```
1202+
1203+
The SDDL file (`openzl/roaring.sddl`) describes the portable Roaring Bitmap binary format, including:
1204+
1205+
- Cookie-based format detection (with and without run containers)
1206+
- Container descriptors (key + cardinality)
1207+
- All three container types: array, bitset, and run-length encoded
1208+
- Offset headers for random access
1209+
1210+
See the [SDDL documentation](https://openzl.org/sddl/) for more on the format description language.
1211+
1212+
1213+
11921214
# References about Roaring
11931215

11941216
- Daniel Lemire, Owen Kaser, Nathan Kurz, Luca Deri, Chris O'Hara, François Saint-Jacques, Gregory Ssi-Yan-Kai, Roaring Bitmaps: Implementation of an Optimized Software Library, Software: Practice and Experience Volume 48, Issue 4 April 2018 Pages 867-895 [arXiv:1709.07821](https://arxiv.org/abs/1709.07821)

openzl/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
set(OPENZL_BUILD_TOOLS ON CACHE BOOL "Build OpenZL tools (needed for SDDL compiler)" FORCE)
2+
3+
CPMAddPackage(
4+
NAME openzl
5+
GIT_REPOSITORY https://github.com/facebook/openzl.git
6+
GIT_TAG 35300cebf0bca276fae7034aa511045df0de1936
7+
)
8+
9+
if(ENABLE_ROARING_TESTS)
10+
add_subdirectory(test)
11+
endif()
12+
13+
add_subdirectory(compression_benchmark)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
set(SDDL_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/../roaring.sddl")
2+
set(SDDL_COMPILED "${CMAKE_CURRENT_BINARY_DIR}/roaring_sddl.bin")
3+
set(SDDL_HEADER "${CMAKE_CURRENT_BINARY_DIR}/roaring_sddl.h")
4+
5+
# Compile the SDDL source to binary using the sddl_compiler tool.
6+
add_custom_command(
7+
OUTPUT ${SDDL_COMPILED}
8+
COMMAND sddl_compiler < ${SDDL_SOURCE} > ${SDDL_COMPILED}
9+
DEPENDS ${SDDL_SOURCE} sddl_compiler
10+
COMMENT "Compiling roaring.sddl"
11+
)
12+
13+
# Generate a C header embedding the compiled SDDL as a byte array.
14+
add_custom_command(
15+
OUTPUT ${SDDL_HEADER}
16+
COMMAND ${CMAKE_COMMAND}
17+
-DINPUT_FILE=${SDDL_COMPILED}
18+
-DOUTPUT_FILE=${SDDL_HEADER}
19+
-DARRAY_NAME=roaring_sddl_compiled
20+
-DSIZE_NAME=roaring_sddl_compiled_size
21+
-DGUARD_NAME=ROARING_SDDL_H
22+
-P ${CMAKE_CURRENT_SOURCE_DIR}/bin2header.cmake
23+
DEPENDS ${SDDL_COMPILED}
24+
COMMENT "Generating roaring_sddl.h"
25+
)
26+
27+
add_executable(compression_benchmark compression_benchmark.c ${SDDL_HEADER})
28+
target_link_libraries(compression_benchmark roaring openzl sddl_profile)
29+
target_include_directories(compression_benchmark PRIVATE
30+
${PROJECT_SOURCE_DIR}/include
31+
${PROJECT_SOURCE_DIR}/cpp
32+
${CMAKE_CURRENT_BINARY_DIR}
33+
${openzl_SOURCE_DIR}
34+
)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
file(READ "${INPUT_FILE}" CONTENT HEX)
2+
string(LENGTH "${CONTENT}" HEX_LEN)
3+
math(EXPR BYTE_COUNT "${HEX_LEN} / 2")
4+
5+
set(OUTPUT "/* Auto-generated — do not edit. */\n")
6+
string(APPEND OUTPUT "#ifndef ${GUARD_NAME}\n")
7+
string(APPEND OUTPUT "#define ${GUARD_NAME}\n\n")
8+
string(APPEND OUTPUT "#include <stddef.h>\n\n")
9+
string(APPEND OUTPUT "static const unsigned char ${ARRAY_NAME}[] = {\n")
10+
11+
set(POS 0)
12+
set(LINE " ")
13+
set(COL 0)
14+
while(POS LESS HEX_LEN)
15+
string(SUBSTRING "${CONTENT}" ${POS} 2 BYTE)
16+
math(EXPR POS "${POS} + 2")
17+
if(POS LESS HEX_LEN)
18+
string(APPEND LINE "0x${BYTE}, ")
19+
else()
20+
string(APPEND LINE "0x${BYTE}")
21+
endif()
22+
math(EXPR COL "${COL} + 1")
23+
if(COL EQUAL 12)
24+
string(APPEND OUTPUT "${LINE}\n")
25+
set(LINE " ")
26+
set(COL 0)
27+
endif()
28+
endwhile()
29+
30+
if(COL GREATER 0)
31+
string(APPEND OUTPUT "${LINE}\n")
32+
endif()
33+
34+
string(APPEND OUTPUT "};\n\n")
35+
string(APPEND OUTPUT "static const size_t ${SIZE_NAME} = ${BYTE_COUNT};\n\n")
36+
string(APPEND OUTPUT "#endif /* ${GUARD_NAME} */\n")
37+
38+
file(WRITE "${OUTPUT_FILE}" "${OUTPUT}")

0 commit comments

Comments
 (0)