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 Oct 2020
18 * \brief
19 */
20
21#pragma once
22
23#include <memory>
24#include "common/profiler.h"
25#include "query_types.h"
26
27namespace proxima {
28namespace be {
29namespace query {
30
31//! Predefine class
32class Query;
33//! Alias for QueryPtr
34using QueryPtr = std::shared_ptr<Query>;
35
36
37/*!
38 * Query Interface
39 */
40class Query {
41 public:
42 //! Destructor
43 virtual ~Query() = default;
44
45 public:
46 //! Unique request id, using trace all relevant information
47 virtual uint64_t id() const = 0;
48
49 //! Validate query object, 0 for valid, otherwise non zero returned
50 virtual int validate() const = 0;
51
52 //! Retrieve IOMode of query
53 virtual IOMode mode() const = 0;
54
55 //! Retrieve the type of query, Readonly
56 virtual QueryType type() const = 0;
57
58 //! Prepare resources, 0 for success, otherwise failed
59 virtual int prepare() = 0;
60
61 //! Evaluate query, and collection feedback
62 virtual int evaluate() = 0;
63
64 //! Finalize query object
65 virtual int finalize() = 0;
66
67 /* Common usage of query
68 * 1. get query object
69 * 2. invoke invalidate
70 * 3. invoke prepare
71 * 4. invoke evaluate
72 * 5. collect all the feedback from query
73 * 6. Handle query finished
74 */
75
76 //! Get Profiler
77 virtual ProfilerPtr profiler() const = 0;
78};
79
80
81} // namespace query
82} // namespace be
83} // namespace proxima
84