Class: Couchbase::Options::Analytics

Inherits:
Base
  • Object
show all
Defined in:
lib/couchbase/options.rb,
/home/runner/work/couchbase-ruby-client/couchbase-ruby-client/lib/couchbase/options.rb

Overview

Instance Attribute Summary collapse

Attributes inherited from Base

#client_context, #parent_span, #retry_strategy, #timeout

Instance Method Summary collapse

Constructor Details

#initialize(client_context_id: nil, scan_consistency: nil, readonly: false, priority: nil, transcoder: JsonTranscoder.new, positional_parameters: nil, named_parameters: nil, scope_qualifier: nil, timeout: nil, retry_strategy: nil, client_context: nil, parent_span: nil) {|self| ... } ⇒ Analytics

Note:

Either positional_parameters or named_parameters may be specified.

Creates new instance of options for Cluster#analytics_query

Parameters:

  • client_context_id (String) (defaults to: nil) —

    provides a custom client context ID for this query

  • scan_consistency (Symbol) (defaults to: nil) —

    specifies level of consistency for the query :not_bounded::

    The index will return whatever state it has to the analytics query engine at the time of query.
    
    This is the default (for single-statement requests). No timestamp vector is used in the index scan.
    This is also the fastest mode, because we avoid the cost of obtaining the vector, and we also avoid
    any wait for the index
    

    :request_plus::

    The index will wait until all mutations have been processed at the time of request before being processed
    in the analytics query engine.
    
    This implements strong consistency per request. Before processing the request, a current vector is obtained.
    The vector is used as a lower bound for the statements in the request.
  • readonly (Boolean) (defaults to: false) —

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

  • priority (Boolean) (defaults to: nil) —

    allows to give certain requests higher priority than others

  • transcoder (JsonTranscoder) (defaults to: JsonTranscoder.new) —

    to decode rows

  • positional_parameters (Array<#to_json>, nil) (defaults to: nil) —

    parameters to be used as substitution for numbered macros like $1, $2 in query string

  • named_parameters (Hash<String => #to_json>, nil) (defaults to: nil) —

    parameters to be used as substitution for named macros like $name in query string

  • scope_qualifier (String, nil) (defaults to: nil) —

    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}.

  • timeout (Integer, #in_milliseconds, nil) (defaults to: nil)
  • retry_strategy (Symbol, nil) (defaults to: nil) —

    ignored by this operation

  • client_context (Hash, nil) (defaults to: nil) —

    the client context data, if set

  • parent_span (Span, nil) (defaults to: nil) —

    if set holds the parent span, that should be used for this request

Yield Parameters:

Raises:

  • (ArgumentError)


2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
# File 'lib/couchbase/options.rb', line 2096

def initialize(client_context_id: nil,
               scan_consistency: nil,
               readonly: false,
               priority: nil,
               transcoder: JsonTranscoder.new,
               positional_parameters: nil,
               named_parameters: nil,
               scope_qualifier: 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)
  @client_context_id = client_context_id
  @scan_consistency = scan_consistency
  @readonly = readonly
  @priority = priority
  @transcoder = transcoder
  @positional_parameters = positional_parameters
  @named_parameters = named_parameters
  @scope_qualifier = scope_qualifier
  @raw_parameters = {}
  yield self if block_given?
end

Instance Attribute Details

#client_context_id ⇒ String

Returns:

  • (String)


2054
2055
2056
# File 'lib/couchbase/options.rb', line 2054

def client_context_id
  @client_context_id
end

#priority ⇒ Boolean

Returns:

  • (Boolean)


2057
2058
2059
# File 'lib/couchbase/options.rb', line 2057

def priority
  @priority
end

#readonly ⇒ Boolean

Returns:

  • (Boolean)


2056
2057
2058
# File 'lib/couchbase/options.rb', line 2056

def readonly
  @readonly
end

#scan_consistency ⇒ Symbol

Returns:

  • (Symbol)


2055
2056
2057
# File 'lib/couchbase/options.rb', line 2055

def scan_consistency
  @scan_consistency
end

#scope_qualifier ⇒ String

Returns:

  • (String)


2059
2060
2061
# File 'lib/couchbase/options.rb', line 2059

def scope_qualifier
  @scope_qualifier
end

#transcoder ⇒ JsonTranscoder, #decode(String)

Returns:



2058
2059
2060
# File 'lib/couchbase/options.rb', line 2058

def transcoder
  @transcoder
end

Instance Method Details

#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



2134
2135
2136
2137
# File 'lib/couchbase/options.rb', line 2134

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



2126
2127
2128
2129
# File 'lib/couchbase/options.rb', line 2126

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, Symbol) —

    the parameter name (key of the JSON property), converted with to_s

  • value (Object) —

    the parameter value (value of the JSON property)



2143
2144
2145
# File 'lib/couchbase/options.rb', line 2143

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