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 "index/collection_query.h"
24#include "index/index_service.h"
25#include "proto/proxima_be.pb.h"
26
27namespace proxima {
28namespace be {
29namespace query {
30
31/*!
32 * QueryContext which store request and response
33 */
34class QueryContext {
35 public:
36 //! Destructor
37 virtual ~QueryContext() = default;
38
39 public:
40 //! Retrieve the PB request of query
41 virtual const proto::QueryRequest *request() const = 0;
42
43 //! Retrieve the PB response of query
44 virtual const proto::QueryResponse *response() const = 0;
45
46 //! Retrieve the PB response of query
47 virtual proto::QueryResponse *mutable_response() = 0;
48};
49
50
51/*!
52 * CollectionQueryContext provide the collection of query
53 */
54class CollectionQueryContext {
55 public:
56 //! Destructor
57 virtual ~CollectionQueryContext() = default;
58
59 public:
60 //! Retrieve collection name
61 virtual const std::string &collection() const = 0;
62};
63
64
65/*!
66 * KNNQueryContext: Provide all the params needed for invoke
67 * segment.knn_search
68 */
69class KNNQueryContext {
70 public:
71 //! Destructor
72 virtual ~KNNQueryContext() = default;
73
74 public:
75 //! Retrieve column name
76 virtual const std::string &column() const = 0;
77
78 //! Retrieve features field
79 virtual const std::string &features() const = 0;
80
81 //! Retrieve batch_count field
82 virtual uint32_t batch_count() const = 0;
83
84 //! Retrieve QueryParams
85 virtual const index::QueryParams &query_params() const = 0;
86};
87
88
89/*!
90 * QueryKeyContext
91 */
92class QueryKeyContext {
93 public:
94 //! Destructor
95 virtual ~QueryKeyContext() = default;
96
97 public:
98 //! Retrieve primary_key
99 virtual uint64_t primary_key() const = 0;
100};
101
102
103} // namespace query
104} // namespace be
105} // namespace proxima
106