Skip to content

Commit 46e15ab

Browse files
committed
[test](be) Exercise keyword norms with leaf posting bounds
Problem Summary: The general postings mock inherits unsupported multi-reader block-bound methods. Use a leaf mock to validate keyword norm and WAND defaults across partitions. Tests: affected ASAN suites; production code unchanged. Release note: none. Behavior changed: no. Documentation: not required.
1 parent 0a676c1 commit 46e15ab

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

‎be/test/storage/index/inverted/query/engine/segment_postings_test.cpp‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,9 +1282,20 @@ TEST_F(SegmentPostingsTest, test_segment_postings_base_constructor_next_true) {
12821282
EXPECT_EQ(base.norm(), 1);
12831283
}
12841284

1285+
// A leaf cursor exposes block bounds; the general mock deliberately inherits the
1286+
// unsupported multi-reader bound methods and cannot exercise keyword WAND defaults.
1287+
class KeywordTermDocs final : public MockTermDocs {
1288+
public:
1289+
using MockTermDocs::MockTermDocs;
1290+
int32_t getLastDocInBlock() override { return static_cast<int32_t>(_docs.back()); }
1291+
int32_t getMaxBlockFreq() override { return -1; }
1292+
int32_t getMaxBlockNorm() override { return -1; }
1293+
};
1294+
12851295
TEST_F(SegmentPostingsTest, KeywordPostingsUseUnitNorm) {
12861296
ClucenePostingsCursor::Partition part {
1287-
.iter = TermDocsPtr(new MockTermDocs({1, 3}, {1, 1}, {0, 0}, 2)), .has_norms = false};
1297+
.iter = TermDocsPtr(new KeywordTermDocs({1, 3}, {1, 1}, {0, 0}, 2)),
1298+
.has_norms = false};
12881299
auto cursor = std::make_unique<ClucenePostingsCursor>(std::move(part));
12891300
auto similarity = std::make_shared<BM25Similarity>(2.0F, 1.0F);
12901301
SegmentPostings postings(std::move(cursor), true, similarity);
@@ -1299,7 +1310,7 @@ TEST_F(SegmentPostingsTest, KeywordPostingsUseUnitNorm) {
12991310
TEST_F(SegmentPostingsTest, KeywordNormSurvivesPartitionSwitch) {
13001311
std::vector<ClucenePostingsCursor::Partition> parts;
13011312
for (uint32_t base : {0, 10}) {
1302-
parts.push_back({.iter = TermDocsPtr(new MockTermDocs({1}, {1}, {0}, 1)),
1313+
parts.push_back({.iter = TermDocsPtr(new KeywordTermDocs({1}, {1}, {0}, 1)),
13031314
.begin = base,
13041315
.end = base + 10,
13051316
.has_norms = false});

0 commit comments

Comments
 (0)