Class: Couchbase::Cluster::QueryOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/couchbase/query_options.rb,
/Users/sergey.auseyau/code/couchbase-ruby-client/lib/couchbase/query_options.rb
more...

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|self| ... } ⇒ QueryOptions

Returns a new instance of QueryOptions.

Yield Parameters:

[View source]

86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/couchbase/query_options.rb', line 86

def initialize
  @timeout = 75_000 # ms
  @adhoc = true
  @raw_parameters = {}
  @positional_parameters = nil
  @named_parameters = nil
  @scan_consistency = nil
  @mutation_state = nil
  @scope_qualifier = nil
  @flex_index = false
  yield self if block_given?
end

Instance Attribute Details

#adhocBoolean

Returns Allows turning this request into a prepared statement query.

Returns:

  • (Boolean)

    Allows turning this request into a prepared statement query


24
25
26
# File 'lib/couchbase/query_options.rb', line 24

def adhoc
  @adhoc
end

#client_context_idString

Returns Provides a custom client context ID for this query.

Returns:

  • (String)

    Provides a custom client context ID for this query


27
28
29
# File 'lib/couchbase/query_options.rb', line 27

def client_context_id
  @client_context_id
end

#flex_indexBoolean

Tells the query engine to use a flex index (utilizing the search service)

Returns:

  • (Boolean)

64
65
66
# File 'lib/couchbase/query_options.rb', line 64

def flex_index
  @flex_index
end

#max_parallelismInteger

Returns Allows overriding the default maximum parallelism for the query execution on the server side.

Returns:

  • (Integer)

    Allows overriding the default maximum parallelism for the query execution on the server side.


30
31
32
# File 'lib/couchbase/query_options.rb', line 30

def max_parallelism
  @max_parallelism
end

#metricsBoolean

Returns Enables per-request metrics in the trailing section of the query.

Returns:

  • (Boolean)

    Enables per-request metrics in the trailing section of the query


55
56
57
# File 'lib/couchbase/query_options.rb', line 55

def metrics
  @metrics
end

#pipeline_batchInteger

Returns Supports customizing the number of items execution operators can batch for fetch from the KV layer on the server.

Returns:

  • (Integer)

    Supports customizing the number of items execution operators can batch for fetch from the KV layer on the server.


48
49
50
# File 'lib/couchbase/query_options.rb', line 48

def pipeline_batch
  @pipeline_batch
end

#pipeline_capInteger

Returns Allows customizing the maximum number of items each execution operator can buffer between various operators on the server.

Returns:

  • (Integer)

    Allows customizing the maximum number of items each execution operator can buffer between various operators on the server.


52
53
54
# File 'lib/couchbase/query_options.rb', line 52

def pipeline_cap
  @pipeline_cap
end

#profile:off, ...

Returns Customize server profile level for this query.

Returns:

  • (:off, :phases, :timings)

    Customize server profile level for this query


58
59
60
# File 'lib/couchbase/query_options.rb', line 58

def profile
  @profile
end

#readonlyBoolean

Returns Allows explicitly marking a query as being readonly and not mutating any documents on the server side.

Returns:

  • (Boolean)

    Allows explicitly marking a query as being readonly and not mutating any documents on the server side.


33
34
35
# File 'lib/couchbase/query_options.rb', line 33

def readonly
  @readonly
end

#scan_capInteger

Returns Supports customizing the maximum buffered channel size between the indexer and the query service.

Returns:

  • (Integer)

    Supports customizing the maximum buffered channel size between the indexer and the query service


45
46
47
# File 'lib/couchbase/query_options.rb', line 45

def scan_cap
  @scan_cap
end

#scan_consistency:not_bounded, :request_plus

Returns:

  • (:not_bounded, :request_plus)

75
76
77
# File 'lib/couchbase/query_options.rb', line 75

def scan_consistency
  @scan_consistency
end

#scan_waitInteger

Note:

that if :not_bounded consistency level is used, this method doesn’t do anything

Allows customizing how long (in milliseconds) the query engine is willing to wait until the index catches up to whatever scan consistency is asked for in this query.

at all. If no value is provided to this method, the server default is used.

Returns:

  • (Integer)

    The maximum duration (in milliseconds) the query engine is willing to wait before failing.


42
43
44
# File 'lib/couchbase/query_options.rb', line 42

def scan_wait
  @scan_wait
end

#scope_qualifierString

Associate scope qualifier (also known as query_context) with the query.

The qualifier must be in form {bucket_name}.{scope_name} or default:{bucket_name}.{scope_name}.

Returns:

  • (String)

72
73
74
# File 'lib/couchbase/query_options.rb', line 72

def scope_qualifier
  @scope_qualifier
end

#timeoutInteger

Returns Timeout in milliseconds.

Returns:

  • (Integer)

    Timeout in milliseconds


21
22
23
# File 'lib/couchbase/query_options.rb', line 21

def timeout
  @timeout
end

Instance Method Details

#consistent_with(mutation_state) ⇒ Object

Note:

overrides consistency level set by #scan_consistency=

Sets the mutation tokens this query should be consistent with

Parameters:

  • mutation_state (MutationState)

    the mutation state containing the mutation tokens

[View source]

128
129
130
131
# File 'lib/couchbase/query_options.rb', line 128

def consistent_with(mutation_state)
  @scan_consistency = nil if @scan_consistency
  @mutation_state = mutation_state
end

#named_parameters(named) ⇒ Object

Sets named parameters for the query

Parameters:

  • named (Hash)

    the key/value map of the parameters to substitute in the statement

[View source]

150
151
152
153
# File 'lib/couchbase/query_options.rb', line 150

def named_parameters(named)
  @named_parameters = named
  @positional_parameters = nil
end

#positional_parameters(positional) ⇒ Object

Sets positional parameters for the query

Parameters:

  • positional (Array)

    the list of parameters that have to be substituted in the statement

[View source]

136
137
138
139
# File 'lib/couchbase/query_options.rb', line 136

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

Parameters:

  • key (String)

    the parameter name (key of the JSON property)

  • value (Object)

    the parameter value (value of the JSON property)

[View source]

103
104
105
# File 'lib/couchbase/query_options.rb', line 103

def raw(key, value)
  @raw_parameters[key] = JSON.generate(value)
end