Skip to content

Commit d11ac9d

Browse files
committed
address comments
1 parent 4627a74 commit d11ac9d

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

src/iceberg/test/struct_like_set_test.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,17 @@ TEST(StructLikeSetTest, InsertAndContains) {
154154
EXPECT_THAT(set.Contains(row3), HasValue(::testing::Eq(false)));
155155
}
156156

157+
TEST(StructLikeSetTest, InsertAndContainsWithCustomArenaInitialSize) {
158+
auto type = MakeStructType({{"id", int32()}, {"name", string()}});
159+
StructLikeSet set(type, 8);
160+
161+
std::string name = "alice";
162+
SimpleStructLike row({Scalar{int32_t{1}}, Scalar{std::string_view(name)}});
163+
164+
ASSERT_THAT(set.Insert(row), IsOk());
165+
EXPECT_THAT(set.Contains(row), HasValue(::testing::Eq(true)));
166+
}
167+
157168
TEST(StructLikeSetTest, DuplicateInsert) {
158169
auto type = MakeStructType({{"id", int32()}});
159170
StructLikeSet set(type);

src/iceberg/util/struct_like_set.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ std::string_view ScalarTypeName(const Scalar& scalar) {
216216
[](int64_t) -> std::string_view { return "int64"; },
217217
[](float) -> std::string_view { return "float"; },
218218
[](double) -> std::string_view { return "double"; },
219-
[](std::string_view) -> std::string_view { return "string_view"; },
219+
[](std::string_view) -> std::string_view { return "string"; },
220220
[](const Decimal&) -> std::string_view { return "decimal"; },
221221
[](const std::shared_ptr<StructLike>&) -> std::string_view { return "struct"; },
222222
[](const std::shared_ptr<ArrayLike>&) -> std::string_view { return "list"; },
@@ -467,7 +467,8 @@ Result<bool> ScalarEqual(const Scalar& lhs, const Scalar& rhs) {
467467
} // namespace
468468

469469
template <bool kValidate>
470-
StructLikeSet<kValidate>::StructLikeSet(const StructType& type) {
470+
StructLikeSet<kValidate>::StructLikeSet(const StructType& type, size_t arena_initial_size)
471+
: arena_(arena_initial_size) {
471472
field_types_.reserve(type.fields().size());
472473
for (const auto& field : type.fields()) {
473474
field_types_.push_back(field.type());

src/iceberg/util/struct_like_set.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ namespace iceberg {
4747
template <bool kValidate = true>
4848
class ICEBERG_TEMPLATE_CLASS_EXPORT StructLikeSet {
4949
public:
50+
static constexpr size_t kDefaultArenaInitialSize = 64 * 1024;
51+
5052
/// \brief Create a StructLikeSet for the given struct type.
51-
explicit StructLikeSet(const StructType& type);
53+
explicit StructLikeSet(const StructType& type,
54+
size_t arena_initial_size = kDefaultArenaInitialSize);
5255

5356
~StructLikeSet();
5457

@@ -94,7 +97,7 @@ class ICEBERG_TEMPLATE_CLASS_EXPORT StructLikeSet {
9497
std::string_view CopyToArena(std::string_view src) const;
9598

9699
std::vector<std::shared_ptr<Type>> field_types_;
97-
mutable std::pmr::monotonic_buffer_resource arena_{64 * 1024};
100+
mutable std::pmr::monotonic_buffer_resource arena_;
98101
std::unordered_set<std::unique_ptr<StructLike>, KeyHash, KeyEqual> set_;
99102
};
100103

0 commit comments

Comments
 (0)