Copilot commented on code in PR #57007:
URL: https://github.com/apache/doris/pull/57007#discussion_r2464289907
##########
be/src/olap/rowset/segment_v2/inverted_index/query_v2/doc_set.h:
##########
@@ -50,6 +50,80 @@ class DocSet {
throw doris::Exception(doris::ErrorCode::NOT_IMPLEMENTED_ERROR,
"size_hint() method not implemented in base
DocSet class");
}
+
+ virtual uint32_t freq() const {
+ throw doris::Exception(doris::ErrorCode::NOT_IMPLEMENTED_ERROR,
+ "freq() method not implemented in base DocSet
class");
+ }
+
+ virtual uint32_t norm() const {
+ throw doris::Exception(doris::ErrorCode::NOT_IMPLEMENTED_ERROR,
+ "norm() method not implemented in base DocSet
class");
+ }
};
+class MockDocSet : public DocSet {
+public:
+ MockDocSet(std::vector<uint32_t> docs, uint32_t size_hint_val = 0,
uint32_t norm_val = 1)
+ : _docs(std::move(docs)), _size_hint_val(size_hint_val),
_norm_val(norm_val) {
+ if (_docs.empty()) {
+ _current_doc = TERMINATED;
+ } else {
+ std::ranges::sort(_docs.begin(), _docs.end());
Review Comment:
Using `std::ranges::sort` with `.begin()` and `.end()` iterators is
incorrect. Either use `std::ranges::sort(_docs)` directly or use
`std::sort(_docs.begin(), _docs.end())`.
```suggestion
std::ranges::sort(_docs);
```
##########
be/src/olap/rowset/segment_v2/inverted_index/query_v2/segment_postings.h:
##########
@@ -77,17 +71,35 @@ class SegmentPostings final : public
SegmentPostingsBase<TermIterator> {
public:
SegmentPostings(TermIterator iter) :
SegmentPostingsBase<TermIterator>(std::move(iter)) {}
- int32_t freq() const override { return this->_iter->freq(); }
- int32_t norm() const override { return this->_iter->norm(); }
+ void positions_with_offset(uint32_t offset, std::vector<uint32_t>& output)
{
+ output.clear();
+ append_positions_with_offset(offset, output);
+ }
+
+ void append_positions_with_offset(uint32_t offset, std::vector<uint32_t>&
output) {
+ static_assert(
+ requires(TermIterator it) {
+ it->freq();
+ it->nextPosition();
+ }, "TermIterator must expose freq() and nextPosition()");
Review Comment:
The static_assert with a requires clause should use `std::is_invocable` or a
proper C++20 concept. The current syntax mixing static_assert with requires
expression may not compile correctly on all compilers.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]