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 "collection_query.h"
24#include "equal_task.h"
25
26namespace proxima {
27namespace be {
28namespace query {
29
30/*!
31 * EqualQuery
32 */
33class EqualQuery : public ContextImpl, public QueryKeyContext {
34 public:
35 //! Constructor
36 EqualQuery(uint64_t traceID, const proto::GetDocumentRequest *req,
37 index::IndexServicePtr index, MetaWrapperPtr meta_wrapper,
38 ExecutorPtr executor_ptr, ProfilerPtr profiler_ptr,
39 proto::GetDocumentResponse *resp);
40
41 //! Destructor
42 ~EqualQuery() override;
43
44 public:
45 //! Validate query object, 0 for valid, otherwise non zero returned
46 int validate() const override;
47
48 //! Retrieve IOMode of query
49 IOMode mode() const override;
50
51 //! Retrieve the type of query, Readonly
52 QueryType type() const override;
53
54 //! Prepare resources, 0 for success, otherwise failed
55 int prepare() override;
56
57 //! Evaluate query, and collection feedback
58 int evaluate() override;
59
60 //! Finalize query object
61 int finalize() override;
62
63 //! Retrieve collection name
64 const std::string &collection() const override;
65
66 //! Retrieve primary_key
67 uint64_t primary_key() const override;
68
69 private:
70 //! Equal tasks
71 EqualTaskPtrList tasks_{};
72
73 // Request pointer readonly field
74 const proto::GetDocumentRequest *request_{nullptr};
75
76 // Response pointer
77 proto::GetDocumentResponse *response_{nullptr};
78};
79
80
81} // namespace query
82} // namespace be
83} // namespace proxima
84