Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions db/db_bloom_filter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4288,6 +4288,9 @@ TEST_F(DBBloomFilterTest, FixedWidthSegments) {
auto extractor4b0b = MakeSharedCappedKeySegmentsExtractor({4, 0});
auto extractor4b0b4b = MakeSharedCappedKeySegmentsExtractor({4, 0, 4});
auto extractor1b3b0b4b = MakeSharedCappedKeySegmentsExtractor({1, 3, 0, 4});
// More than 6 segments uses a different implementation
auto extractor1b2b0b1b1b1b1b =
MakeSharedCappedKeySegmentsExtractor({1, 2, 0, 1, 1, 1, 1});

ASSERT_EQ(extractor_none->GetId(), "CappedKeySegmentsExtractor");
ASSERT_EQ(extractor0b->GetId(), "CappedKeySegmentsExtractor0b");
Expand All @@ -4296,6 +4299,8 @@ TEST_F(DBBloomFilterTest, FixedWidthSegments) {
ASSERT_EQ(extractor4b0b->GetId(), "CappedKeySegmentsExtractor4b0b");
ASSERT_EQ(extractor4b0b4b->GetId(), "CappedKeySegmentsExtractor4b0b4b");
ASSERT_EQ(extractor1b3b0b4b->GetId(), "CappedKeySegmentsExtractor1b3b0b4b");
ASSERT_EQ(extractor1b2b0b1b1b1b1b->GetId(),
"CappedKeySegmentsExtractor1b2b0b1b1b1b1b");

using V = std::vector<int>;
ASSERT_EQ(V({}), ExtractedSizes(*extractor_none, {}));
Expand Down Expand Up @@ -4332,6 +4337,15 @@ TEST_F(DBBloomFilterTest, FixedWidthSegments) {
ASSERT_EQ(V({4, 0, 4}), ExtractedSizes(*extractor4b0b4b, "blah12345"));
ASSERT_EQ(V({1, 3, 0, 4}), ExtractedSizes(*extractor1b3b0b4b, "blah12345"));

ASSERT_EQ(V({0, 0, 0, 0, 0, 0, 0}),
ExtractedSizes(*extractor1b2b0b1b1b1b1b, {}));
ASSERT_EQ(V({1, 2, 0, 1, 0, 0, 0}),
ExtractedSizes(*extractor1b2b0b1b1b1b1b, "blah"));
ASSERT_EQ(V({1, 2, 0, 1, 1, 1, 1}),
ExtractedSizes(*extractor1b2b0b1b1b1b1b, "blah123"));
ASSERT_EQ(V({1, 2, 0, 1, 1, 1, 1}),
ExtractedSizes(*extractor1b2b0b1b1b1b1b, "blah12345"));

// Filter config for second and fourth segment
auto filter1 =
MakeSharedReverseBytewiseMinMaxSQFC(experimental::SelectKeySegment(1));
Expand Down
1 change: 1 addition & 0 deletions db/experimental.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ class DynamicCappedKeySegmentsExtractor : public KeySegmentsExtractor {
public:
DynamicCappedKeySegmentsExtractor(const std::vector<uint32_t>& byte_widths) {
id_ = kName();
ideal_ends_.resize(byte_widths.size());
uint32_t prev_end = 0;
for (size_t i = 0; i < byte_widths.size(); ++i) {
prev_end = prev_end + byte_widths[i];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed a crash in experimental `MakeSharedCappedKeySegmentsExtractor()` with more than 6 byte widths: the extractor wrote the segment ends into an empty vector.