Class: Couchbase::Options::Query
Overview
Options for Cluster#query
Constant Summary collapse
- DEFAULT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Query.new.freeze
Instance Attribute Summary collapse
- #adhoc ⇒ Boolean
- #client_context_id ⇒ String
- #flex_index ⇒ Boolean
- #max_parallelism ⇒ Integer
- #metrics ⇒ Boolean
- #mutation_state ⇒ MutationState readonly private
- #pipeline_batch ⇒ Integer
- #pipeline_cap ⇒ Integer
- #preserve_expiry ⇒ Boolean
- #profile ⇒ Symbol
- #raw_parameters ⇒ Hash<String => #to_json> readonly private
- #readonly ⇒ Boolean
- #scan_cap ⇒ Integer
- #scan_wait ⇒ Integer, #in_milliseconds
- #scope_qualifier ⇒ String
- #transcoder ⇒ JsonTranscoder, #decode(String)
- #use_replica ⇒ Boolean?
Attributes inherited from Base
#client_context, #parent_span, #retry_strategy, #timeout
Instance Method Summary collapse
-
#consistent_with(mutation_state) ⇒ Object
Sets the mutation tokens this query should be consistent with.
- #export_named_parameters ⇒ Hash<String => String>? private
- #export_positional_parameters ⇒ Array<String>? private
-
#initialize(adhoc: true, client_context_id: nil, max_parallelism: nil, readonly: false, scan_wait: nil, scan_cap: nil, pipeline_cap: nil, pipeline_batch: nil, metrics: nil, profile: :off, flex_index: nil, preserve_expiry: nil, use_replica: nil, scope_qualifier: nil, scan_consistency: :not_bounded, mutation_state: nil, transcoder: JsonTranscoder.new, positional_parameters: nil, named_parameters: nil, timeout: nil, retry_strategy: nil, client_context: nil, parent_span: nil) {|self| ... } ⇒ Query
constructor
Creates new instance of options for Cluster#query.
-
#named_parameters(named) ⇒ Object
Sets named parameters for the query.
-
#positional_parameters(positional) ⇒ Object
Sets positional parameters for the query.
-
#raw(key, value) ⇒ Object
Allows providing custom JSON key/value pairs for advanced usage.
-
#scan_consistency=(level) ⇒ Object
Customizes the consistency guarantees for this query.
- #to_backend(scope_name: nil, bucket_name: nil) ⇒ Object private
Constructor Details
#initialize(adhoc: true, client_context_id: nil, max_parallelism: nil, readonly: false, scan_wait: nil, scan_cap: nil, pipeline_cap: nil, pipeline_batch: nil, metrics: nil, profile: :off, flex_index: nil, preserve_expiry: nil, use_replica: nil, scope_qualifier: nil, scan_consistency: :not_bounded, mutation_state: nil, transcoder: JsonTranscoder.new, positional_parameters: nil, named_parameters: nil, timeout: nil, retry_strategy: nil, client_context: nil, parent_span: nil) {|self| ... } ⇒ Query
Either positional_parameters
or named_parameters
may be specified.
Creates new instance of options for Cluster#query
2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 |
# File 'lib/couchbase/options.rb', line 2101 def initialize(adhoc: true, client_context_id: nil, max_parallelism: nil, readonly: false, scan_wait: nil, scan_cap: nil, pipeline_cap: nil, pipeline_batch: nil, metrics: nil, profile: :off, flex_index: nil, preserve_expiry: nil, use_replica: nil, scope_qualifier: nil, scan_consistency: :not_bounded, mutation_state: nil, transcoder: JsonTranscoder.new, positional_parameters: nil, named_parameters: nil, timeout: nil, retry_strategy: nil, client_context: nil, parent_span: nil) raise ArgumentError, "Cannot pass positional and named parameters at the same time" if positional_parameters && named_parameters super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span) @adhoc = adhoc @client_context_id = client_context_id @max_parallelism = max_parallelism @readonly = readonly @scan_wait = scan_wait @scan_cap = scan_cap @pipeline_cap = pipeline_cap @pipeline_batch = pipeline_batch @metrics = metrics @profile = profile @flex_index = flex_index @preserve_expiry = preserve_expiry @use_replica = use_replica @scope_qualifier = scope_qualifier @scan_consistency = scan_consistency @mutation_state = mutation_state @transcoder = transcoder @positional_parameters = positional_parameters @named_parameters = named_parameters @raw_parameters = {} yield self if block_given? end |
Instance Attribute Details
#adhoc ⇒ Boolean
2022 2023 2024 |
# File 'lib/couchbase/options.rb', line 2022 def adhoc @adhoc end |
#client_context_id ⇒ String
2023 2024 2025 |
# File 'lib/couchbase/options.rb', line 2023 def client_context_id @client_context_id end |
#flex_index ⇒ Boolean
2032 2033 2034 |
# File 'lib/couchbase/options.rb', line 2032 def flex_index @flex_index end |
#max_parallelism ⇒ Integer
2024 2025 2026 |
# File 'lib/couchbase/options.rb', line 2024 def max_parallelism @max_parallelism end |
#metrics ⇒ Boolean
2030 2031 2032 |
# File 'lib/couchbase/options.rb', line 2030 def metrics @metrics end |
#mutation_state ⇒ MutationState (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
2214 2215 2216 |
# File 'lib/couchbase/options.rb', line 2214 def mutation_state @mutation_state end |
#pipeline_batch ⇒ Integer
2028 2029 2030 |
# File 'lib/couchbase/options.rb', line 2028 def pipeline_batch @pipeline_batch end |
#pipeline_cap ⇒ Integer
2029 2030 2031 |
# File 'lib/couchbase/options.rb', line 2029 def pipeline_cap @pipeline_cap end |
#preserve_expiry ⇒ Boolean
2033 2034 2035 |
# File 'lib/couchbase/options.rb', line 2033 def preserve_expiry @preserve_expiry end |
#profile ⇒ Symbol
2031 2032 2033 |
# File 'lib/couchbase/options.rb', line 2031 def profile @profile end |
#raw_parameters ⇒ Hash<String => #to_json> (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
2218 2219 2220 |
# File 'lib/couchbase/options.rb', line 2218 def raw_parameters @raw_parameters end |
#readonly ⇒ Boolean
2025 2026 2027 |
# File 'lib/couchbase/options.rb', line 2025 def readonly @readonly end |
#scan_cap ⇒ Integer
2027 2028 2029 |
# File 'lib/couchbase/options.rb', line 2027 def scan_cap @scan_cap end |
#scan_wait ⇒ Integer, #in_milliseconds
2026 2027 2028 |
# File 'lib/couchbase/options.rb', line 2026 def scan_wait @scan_wait end |
#scope_qualifier ⇒ String
2035 2036 2037 |
# File 'lib/couchbase/options.rb', line 2035 def scope_qualifier @scope_qualifier end |
#transcoder ⇒ JsonTranscoder, #decode(String)
2036 2037 2038 |
# File 'lib/couchbase/options.rb', line 2036 def transcoder @transcoder end |
#use_replica ⇒ Boolean?
2034 2035 2036 |
# File 'lib/couchbase/options.rb', line 2034 def use_replica @use_replica end |
Instance Method Details
#consistent_with(mutation_state) ⇒ Object
overrides consistency level set by #scan_consistency=
Sets the mutation tokens this query should be consistent with
2179 2180 2181 2182 |
# File 'lib/couchbase/options.rb', line 2179 def consistent_with(mutation_state) @scan_consistency = nil if @scan_consistency @mutation_state = mutation_state end |
#export_named_parameters ⇒ Hash<String => String>?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
2208 2209 2210 |
# File 'lib/couchbase/options.rb', line 2208 def export_named_parameters @named_parameters&.each_with_object({}) { |(n, v), o| o[n.to_s] = JSON.dump(v) } end |
#export_positional_parameters ⇒ Array<String>?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
2194 2195 2196 |
# File 'lib/couchbase/options.rb', line 2194 def export_positional_parameters @positional_parameters&.map { |p| JSON.dump(p) } end |
#named_parameters(named) ⇒ Object
Sets named parameters for the query
2201 2202 2203 2204 |
# File 'lib/couchbase/options.rb', line 2201 def named_parameters(named) @named_parameters = named @positional_parameters = nil end |
#positional_parameters(positional) ⇒ Object
Sets positional parameters for the query
2187 2188 2189 2190 |
# File 'lib/couchbase/options.rb', line 2187 def positional_parameters(positional) @positional_parameters = positional @named_parameters = nil end |
#raw(key, value) ⇒ Object
Allows providing custom JSON key/value pairs for advanced usage
2154 2155 2156 |
# File 'lib/couchbase/options.rb', line 2154 def raw(key, value) @raw_parameters[key] = JSON.generate(value) end |
#scan_consistency=(level) ⇒ Object
overrides consistency level set by #consistent_with
Customizes the consistency guarantees for this query
:not_bounded
-
The indexer will return whatever state it has to the query engine at the time of query. This is the default (for
single-statement requests).
:request_plus
-
The indexer will wait until all mutations have been processed at the time of request before returning to the query
engine.
2169 2170 2171 2172 |
# File 'lib/couchbase/options.rb', line 2169 def scan_consistency=(level) @mutation_state = nil if @mutation_state @scan_consistency = level end |
#to_backend(scope_name: nil, bucket_name: nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 |
# File 'lib/couchbase/options.rb', line 2221 def to_backend(scope_name: nil, bucket_name: nil) if scope_name && bucket_name default_query_context = format("default:`%<bucket>s`.`%<scope>s`", bucket: bucket_name, scope: scope_name) end { timeout: Utils::Time.extract_duration(@timeout), adhoc: @adhoc, client_context_id: @client_context_id, max_parallelism: @max_parallelism, readonly: @readonly, flex_index: @flex_index, preserve_expiry: @preserve_expiry, use_replica: @use_replica, scan_wait: Utils::Time.extract_duration(@scan_wait), scan_cap: @scan_cap, pipeline_batch: @pipeline_batch, pipeline_cap: @pipeline_cap, metrics: @metrics, profile: @profile, positional_parameters: export_positional_parameters, named_parameters: export_named_parameters, raw_parameters: @raw_parameters, scan_consistency: @scan_consistency, mutation_state: @mutation_state&.to_a, query_context: @scope_qualifier || default_query_context, } end |