Class: Couchbase::Protostellar::ResponseConverter::Query Private
- Inherits:
-
Object
- Object
- Couchbase::Protostellar::ResponseConverter::Query
- Defined in:
- lib/couchbase/protostellar/response_converter/query.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- STATUS_MAP =
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.
{ :STATUS_RUNNING => :running, :STATUS_SUCCESS => :success, :STATUS_ERRORS => :errors, :STATUS_COMPLETED => :completed, :STATUS_STOPPED => :stopped, :STATUS_TIMEOUT => :timeout, :STATUS_CLOSED => :closed, :STATUS_FATAL => :fatal, :STATUS_ABORTED => :aborted, :STATUS_UNKNOWN => :unknown, }.freeze
Class Method Summary collapse
- .convert_query_metadata(proto_metadata) ⇒ Object private
- .convert_query_metrics(proto_metrics) ⇒ Object private
- .convert_query_warning(proto_warning) ⇒ Object private
- .to_query_result(resps) ⇒ Object private
Class Method Details
.convert_query_metadata(proto_metadata) ⇒ 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.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/couchbase/protostellar/response_converter/query.rb', line 49 def self.() Couchbase::Cluster::QueryMetaData.new do || .status = STATUS_MAP[.status] .request_id = .request_id .client_context_id = .client_context_id .signature = JSON.parse(.signature) unless .signature.nil? || .signature.empty? .profile = JSON.parse(.profile) unless .profile.nil? || .profile.empty? .metrics = if .has_metrics? convert_query_metrics(.metrics) else Couchbase::Cluster::QueryMetrics.new end .warnings = .warnings.map { |w| convert_query_warning(w) } unless .warnings.empty? end end |
.convert_query_metrics(proto_metrics) ⇒ 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.
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/couchbase/protostellar/response_converter/query.rb', line 69 def self.convert_query_metrics(proto_metrics) Couchbase::Cluster::QueryMetrics.new do |metrics| metrics.elapsed_time = proto_metrics.elapsed_time.nanos + (proto_metrics.elapsed_time.seconds * (10**9)) metrics.execution_time = proto_metrics.execution_time.nanos + (proto_metrics.execution_time.seconds * (10**9)) metrics.result_count = proto_metrics.result_count metrics.result_size = proto_metrics.result_size metrics.mutation_count = proto_metrics.mutation_count metrics.sort_count = proto_metrics.sort_count metrics.error_count = proto_metrics.error_count metrics.warning_count = proto_metrics.warning_count end end |
.convert_query_warning(proto_warning) ⇒ 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.
65 66 67 |
# File 'lib/couchbase/protostellar/response_converter/query.rb', line 65 def self.convert_query_warning(proto_warning) Couchbase::Cluster::QueryWarning.new(proto_warning.code, proto_warning.) end |
.to_query_result(resps) ⇒ 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.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/couchbase/protostellar/response_converter/query.rb', line 38 def self.to_query_result(resps) Couchbase::Cluster::QueryResult.new do |res| rows = [] resps.each do |resp| rows.push(*resp.rows) res. = (resp.) unless resp..nil? end res.instance_variable_set(:@rows, rows) end end |