Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MBkkt committed Jul 26, 2023
1 parent 82fd5cd commit a95de2c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 34 deletions.
24 changes: 8 additions & 16 deletions core/search/nested_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,7 @@ class AnyMatcher : public Merger, private score_ctx {
ScoreFunction PrepareScore() {
static_assert(HasScore_v<Merger>);

return {*this,
[](score_ctx* ctx, score_t* res) noexcept {
return {*this, [](score_ctx* ctx, score_t* res) noexcept {
IRS_ASSERT(ctx);
IRS_ASSERT(res);
auto& self = static_cast<JoinType&>(*ctx);
Expand All @@ -295,8 +294,7 @@ class AnyMatcher : public Merger, private score_ctx {
child_score(merger.temp());
merger(res, merger.temp());
}
},
ScoreFunction::DefaultMin};
}};
}
};

Expand Down Expand Up @@ -361,16 +359,14 @@ class PredMatcher : public Merger,
ScoreFunction PrepareScore() noexcept {
static_assert(HasScore_v<Merger>);

return {*this,
[](score_ctx* ctx, score_t* res) noexcept {
return {*this, [](score_ctx* ctx, score_t* res) noexcept {
IRS_ASSERT(ctx);
IRS_ASSERT(res);
auto& self = static_cast<PredMatcher&>(*ctx);
auto& merger = static_cast<Merger&>(self);
auto& buf = static_cast<ScoreBuffer<Merger>&>(self);
std::memcpy(res, buf.data(), merger.byte_size());
},
ScoreFunction::DefaultMin};
}};
}

private:
Expand Down Expand Up @@ -446,16 +442,14 @@ class RangeMatcher : public Merger,
ScoreFunction PrepareScore() noexcept {
static_assert(HasScore_v<Merger>);

return {*this,
[](score_ctx* ctx, score_t* res) noexcept {
return {*this, [](score_ctx* ctx, score_t* res) noexcept {
IRS_ASSERT(ctx);
IRS_ASSERT(res);
auto& self = static_cast<RangeMatcher&>(*ctx);
auto& merger = static_cast<Merger&>(self);
auto& buf = static_cast<ScoreBuffer<Merger>&>(self);
std::memcpy(res, buf.data(), merger.byte_size());
},
ScoreFunction::DefaultMin};
}};
}

const Match& range() const noexcept { return match_; }
Expand Down Expand Up @@ -530,8 +524,7 @@ class MinMatcher : public Merger,
ScoreFunction PrepareScore() noexcept {
static_assert(HasScore_v<Merger>);

return {*this,
[](score_ctx* ctx, score_t* res) noexcept {
return {*this, [](score_ctx* ctx, score_t* res) noexcept {
IRS_ASSERT(ctx);
IRS_ASSERT(res);
auto& self = static_cast<JoinType&>(*ctx);
Expand All @@ -552,8 +545,7 @@ class MinMatcher : public Merger,
}

std::memcpy(res, buf.data(), merger.byte_size());
},
ScoreFunction::DefaultMin};
}};
}

Match range() const noexcept { return Match{min_}; }
Expand Down
5 changes: 2 additions & 3 deletions core/search/same_position_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,8 @@ class same_position_query : public filter::prepared {
irs::ScoreMergeType::kSum, ord.buckets().size(),
[&]<typename A>(A&& aggregator) -> irs::doc_iterator::ptr {
return MakeConjunction<same_position_iterator>(
// TODO(MBkkt)
WandContext{}, std::move(aggregator), std::move(itrs),
std::move(positions));
// TODO(MBkkt) Implement wand?
{}, std::move(aggregator), std::move(itrs), std::move(positions));
});
}

Expand Down
2 changes: 1 addition & 1 deletion core/search/score_function.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ScoreFunction : util::noncopyable {
}

ScoreFunction() noexcept = default;
ScoreFunction(score_ctx& ctx, score_f score, min_f min) noexcept
ScoreFunction(score_ctx& ctx, score_f score, min_f min = DefaultMin) noexcept
: ScoreFunction{&ctx, score, min, Noop} {}
ScoreFunction(ScoreFunction&& rhs) noexcept
: ScoreFunction{std::exchange(rhs.ctx_, nullptr),
Expand Down
3 changes: 1 addition & 2 deletions tests/formats/formats_15_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ struct FreqScorer : irs::ScorerBase<void> {
reinterpret_cast<irs::score_ctx&>(const_cast<irs::frequency&>(*freq)),
[](irs::score_ctx* ctx, irs::score_t* res) noexcept {
*res = reinterpret_cast<irs::frequency*>(ctx)->value;
},
irs::ScoreFunction::DefaultMin};
}};
}

irs::WandWriter::ptr prepare_wand_writer(size_t max_levels) const {
Expand Down
22 changes: 10 additions & 12 deletions tests/search/sort_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ TEST(ScoreFunctionTest, construct) {
auto score_func =
+[](irs::score_ctx*, irs::score_t* res) noexcept { *res = 42; };

irs::ScoreFunction func(ctx, score_func, irs::ScoreFunction::DefaultMin);
irs::ScoreFunction func(ctx, score_func);
ASSERT_EQ(score_func, func.Func());
ASSERT_EQ(&ctx, func.Ctx());
irs::score_t tmp{1};
Expand All @@ -890,7 +890,7 @@ TEST(ScoreFunctionTest, construct) {
auto score_func =
+[](irs::score_ctx*, irs::score_t* res) noexcept { *res = 42; };

irs::ScoreFunction func(ctx, score_func, irs::ScoreFunction::DefaultMin);
irs::ScoreFunction func(ctx, score_func);
ASSERT_EQ(score_func, func.Func());
ASSERT_EQ(&ctx, func.Ctx());
irs::score_t tmp{1};
Expand Down Expand Up @@ -1019,7 +1019,7 @@ TEST(ScoreFunctionTest, move) {
+[](irs::score_ctx*, irs::score_t* res) noexcept { *res = 42; };

float_t tmp{1};
irs::ScoreFunction func(ctx, score_func, irs::ScoreFunction::DefaultMin);
irs::ScoreFunction func(ctx, score_func);
ASSERT_EQ(&ctx, func.Ctx());
ASSERT_EQ(score_func, func.Func());
func(&tmp);
Expand Down Expand Up @@ -1050,7 +1050,7 @@ TEST(ScoreFunctionTest, move) {
ASSERT_NE(score_func, moved.Func());
moved(&tmp);
ASSERT_EQ(1, tmp);
irs::ScoreFunction func(ctx, score_func, irs::ScoreFunction::DefaultMin);
irs::ScoreFunction func(ctx, score_func);
ASSERT_EQ(&ctx, func.Ctx());
ASSERT_EQ(score_func, func.Func());
func(&tmp);
Expand Down Expand Up @@ -1079,17 +1079,15 @@ TEST(ScoreFunctionTest, equality) {
auto score_func1 = [](irs::score_ctx*, irs::score_t*) noexcept {};

irs::ScoreFunction func0;
irs::ScoreFunction func1(ctx0, score_func0, irs::ScoreFunction::DefaultMin);
irs::ScoreFunction func2(ctx1, score_func1, irs::ScoreFunction::DefaultMin);
irs::ScoreFunction func3(ctx0, score_func1, irs::ScoreFunction::DefaultMin);
irs::ScoreFunction func4(ctx1, score_func0, irs::ScoreFunction::DefaultMin);
irs::ScoreFunction func1(ctx0, score_func0);
irs::ScoreFunction func2(ctx1, score_func1);
irs::ScoreFunction func3(ctx0, score_func1);
irs::ScoreFunction func4(ctx1, score_func0);

ASSERT_EQ(func0, irs::ScoreFunction());
ASSERT_NE(func0, func1);
ASSERT_NE(func2, func3);
ASSERT_NE(func2, func4);
ASSERT_EQ(func1, irs::ScoreFunction(ctx0, score_func0,
irs::ScoreFunction::DefaultMin));
ASSERT_EQ(func2, irs::ScoreFunction(ctx1, score_func1,
irs::ScoreFunction::DefaultMin));
ASSERT_EQ(func1, irs::ScoreFunction(ctx0, score_func0));
ASSERT_EQ(func2, irs::ScoreFunction(ctx1, score_func1));
}

0 comments on commit a95de2c

Please sign in to comment.