1/**
2 * Copyright 2021 Alibaba, Inc. and its affiliates. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * \author guonix
17 * \date Nov 2020
18 * \brief
19 */
20
21#pragma once
22
23#include "executor/bthread_task.h"
24#include "context.h"
25
26namespace proxima {
27namespace be {
28namespace query {
29
30//! Predefine class
31class EqualTask;
32
33//! Alias for EqualTask
34using EqualTaskPtr = std::shared_ptr<EqualTask>;
35using EqualTaskPtrList = std::list<EqualTaskPtr>;
36
37
38/*!
39 * EqualTask
40 */
41class EqualTask : public BthreadTask {
42 public:
43 //! Constructor
44 EqualTask(index::SegmentPtr segment, QueryKeyContext *context);
45
46 //! Destructor
47 ~EqualTask() override;
48
49 public:
50 //! Retrieve hit count
51 uint32_t hit() const;
52
53 //! Get the forward
54 const index::QueryResult &forward() const;
55
56 private:
57 // Do search
58 int do_run() override;
59
60 private:
61 //! Hit count
62 uint32_t hit_count_{0};
63
64 //! Segment handler
65 index::SegmentPtr segment_{nullptr};
66
67 //! Query Param
68 QueryKeyContext *context_{nullptr};
69
70 //! Forward
71 index::QueryResult forward_{};
72};
73
74
75} // namespace query
76} // namespace be
77} // namespace proxima
78