Couchbase C++ SDK 1.0.4 (rev. 5355b0f)
|
Options for cluster::query() and scope::query(). More...
#include <couchbase/query_options.hxx>
Classes | |
struct | built |
Immutable value object representing consistent options. More... | |
Public Member Functions | |
auto | build () const -> built |
Validates options and returns them as an immutable value. | |
auto | adhoc (bool adhoc) -> query_options & |
Allows turning this request into a prepared statement query. | |
auto | metrics (bool metrics) -> query_options & |
Enables per-request metrics in the trailing section of the query. | |
auto | profile (query_profile profile) -> query_options & |
Customizes the server profiling level for this query. | |
auto | readonly (bool readonly) -> query_options & |
Allows explicitly marking a query as being readonly and not mutating and documents on the server side. | |
auto | flex_index (bool flex_index) -> query_options & |
Tells the query engine to use a flex index (utilizing the search service). | |
auto | preserve_expiry (bool preserve_expiry) -> query_options & |
Tells the query engine to preserve expiration values set on any documents modified by this query. | |
auto | use_replica (bool use_replica) -> query_options & |
Specifies that the query engine should use replica nodes for KV fetches if the active node is down. | |
auto | max_parallelism (std::uint64_t max_parallelism) -> query_options & |
Allows overriding the default maximum parallelism for the query execution on the server side. | |
auto | scan_cap (std::uint64_t scan_cap) -> query_options & |
Supports customizing the maximum buffered channel size between the indexer and the query service. | |
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 whatever scan consistency is asked for in this query. | |
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 the server. | |
auto | pipeline_cap (std::uint64_t pipeline_cap) -> query_options & |
Allows customizing the maximum number of items each execution operator can buffer between various operators on the server. | |
auto | client_context_id (std::string client_context_id) -> query_options & |
Supports providing a custom client context ID for this query. | |
auto | scan_consistency (query_scan_consistency scan_consistency) -> query_options & |
Customizes the consistency guarantees for this query. | |
auto | consistent_with (const mutation_state &state) -> query_options & |
Sets the mutation_token s this query should be consistent with. | |
template<typename Serializer = codec::tao_json_serializer, typename Value , std::enable_if_t< codec::is_serializer_v< Serializer >, bool > = true> | |
auto | raw (std::string name, const Value &value) -> query_options & |
template<typename Serializer = codec::tao_json_serializer, typename... Parameters, std::enable_if_t< codec::is_serializer_v< Serializer >, bool > = true> | |
auto | positional_parameters (const Parameters &... parameters) -> query_options & |
Set list of positional parameters for a query. | |
template<typename Serializer = codec::tao_json_serializer, typename... Parameters, std::enable_if_t< codec::is_serializer_v< Serializer >, bool > = true> | |
auto | named_parameters (const Parameters &... parameters) -> query_options & |
Set list of named parameters for a query. | |
auto | encoded_raw_options (std::map< std::string, codec::binary, std::less<> > options) -> query_options & |
Set map of raw options for a query. | |
auto | encoded_positional_parameters (std::vector< codec::binary > parameters) -> query_options & |
Set list of positional parameters for a query. | |
auto | encoded_named_parameters (std::map< std::string, codec::binary, std::less<> > parameters) -> query_options & |
Set map of named parameters for a query. | |
Public Member Functions inherited from common_options< query_options > | |
auto | timeout (const std::chrono::milliseconds timeout) -> query_options & |
Specifies a custom per-operation timeout. | |
auto | retry_strategy (const std::shared_ptr< retry_strategy > strategy) -> query_options & |
Specifies a custom couchbase::retry_strategy for this operation. | |
auto | parent_span (std::shared_ptr< tracing::request_span > span) -> query_options & |
Additional Inherited Members | |
Protected Member Functions inherited from common_options< query_options > | |
auto | build_common_options () const -> built |
auto | self () -> query_options & |
Allows to return the right options builder instance for child implementations. | |
Options for cluster::query() and scope::query().
|
inline |
Allows turning this request into a prepared statement query.
If set to false
, the SDK will transparently perform "prepare and execute" logic the first time this query is seen and then subsequently reuse the prepared statement name when sending it to the server. If a query is executed frequently, this is a good way to speed it up since it will save the server the task of re-parsing and analyzing the query.
If you are using prepared statements, make sure that if certain parts of the query string change you are using named_parameters() or positional_parameters(). If the statement string itself changes it cannot be cached.
adhoc | if set to false this query will be turned into a prepared statement query. |
|
inlinenodiscard |
Validates options and returns them as an immutable value.
std::system_error | with code errc::common::invalid_argument if the options are not valid |
|
inline |
Supports providing a custom client context ID for this query.
If no client context ID is provided by the user, a UUID is generated and sent automatically so by default it is always possible to identify a query when debugging.
client_context_id | the client context ID |
|
inline |
Sets the mutation_token
s this query should be consistent with.
These mutation tokens are returned from mutations (i.e. as part of a mutation_result
) and if you want your N1QL query to include those you need to pass the mutation tokens into a mutation_state
.
Note that you cannot use this method and scan_consistency(query_scan_consistency)
at the same time, since they are mutually exclusive. As a rule of thumb, if you only care to be consistent with the mutation you just wrote on the same thread/app, use this method. If you need "global" scan consistency, use query_scan_consistency#request_plus
on scan_consistency(query_scan_consistency)
.
state | the mutation state containing the mutation tokens. |
|
inline |
Set map of named parameters for a query.
This function expects that all parameters encoded into pairs containing mapping names of the parameter to valid JSON values encoded as string.
parameters | mapping of pairs, where each entry contains string with valid JSON value. |
|
inline |
Set list of positional parameters for a query.
This function expects that all parameters encoded into byte strings containing valid JSON values.
parameters | vector of binaries, where each entry contains string with valid JSON value. |
|
inline |
Set map of raw options for a query.
This function expects that all parameters encoded into pairs containing mapping names of the parameter to valid JSON values encoded as string.
options | mapping of pairs, where each entry contains string with valid JSON value. |
|
inline |
Tells the query engine to use a flex index (utilizing the search service).
flex_index | if a flex index should be used, false is the default. |
|
inline |
Allows overriding the default maximum parallelism for the query execution on the server side.
If 0 value is set, the parallelism is disabled. If not provided, the server default will be used.
max_parallelism | the maximum parallelism for this query, 0 value disable it. |
|
inline |
Enables per-request metrics in the trailing section of the query.
If this method is set to true, the server will send metrics back to the client which are available through the query_meta_data#metrics()
section. As opposed to profile(query_profile)
, returning metrics is rather cheap and can also be enabled in production if needed.
metrics | set to true if the server should return simple query metrics. |
|
inline |
Set list of named parameters for a query.
Parameters | types for the parameter pairs |
parameters | the sequence of name-value pairs. Each value will be encoded into JSON. |
|
inline |
Supports customizing the number of items execution operators can batch for fetch from the KV layer on the server.
This is an advanced API and should only be tuned with care.
pipeline_batch | the pipeline batch size. |
|
inline |
Allows customizing the maximum number of items each execution operator can buffer between various operators on the server.
This is an advanced API and should only be tuned with care.
pipeline_cap | the pipeline cap size. |
|
inline |
Set list of positional parameters for a query.
Parameters | types for the parameters |
parameters | the sequence of positional parameters. Each entry will be encoded into JSON. |
|
inline |
Tells the query engine to preserve expiration values set on any documents modified by this query.
This feature works from Couchbase Server 7.1.0 onwards.
preserve_expiry | whether expiration values should be preserved, the default is false. |
|
inline |
Customizes the server profiling level for this query.
This is an Enterprise Edition feature. On Community Edition the parameter will be accepted, but no profiling information returned.
profile | the custom query profile level for this query. |
|
inline |
Value |
name | |
value |
|
inline |
Allows explicitly marking a query as being readonly and not mutating and documents on the server side.
In addition to providing some security in that you are not accidentally modifying data, setting this flag to true also helps the client to more proactively retry and re-dispatch a query since then it can be sure it is idempotent. As a result, if your query is readonly then it is a good idea to set this flag.
If set to true, then (at least) the following statements are not allowed:
readonly | true if readonly should be set, false is the default and will use the server side default. |
|
inline |
Supports customizing the maximum buffered channel size between the indexer and the query service.
This is an advanced API and should only be tuned with care. Use 0 to disable.
scan_cap | the scan cap size, use 0 value to disable. |
|
inline |
Customizes the consistency guarantees for this query.
Tuning the scan consistency allows to trade data "freshness" for latency and vice versa. By default query_scan_consistency::not_bounded
is used, which means that the server returns the data it has in the index right away. This is fast, but might not include the most recent mutations. If you want to include all the mutations up to the point of the query, use query_scan_consistency::request_plus
.
Note that you cannot use this method and consistent_with(const mutation_state&)
at the same time, since they are mutually exclusive. As a rule of thumb, if you only care to be consistent with the mutation you just wrote on the same thread/app, use consistent_with(const mutation_state&)
. If you need "global" scan consistency, use query_scan_consistency::request_plus
on this method.
scan_consistency | the index scan consistency to be used for this query |
|
inline |
Allows customizing how long the query engine is willing to wait until the index catches up to whatever scan consistency is asked for in this query.
query_scan_consistency::not_bounded
is used, this method doesn't do anything at all. If no value is provided to this method, the server default is used.wait | the maximum duration the query engine is willing to wait before failing. |
|
inline |
Specifies that the query engine should use replica nodes for KV fetches if the active node is down.
use_replica | whether replica nodes should be used if the active node is down. If not provided, the server default will be used. |