Skip to content

Commit 36b5887

Browse files
authored
feat: add StructLikeSet (#598)
Adds StructLikeSet<bool kValidate = true>, a hash set for StructLike rows backed by an internal arena allocator. Key design points: - Deep-copies inserted rows into a monotonic_buffer_resource arena; string data and nested struct/list/map scalars are fully materialized so the set owns its memory independently of the caller - Transparent heterogeneous lookup: Contains() does not allocate a temporary key - Hash and equality semantics match the Java reference implementation (String.hashCode, StructLikeHash, ListHash; float/double use canonical NaN bits and distinguish ±0.0) - Schema validation (field count + scalar type) on Insert/Contains; can be disabled via kValidate=false (UncheckedStructLikeSet) when the caller guarantees conformance - Internal Arena wrapper containers use std::pmr::vector
1 parent 181fc8a commit 36b5887

8 files changed

Lines changed: 1163 additions & 1 deletion

File tree

src/iceberg/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ set(ICEBERG_SOURCES
112112
util/property_util.cc
113113
util/snapshot_util.cc
114114
util/string_util.cc
115+
util/struct_like_set.cc
115116
util/temporal_util.cc
116117
util/timepoint.cc
117118
util/transform_util.cc

src/iceberg/iceberg_export.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,31 @@
2727
# else
2828
# define ICEBERG_EXPORT __declspec(dllimport)
2929
# endif
30-
#else // Not Windows
30+
31+
# define ICEBERG_TEMPLATE_EXPORT ICEBERG_EXPORT
32+
33+
// For template class declarations. Empty on MSVC: dllexport on a class template
34+
// declaration combined with extern template triggers C4910.
35+
# if defined(_MSC_VER)
36+
# define ICEBERG_TEMPLATE_CLASS_EXPORT
37+
# else
38+
# define ICEBERG_TEMPLATE_CLASS_EXPORT ICEBERG_EXPORT
39+
# endif
40+
41+
// For extern template declarations. Empty when building the DLL on MSVC:
42+
// `extern` + `dllexport` is contradictory and triggers C4910.
43+
# if defined(_MSC_VER) && defined(ICEBERG_EXPORTING) && !defined(ICEBERG_STATIC)
44+
# define ICEBERG_EXTERN_TEMPLATE_CLASS_EXPORT
45+
# else
46+
# define ICEBERG_EXTERN_TEMPLATE_CLASS_EXPORT ICEBERG_TEMPLATE_EXPORT
47+
# endif
48+
49+
#else // Non-Windows
3150
# ifndef ICEBERG_EXPORT
3251
# define ICEBERG_EXPORT __attribute__((visibility("default")))
3352
# endif
53+
54+
# define ICEBERG_TEMPLATE_EXPORT
55+
# define ICEBERG_TEMPLATE_CLASS_EXPORT ICEBERG_EXPORT
56+
# define ICEBERG_EXTERN_TEMPLATE_CLASS_EXPORT ICEBERG_TEMPLATE_EXPORT
3457
#endif

src/iceberg/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ iceberg_sources = files(
130130
'util/property_util.cc',
131131
'util/snapshot_util.cc',
132132
'util/string_util.cc',
133+
'util/struct_like_set.cc',
133134
'util/temporal_util.cc',
134135
'util/timepoint.cc',
135136
'util/transform_util.cc',

src/iceberg/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ add_iceberg_test(util_test
118118
roaring_position_bitmap_test.cc
119119
position_delete_index_test.cc
120120
string_util_test.cc
121+
struct_like_set_test.cc
121122
transform_util_test.cc
122123
truncate_util_test.cc
123124
url_encoder_test.cc

src/iceberg/test/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ iceberg_tests = {
9393
'position_delete_index_test.cc',
9494
'roaring_position_bitmap_test.cc',
9595
'string_util_test.cc',
96+
'struct_like_set_test.cc',
9697
'transform_util_test.cc',
9798
'truncate_util_test.cc',
9899
'url_encoder_test.cc',

0 commit comments

Comments
 (0)