Coverage Report

Created: 2026-08-18 00:40

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/storage/index/inverted/query/query.h
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#pragma once
19
20
// CLucene is third-party code and is not clean under -Wconversion (which
21
// -Wshorten-64-to-32 belongs to). Whether its first expansion lands inside
22
// someone else's suppressed region depends on include order, so suppress it
23
// deliberately here (same pattern as inverted_index_common_impl.h).
24
#ifdef __clang__
25
#pragma clang diagnostic push
26
#pragma clang diagnostic ignored "-Wconversion"
27
#endif
28
#include <CLucene.h> // IWYU pragma: keep
29
#include <CLucene/index/IndexReader.h>
30
#include <CLucene/index/Term.h>
31
#ifdef __clang__
32
#pragma clang diagnostic pop
33
#endif
34
#include <gen_cpp/PaloInternalService_types.h>
35
36
#include <memory>
37
#include <vector>
38
39
#include "common/status.h"
40
#include "io/io_common.h"
41
#include "roaring/roaring.hh"
42
#include "runtime/runtime_state.h"
43
#include "storage/index/index_query_context.h"
44
#include "storage/index/inverted/inverted_index_searcher.h"
45
#include "storage/index/inverted/query/query_info.h"
46
#include "storage/index/inverted/similarity/bm25_similarity.h"
47
#include "storage/index/inverted/util/docid_set_iterator.h"
48
#include "storage/index/inverted/util/string_helper.h"
49
50
CL_NS_USE(index)
51
CL_NS_USE(search)
52
CL_NS_USE(util)
53
54
namespace doris::segment_v2 {
55
56
using SearcherPtr = std::shared_ptr<lucene::search::IndexSearcher>;
57
58
class Query {
59
public:
60
257
    virtual ~Query() = default;
61
62
    // a unified data preparation interface that provides the field names to be queried and the terms for the query.
63
    // @param field_name The name of the field within the data source to search against.
64
    // @param terms a vector of tokenized strings that represent the search terms.
65
    virtual void add(const InvertedIndexQueryInfo& query_info) = 0;
66
67
    // a unified query interface for retrieving the ids obtained from the search.
68
    // @param roaring a Roaring bitmap to be populated with the search results,
69
    virtual void search(roaring::Roaring& roaring) = 0;
70
};
71
72
} // namespace doris::segment_v2