/Users/deen/code/yugabyte-db/src/yb/yql/cql/ql/util/statement_params.h
Line | Count | Source (jump to first uncovered line) |
1 | | //-------------------------------------------------------------------------------------------------- |
2 | | // Copyright (c) YugaByte, Inc. |
3 | | // |
4 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
5 | | // in compliance with the License. You may obtain a copy of the License at |
6 | | // |
7 | | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
10 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
11 | | // or implied. See the License for the specific language governing permissions and limitations |
12 | | // under the License. |
13 | | // |
14 | | // |
15 | | // Parameters for executing a SQL statement. |
16 | | //-------------------------------------------------------------------------------------------------- |
17 | | |
18 | | #ifndef YB_YQL_CQL_QL_UTIL_STATEMENT_PARAMS_H_ |
19 | | #define YB_YQL_CQL_QL_UTIL_STATEMENT_PARAMS_H_ |
20 | | |
21 | | #include "yb/common/common_fwd.h" |
22 | | #include "yb/common/ql_protocol.pb.h" |
23 | | |
24 | | #include "yb/util/status_fwd.h" |
25 | | |
26 | | namespace yb { |
27 | | |
28 | | struct ReadHybridTime; |
29 | | |
30 | | namespace ql { |
31 | | |
32 | | // This class represents the parameters for executing a SQL statement. |
33 | | class StatementParameters { |
34 | | public: |
35 | | // Public types. |
36 | | typedef std::unique_ptr<StatementParameters> UniPtr; |
37 | | typedef std::unique_ptr<const StatementParameters> UniPtrConst; |
38 | | |
39 | | // Constructors |
40 | | StatementParameters(); |
41 | | StatementParameters(const StatementParameters& other); |
42 | | virtual ~StatementParameters(); |
43 | | |
44 | | // Accessor functions for page_size. |
45 | 14.7M | uint64_t page_size() const { return page_size_; } |
46 | 8.79M | void set_page_size(const uint64_t page_size) { page_size_ = page_size; } |
47 | | |
48 | | // Set paging state. |
49 | | CHECKED_STATUS SetPagingState(const std::string& paging_state); |
50 | | |
51 | | // Write paging state to output. |
52 | 7.49M | void WritePagingState(QLPagingStatePB *output) const { output->CopyFrom(paging_state()); } |
53 | | |
54 | | // Accessor functions for paging state fields. |
55 | 7.47M | const std::string& table_id() const { return paging_state().table_id(); } |
56 | | |
57 | 0 | const std::string& next_partition_key() const { return paging_state().next_partition_key(); } |
58 | | |
59 | 0 | const std::string& next_row_key() const { return paging_state().next_row_key(); } |
60 | | |
61 | 0 | int64_t total_num_rows_read() const { return paging_state().total_num_rows_read(); } |
62 | | |
63 | 0 | int64_t total_rows_skipped() const { return paging_state().total_rows_skipped(); } |
64 | | |
65 | 0 | int64_t next_partition_index() const { return paging_state().next_partition_index(); } |
66 | | |
67 | | ReadHybridTime read_time() const; |
68 | | |
69 | | // Check if a bind variable is unset. To be overridden by subclasses |
70 | | // to return actual bind variables status. |
71 | | virtual Result<bool> IsBindVariableUnset(const std::string& name, |
72 | | int64_t pos) const; |
73 | | |
74 | | // Retrieve a bind variable for the execution of the statement. To be overridden by subclasses |
75 | | // to return actual bind variables. |
76 | | virtual CHECKED_STATUS GetBindVariable(const std::string& name, |
77 | | int64_t pos, |
78 | | const std::shared_ptr<QLType>& type, |
79 | | QLValue* value) const; |
80 | | |
81 | 7.22M | YBConsistencyLevel yb_consistency_level() const { |
82 | 7.22M | return yb_consistency_level_; |
83 | 7.22M | } |
84 | | |
85 | 8.91M | void set_request_id(uint64_t value) { |
86 | 8.91M | request_id_ = value; |
87 | 8.91M | } |
88 | | |
89 | 7.47M | uint64_t request_id() const { |
90 | 7.47M | return request_id_; |
91 | 7.47M | } |
92 | | |
93 | | protected: |
94 | 8.91M | void set_yb_consistency_level(const YBConsistencyLevel yb_consistency_level) { |
95 | 8.91M | yb_consistency_level_ = yb_consistency_level; |
96 | 8.91M | } |
97 | | |
98 | | private: |
99 | 14.9M | const QLPagingStatePB& paging_state() const { |
100 | 14.9M | return paging_state_ != nullptr ? *paging_state_905 : QLPagingStatePB::default_instance()14.9M ; |
101 | 14.9M | } |
102 | | |
103 | | // Limit of the number of rows to return set as page size. |
104 | | uint64_t page_size_ = 0; |
105 | | |
106 | | // Paging State. |
107 | | std::unique_ptr<QLPagingStatePB> paging_state_; |
108 | | |
109 | | // Consistency level for YB. |
110 | | YBConsistencyLevel yb_consistency_level_; |
111 | | |
112 | | // Unique identifier of call that initiated this request. |
113 | | uint64_t request_id_ = 0; |
114 | | }; |
115 | | |
116 | | } // namespace ql |
117 | | } // namespace yb |
118 | | |
119 | | #endif // YB_YQL_CQL_QL_UTIL_STATEMENT_PARAMS_H_ |