Couchbase C++ SDK 1.0.2 (rev. 51f4775)
Loading...
Searching...
No Matches
transaction_query_options.hxx
Go to the documentation of this file.
1/*
2 * Copyright 2021-Present Couchbase, Inc.
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#pragma once
17
19
20// NOTE: when query is in public api, we will hold a query_options struct instead, and
21// import that from the public api.
22
24{
25class transaction_context;
26
35{
36public:
38 {
39 // set defaults specific to query in transactions.
40 opts_.metrics(true);
41 }
42
53 template<typename Value>
54 auto raw(const std::string& key, const Value& value) -> transaction_query_options&
55 {
56 opts_.raw(key, value);
57 return *this;
58 }
59
69 auto ad_hoc(bool value) -> transaction_query_options&
70 {
71 opts_.adhoc(value);
72 return *this;
73 }
74
88
98 {
99 opts_.profile(mode);
100 return *this;
101 }
102
111 auto client_context_id(const std::string& id) -> transaction_query_options&
112 {
113 opts_.client_context_id(id);
114 return *this;
115 }
116
125 auto scan_wait(std::chrono::milliseconds scan_wait) -> transaction_query_options&
126 {
127 opts_.scan_wait(scan_wait);
128 return *this;
129 }
130
140 {
141 opts_.readonly(readonly);
142 return *this;
143 }
144
153 auto scan_cap(std::uint64_t cap) -> transaction_query_options&
154 {
155 opts_.scan_cap(cap);
156 return *this;
157 }
158
167 auto pipeline_batch(std::uint64_t batch) -> transaction_query_options&
168 {
169 opts_.pipeline_batch(batch);
170 return *this;
171 }
172
181 auto pipeline_cap(std::uint64_t cap) -> transaction_query_options&
182 {
183 opts_.pipeline_cap(cap);
184 return *this;
185 }
186
196 template<typename... Parameters>
197 auto positional_parameters(const Parameters&... parameters)
198 {
199 opts_.positional_parameters(parameters...);
200 return *this;
201 }
202
212 template<typename... Parameters>
213 auto named_parameters(const Parameters&... parameters) -> transaction_query_options&
214 {
215 opts_.named_parameters(parameters...);
216 return *this;
217 }
218
229 auto metrics(bool metrics) -> transaction_query_options&
230 {
231 opts_.metrics(metrics);
232 return *this;
233 }
234
244 {
245 opts_.max_parallelism(max);
246 return *this;
247 }
248
250 auto encoded_raw_options(std::map<std::string, codec::binary, std::less<>> options)
252 {
253 opts_.encoded_raw_options(options);
254 return *this;
255 }
256
258 auto encoded_positional_parameters(std::vector<codec::binary> parameters)
260 {
261 opts_.encoded_positional_parameters(parameters);
262 return *this;
263 }
264
266 auto encoded_named_parameters(std::map<std::string, codec::binary, std::less<>> parameters)
268 {
269 opts_.encoded_named_parameters(parameters);
270 return *this;
271 }
272
274 auto get_query_options() const -> const query_options&
275 {
276 return opts_;
277 }
278
279private:
280 query_options opts_{};
281};
282} // namespace couchbase::transactions
The transaction_query_options are options specific to a query.
Definition transaction_query_options.hxx:35
auto client_context_id(const std::string &id) -> transaction_query_options &
Set a client id for this query.
Definition transaction_query_options.hxx:111
auto raw(const std::string &key, const Value &value) -> transaction_query_options &
Set an option which isn't exposed explicitly in transaction_query_options.
Definition transaction_query_options.hxx:54
auto profile(query_profile mode) -> transaction_query_options &
Set the profile mode for this query.
Definition transaction_query_options.hxx:97
auto scan_cap(std::uint64_t cap) -> transaction_query_options &
Set the scan cap for this query.
Definition transaction_query_options.hxx:153
transaction_query_options()
Definition transaction_query_options.hxx:37
auto scan_consistency(query_scan_consistency scan_consistency) -> transaction_query_options &
Set the query_scan_consistency for this query.
Definition transaction_query_options.hxx:83
auto metrics(bool metrics) -> transaction_query_options &
Set metrics for this query.
Definition transaction_query_options.hxx:229
auto max_parallelism(std::uint64_t max) -> transaction_query_options &
Set max parallelism for this query.
Definition transaction_query_options.hxx:243
auto scan_wait(std::chrono::milliseconds scan_wait) -> transaction_query_options &
Set the scan_wait time.
Definition transaction_query_options.hxx:125
auto pipeline_cap(std::uint64_t cap) -> transaction_query_options &
Set pipeline cap for this query.
Definition transaction_query_options.hxx:181
auto positional_parameters(const Parameters &... parameters)
Set positional parameters for this query.
Definition transaction_query_options.hxx:197
auto readonly(bool readonly) -> transaction_query_options &
Set the readonly hint for this query.
Definition transaction_query_options.hxx:139
auto pipeline_batch(std::uint64_t batch) -> transaction_query_options &
Set pipeline_batch size for this query.
Definition transaction_query_options.hxx:167
auto named_parameters(const Parameters &... parameters) -> transaction_query_options &
Set named parameters for this query.
Definition transaction_query_options.hxx:213
auto ad_hoc(bool value) -> transaction_query_options &
Set ad_hoc.
Definition transaction_query_options.hxx:69
std::vector< std::byte > binary
Definition encoded_value.hxx:25
Definition transactions.hxx:28
query_profile
Definition query_profile.hxx:22
query_scan_consistency
Definition query_scan_consistency.hxx:22
auto client_context_id(std::string client_context_id) -> query_options &
Supports providing a custom client context ID for this query.
Definition query_options.hxx:367
auto named_parameters(const Parameters &... parameters) -> query_options &
Set list of named parameters for a query.
Definition query_options.hxx:486
auto encoded_raw_options(std::map< std::string, codec::binary, std::less<> > options) -> query_options &
Set map of raw options for a query.
Definition query_options.hxx:508
auto metrics(bool metrics) -> query_options &
Enables per-request metrics in the trailing section of the query.
Definition query_options.hxx:148
auto max_parallelism(std::uint64_t max_parallelism) -> query_options &
Allows overriding the default maximum parallelism for the query execution on the server side.
Definition query_options.hxx:271
auto encoded_named_parameters(std::map< std::string, codec::binary, std::less<> > parameters) -> query_options &
Set map of named parameters for a query.
Definition query_options.hxx:551
auto raw(std::string name, const Value &value) -> query_options &
Definition query_options.hxx:446
auto pipeline_cap(std::uint64_t pipeline_cap) -> query_options &
Allows customizing the maximum number of items each execution operator can buffer between various ope...
Definition query_options.hxx:349
auto scan_wait(std::chrono::milliseconds wait) -> query_options &
Allows customizing how long the query engine is willing to wait until the index catches up to whateve...
Definition query_options.hxx:308
auto encoded_positional_parameters(std::vector< codec::binary > parameters) -> query_options &
Set list of positional parameters for a query.
Definition query_options.hxx:530
auto scan_cap(std::uint64_t scan_cap) -> query_options &
Supports customizing the maximum buffered channel size between the indexer and the query service.
Definition query_options.hxx:289
auto pipeline_batch(std::uint64_t pipeline_batch) -> query_options &
Supports customizing the number of items execution operators can batch for fetch from the KV layer on...
Definition query_options.hxx:330
auto readonly(bool readonly) -> query_options &
Allows explicitly marking a query as being readonly and not mutating and documents on the server side...
Definition query_options.hxx:203
auto adhoc(bool adhoc) -> query_options &
Allows turning this request into a prepared statement query.
Definition query_options.hxx:128
auto scan_consistency(query_scan_consistency scan_consistency) -> query_options &
Customizes the consistency guarantees for this query.
Definition query_options.hxx:399
auto profile(query_profile profile) -> query_options &
Customizes the server profiling level for this query.
Definition query_options.hxx:170
auto positional_parameters(const Parameters &... parameters) -> query_options &
Set list of positional parameters for a query.
Definition query_options.hxx:465