couchbase 3.1.1-universal-darwin-20 → 3.2.0-universal-darwin-20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/ext/CMakeLists.txt +3 -1
  4. data/ext/build_version.hxx.in +1 -1
  5. data/ext/cmake/Testing.cmake +1 -0
  6. data/ext/cmake/ThirdPartyDependencies.cmake +6 -0
  7. data/ext/cmake/VersionInfo.cmake +3 -0
  8. data/ext/couchbase/bucket.hxx +47 -28
  9. data/ext/couchbase/cbsasl/client.h +1 -1
  10. data/ext/couchbase/cbsasl/context.cc +1 -1
  11. data/ext/couchbase/cbsasl/context.h +3 -3
  12. data/ext/couchbase/cbsasl/mechanism.cc +5 -8
  13. data/ext/couchbase/cbsasl/mechanism.h +1 -4
  14. data/ext/couchbase/cbsasl/plain/plain.cc +1 -1
  15. data/ext/couchbase/cbsasl/scram-sha/scram-sha.cc +30 -36
  16. data/ext/couchbase/cluster.hxx +40 -22
  17. data/ext/couchbase/cluster_options.hxx +7 -1
  18. data/ext/couchbase/configuration.hxx +37 -16
  19. data/ext/couchbase/couchbase.cxx +1145 -291
  20. data/ext/couchbase/error_map.hxx +1 -1
  21. data/ext/couchbase/errors.hxx +25 -17
  22. data/ext/couchbase/io/dns_client.hxx +3 -3
  23. data/ext/couchbase/io/dns_codec.hxx +4 -5
  24. data/ext/couchbase/io/dns_config.hxx +5 -6
  25. data/ext/couchbase/io/dns_message.hxx +3 -3
  26. data/ext/couchbase/io/http_command.hxx +70 -35
  27. data/ext/couchbase/io/http_session.hxx +4 -3
  28. data/ext/couchbase/io/http_session_manager.hxx +28 -19
  29. data/ext/couchbase/io/mcbp_command.hxx +51 -19
  30. data/ext/couchbase/io/mcbp_context.hxx +1 -1
  31. data/ext/couchbase/io/mcbp_parser.hxx +4 -4
  32. data/ext/couchbase/io/mcbp_session.hxx +91 -101
  33. data/ext/couchbase/io/query_cache.hxx +2 -2
  34. data/ext/couchbase/io/retry_orchestrator.hxx +2 -4
  35. data/ext/couchbase/io/retry_reason.hxx +2 -2
  36. data/ext/couchbase/io/retry_strategy.hxx +1 -6
  37. data/ext/couchbase/io/streams.hxx +7 -7
  38. data/ext/couchbase/metrics/logging_meter.hxx +228 -0
  39. data/ext/couchbase/metrics/logging_meter_options.hxx +28 -0
  40. data/ext/couchbase/metrics/meter.hxx +49 -0
  41. data/ext/couchbase/metrics/noop_meter.hxx +43 -0
  42. data/ext/couchbase/operations.hxx +4 -0
  43. data/ext/couchbase/operations/analytics_dataset_create.hxx +16 -12
  44. data/ext/couchbase/operations/analytics_dataset_drop.hxx +11 -11
  45. data/ext/couchbase/operations/analytics_dataset_get_all.hxx +6 -6
  46. data/ext/couchbase/operations/analytics_dataverse_create.hxx +10 -11
  47. data/ext/couchbase/operations/analytics_dataverse_drop.hxx +10 -11
  48. data/ext/couchbase/operations/analytics_get_pending_mutations.hxx +9 -11
  49. data/ext/couchbase/operations/analytics_index_create.hxx +14 -13
  50. data/ext/couchbase/operations/analytics_index_drop.hxx +18 -12
  51. data/ext/couchbase/operations/analytics_index_get_all.hxx +8 -6
  52. data/ext/couchbase/operations/analytics_link.hxx +39 -0
  53. data/ext/couchbase/operations/analytics_link_azure_blob_external.hxx +145 -0
  54. data/ext/couchbase/operations/analytics_link_connect.hxx +14 -12
  55. data/ext/couchbase/operations/analytics_link_couchbase_remote.hxx +220 -0
  56. data/ext/couchbase/operations/analytics_link_create.hxx +128 -0
  57. data/ext/couchbase/operations/analytics_link_disconnect.hxx +11 -12
  58. data/ext/couchbase/operations/analytics_link_drop.hxx +130 -0
  59. data/ext/couchbase/operations/analytics_link_get_all.hxx +160 -0
  60. data/ext/couchbase/operations/analytics_link_replace.hxx +128 -0
  61. data/ext/couchbase/operations/analytics_link_s3_external.hxx +122 -0
  62. data/ext/couchbase/operations/bucket_create.hxx +8 -8
  63. data/ext/couchbase/operations/bucket_drop.hxx +5 -5
  64. data/ext/couchbase/operations/bucket_flush.hxx +5 -5
  65. data/ext/couchbase/operations/bucket_get.hxx +7 -7
  66. data/ext/couchbase/operations/bucket_get_all.hxx +7 -5
  67. data/ext/couchbase/operations/bucket_settings.hxx +40 -49
  68. data/ext/couchbase/operations/bucket_update.hxx +8 -8
  69. data/ext/couchbase/operations/cluster_developer_preview_enable.hxx +7 -7
  70. data/ext/couchbase/operations/collection_create.hxx +11 -11
  71. data/ext/couchbase/operations/collection_drop.hxx +12 -10
  72. data/ext/couchbase/operations/collections_manifest_get.hxx +3 -3
  73. data/ext/couchbase/operations/design_document.hxx +2 -2
  74. data/ext/couchbase/operations/document_analytics.hxx +29 -36
  75. data/ext/couchbase/operations/document_append.hxx +3 -3
  76. data/ext/couchbase/operations/document_decrement.hxx +3 -3
  77. data/ext/couchbase/operations/document_exists.hxx +2 -2
  78. data/ext/couchbase/operations/document_get.hxx +3 -3
  79. data/ext/couchbase/operations/document_get_and_lock.hxx +5 -3
  80. data/ext/couchbase/operations/document_get_and_touch.hxx +5 -3
  81. data/ext/couchbase/operations/document_get_projected.hxx +10 -11
  82. data/ext/couchbase/operations/document_increment.hxx +3 -3
  83. data/ext/couchbase/operations/document_insert.hxx +3 -3
  84. data/ext/couchbase/operations/document_lookup_in.hxx +12 -18
  85. data/ext/couchbase/operations/document_mutate_in.hxx +13 -18
  86. data/ext/couchbase/operations/document_prepend.hxx +3 -3
  87. data/ext/couchbase/operations/document_query.hxx +39 -41
  88. data/ext/couchbase/operations/document_remove.hxx +3 -3
  89. data/ext/couchbase/operations/document_replace.hxx +3 -3
  90. data/ext/couchbase/operations/document_search.hxx +56 -61
  91. data/ext/couchbase/operations/document_touch.hxx +3 -3
  92. data/ext/couchbase/operations/document_unlock.hxx +3 -3
  93. data/ext/couchbase/operations/document_upsert.hxx +3 -3
  94. data/ext/couchbase/operations/document_view.hxx +23 -23
  95. data/ext/couchbase/operations/group_drop.hxx +5 -5
  96. data/ext/couchbase/operations/group_get.hxx +7 -7
  97. data/ext/couchbase/operations/group_get_all.hxx +6 -6
  98. data/ext/couchbase/operations/group_upsert.hxx +11 -11
  99. data/ext/couchbase/operations/http_noop.hxx +6 -6
  100. data/ext/couchbase/operations/mcbp_noop.hxx +3 -3
  101. data/ext/couchbase/operations/query_index_build_deferred.hxx +6 -6
  102. data/ext/couchbase/operations/query_index_create.hxx +10 -8
  103. data/ext/couchbase/operations/query_index_drop.hxx +8 -8
  104. data/ext/couchbase/operations/query_index_get_all.hxx +43 -39
  105. data/ext/couchbase/operations/rbac.hxx +40 -63
  106. data/ext/couchbase/operations/role_get_all.hxx +6 -6
  107. data/ext/couchbase/operations/scope_create.hxx +10 -10
  108. data/ext/couchbase/operations/scope_drop.hxx +9 -9
  109. data/ext/couchbase/operations/scope_get_all.hxx +8 -8
  110. data/ext/couchbase/operations/search_get_stats.hxx +5 -3
  111. data/ext/couchbase/operations/search_index.hxx +6 -15
  112. data/ext/couchbase/operations/search_index_analyze_document.hxx +11 -11
  113. data/ext/couchbase/operations/search_index_control_ingest.hxx +9 -9
  114. data/ext/couchbase/operations/search_index_control_plan_freeze.hxx +9 -9
  115. data/ext/couchbase/operations/search_index_control_query.hxx +9 -9
  116. data/ext/couchbase/operations/search_index_drop.hxx +11 -9
  117. data/ext/couchbase/operations/search_index_get.hxx +11 -9
  118. data/ext/couchbase/operations/search_index_get_all.hxx +11 -11
  119. data/ext/couchbase/operations/search_index_get_documents_count.hxx +10 -10
  120. data/ext/couchbase/operations/search_index_get_stats.hxx +10 -8
  121. data/ext/couchbase/operations/search_index_upsert.hxx +12 -10
  122. data/ext/couchbase/operations/user_drop.hxx +5 -5
  123. data/ext/couchbase/operations/user_get.hxx +7 -7
  124. data/ext/couchbase/operations/user_get_all.hxx +6 -6
  125. data/ext/couchbase/operations/user_upsert.hxx +9 -9
  126. data/ext/couchbase/operations/view_index_drop.hxx +10 -10
  127. data/ext/couchbase/operations/view_index_get.hxx +13 -15
  128. data/ext/couchbase/operations/view_index_get_all.hxx +17 -20
  129. data/ext/couchbase/operations/view_index_upsert.hxx +9 -7
  130. data/ext/couchbase/origin.hxx +14 -10
  131. data/ext/couchbase/platform/backtrace.c +1 -1
  132. data/ext/couchbase/platform/base64.cc +5 -5
  133. data/ext/couchbase/platform/base64.h +2 -5
  134. data/ext/couchbase/protocol/client_opcode.hxx +7 -4
  135. data/ext/couchbase/protocol/client_request.hxx +2 -2
  136. data/ext/couchbase/protocol/client_response.hxx +41 -16
  137. data/ext/couchbase/protocol/cmd_append.hxx +17 -16
  138. data/ext/couchbase/protocol/cmd_cluster_map_change_notification.hxx +4 -4
  139. data/ext/couchbase/protocol/cmd_decrement.hxx +10 -11
  140. data/ext/couchbase/protocol/cmd_exists.hxx +12 -15
  141. data/ext/couchbase/protocol/cmd_get.hxx +11 -14
  142. data/ext/couchbase/protocol/cmd_get_and_lock.hxx +10 -12
  143. data/ext/couchbase/protocol/cmd_get_and_touch.hxx +10 -12
  144. data/ext/couchbase/protocol/cmd_get_cluster_config.hxx +13 -18
  145. data/ext/couchbase/protocol/cmd_get_collection_id.hxx +12 -15
  146. data/ext/couchbase/protocol/cmd_get_collections_manifest.hxx +12 -16
  147. data/ext/couchbase/protocol/cmd_get_error_map.hxx +14 -17
  148. data/ext/couchbase/protocol/cmd_hello.hxx +8 -10
  149. data/ext/couchbase/protocol/cmd_increment.hxx +9 -10
  150. data/ext/couchbase/protocol/cmd_insert.hxx +9 -9
  151. data/ext/couchbase/protocol/cmd_lookup_in.hxx +12 -13
  152. data/ext/couchbase/protocol/cmd_mutate_in.hxx +11 -11
  153. data/ext/couchbase/protocol/cmd_noop.hxx +16 -20
  154. data/ext/couchbase/protocol/cmd_prepend.hxx +9 -10
  155. data/ext/couchbase/protocol/cmd_remove.hxx +10 -13
  156. data/ext/couchbase/protocol/cmd_replace.hxx +7 -7
  157. data/ext/couchbase/protocol/cmd_sasl_auth.hxx +8 -10
  158. data/ext/couchbase/protocol/cmd_sasl_list_mechs.hxx +10 -15
  159. data/ext/couchbase/protocol/cmd_sasl_step.hxx +10 -12
  160. data/ext/couchbase/protocol/cmd_select_bucket.hxx +14 -18
  161. data/ext/couchbase/protocol/cmd_touch.hxx +8 -11
  162. data/ext/couchbase/protocol/cmd_unlock.hxx +10 -14
  163. data/ext/couchbase/protocol/cmd_upsert.hxx +8 -8
  164. data/ext/couchbase/protocol/datatype.hxx +3 -3
  165. data/ext/couchbase/protocol/durability_level.hxx +2 -2
  166. data/ext/couchbase/protocol/frame_info_id.hxx +4 -4
  167. data/ext/couchbase/protocol/hello_feature.hxx +2 -2
  168. data/ext/couchbase/protocol/magic.hxx +2 -2
  169. data/ext/couchbase/protocol/server_opcode.hxx +2 -2
  170. data/ext/couchbase/protocol/server_request.hxx +1 -1
  171. data/ext/couchbase/protocol/status.hxx +4 -7
  172. data/ext/couchbase/protocol/unsigned_leb128.h +5 -20
  173. data/ext/couchbase/service_type.hxx +4 -4
  174. data/ext/couchbase/tracing/constants.hxx +261 -0
  175. data/ext/couchbase/tracing/noop_tracer.hxx +50 -0
  176. data/ext/couchbase/tracing/request_tracer.hxx +77 -0
  177. data/ext/couchbase/tracing/threshold_logging_options.hxx +64 -0
  178. data/ext/couchbase/tracing/threshold_logging_tracer.hxx +366 -0
  179. data/ext/couchbase/utils/byteswap.hxx +1 -1
  180. data/ext/couchbase/utils/connection_string.hxx +21 -1
  181. data/ext/couchbase/utils/name_codec.hxx +41 -0
  182. data/ext/couchbase/utils/url_codec.hxx +236 -0
  183. data/ext/couchbase/version.hxx +1 -1
  184. data/ext/test/CMakeLists.txt +1 -0
  185. data/ext/test/test_native_trivial_query.cxx +60 -0
  186. data/ext/third_party/hdr_histogram_c/CMakeLists.txt +84 -0
  187. data/ext/third_party/hdr_histogram_c/COPYING.txt +121 -0
  188. data/ext/third_party/hdr_histogram_c/LICENSE.txt +41 -0
  189. data/ext/third_party/hdr_histogram_c/config.cmake.in +6 -0
  190. data/ext/third_party/hdr_histogram_c/src/CMakeLists.txt +83 -0
  191. data/ext/third_party/hdr_histogram_c/src/hdr_atomic.h +146 -0
  192. data/ext/third_party/hdr_histogram_c/src/hdr_encoding.c +322 -0
  193. data/ext/third_party/hdr_histogram_c/src/hdr_encoding.h +79 -0
  194. data/ext/third_party/hdr_histogram_c/src/hdr_endian.h +116 -0
  195. data/ext/third_party/hdr_histogram_c/src/hdr_histogram.c +1196 -0
  196. data/ext/third_party/hdr_histogram_c/src/hdr_histogram.h +516 -0
  197. data/ext/third_party/hdr_histogram_c/src/hdr_histogram_log.c +1290 -0
  198. data/ext/third_party/hdr_histogram_c/src/hdr_histogram_log.h +236 -0
  199. data/ext/third_party/hdr_histogram_c/src/hdr_histogram_log_no_op.c +171 -0
  200. data/ext/third_party/hdr_histogram_c/src/hdr_interval_recorder.c +227 -0
  201. data/ext/third_party/hdr_histogram_c/src/hdr_interval_recorder.h +109 -0
  202. data/ext/third_party/hdr_histogram_c/src/hdr_malloc.h +19 -0
  203. data/ext/third_party/hdr_histogram_c/src/hdr_tests.h +22 -0
  204. data/ext/third_party/hdr_histogram_c/src/hdr_thread.c +108 -0
  205. data/ext/third_party/hdr_histogram_c/src/hdr_thread.h +55 -0
  206. data/ext/third_party/hdr_histogram_c/src/hdr_time.c +98 -0
  207. data/ext/third_party/hdr_histogram_c/src/hdr_time.h +49 -0
  208. data/ext/third_party/hdr_histogram_c/src/hdr_writer_reader_phaser.c +143 -0
  209. data/ext/third_party/hdr_histogram_c/src/hdr_writer_reader_phaser.h +51 -0
  210. data/lib/couchbase/cluster.rb +1 -0
  211. data/lib/couchbase/errors.rb +3 -0
  212. data/lib/couchbase/libcouchbase.bundle +0 -0
  213. data/lib/couchbase/management/analytics_index_manager.rb +920 -226
  214. data/lib/couchbase/management/bucket_manager.rb +207 -69
  215. data/lib/couchbase/management/collection_manager.rb +173 -61
  216. data/lib/couchbase/management/query_index_manager.rb +357 -169
  217. data/lib/couchbase/options.rb +75 -3
  218. data/lib/couchbase/scope.rb +102 -0
  219. data/lib/couchbase/utils/time.rb +4 -0
  220. data/lib/couchbase/version.rb +6 -6
  221. metadata +48 -5
@@ -40,6 +40,13 @@ module Couchbase
40
40
  @parent_span = parent_span
41
41
  yield self if block_given?
42
42
  end
43
+
44
+ # @api private
45
+ def to_backend
46
+ {
47
+ timeout: @timeout.respond_to?(:in_milliseconds) ? @timeout.public_send(:in_milliseconds) : @timeout,
48
+ }
49
+ end
43
50
  end
44
51
 
45
52
  # Options for {Collection#get}
@@ -128,7 +135,7 @@ module Couchbase
128
135
  # @param [Hash, nil] client_context the client context data, if set
129
136
  # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
130
137
  #
131
- # @yieldparam [Get] self
138
+ # @yieldparam [GetMulti] self
132
139
  def initialize(transcoder: JsonTranscoder.new,
133
140
  timeout: nil,
134
141
  retry_strategy: nil,
@@ -1142,13 +1149,53 @@ module Couchbase
1142
1149
  class Cluster
1143
1150
  attr_accessor :authenticator # @return [PasswordAuthenticator, CertificateAuthenticator]
1144
1151
 
1152
+ attr_accessor :enable_metrics # @return [Boolean]
1153
+ attr_accessor :metrics_emit_interval # @return [nil, Integer, #in_milliseconds]
1154
+ attr_accessor :enable_tracing # @return [Boolean]
1155
+ attr_accessor :orphaned_emit_interval # @return [nil, Integer, #in_milliseconds]
1156
+ attr_accessor :orphaned_sample_size # @return [nil, Integer]
1157
+ attr_accessor :threshold_emit_interval # @return [nil, Integer, #in_milliseconds]
1158
+ attr_accessor :threshold_sample_size # @return [nil, Integer]
1159
+ attr_accessor :key_value_threshold # @return [nil, Integer, #in_milliseconds]
1160
+ attr_accessor :query_threshold # @return [nil, Integer, #in_milliseconds]
1161
+ attr_accessor :view_threshold # @return [nil, Integer, #in_milliseconds]
1162
+ attr_accessor :search_threshold # @return [nil, Integer, #in_milliseconds]
1163
+ attr_accessor :analytics_threshold # @return [nil, Integer, #in_milliseconds]
1164
+ attr_accessor :management_threshold # @return [nil, Integer, #in_milliseconds]
1165
+
1145
1166
  # Creates an instance of options for {Couchbase::Cluster.connect}
1146
1167
  #
1147
1168
  # @param [PasswordAuthenticator, CertificateAuthenticator] authenticator
1148
1169
  #
1149
1170
  # @yieldparam [Cluster] self
1150
- def initialize(authenticator: nil)
1171
+ def initialize(authenticator: nil,
1172
+ enable_metrics: nil,
1173
+ metrics_emit_interval: nil,
1174
+ enable_tracing: nil,
1175
+ orphaned_emit_interval: nil,
1176
+ orphaned_sample_size: nil,
1177
+ threshold_emit_interval: nil,
1178
+ threshold_sample_size: nil,
1179
+ key_value_threshold: nil,
1180
+ query_threshold: nil,
1181
+ view_threshold: nil,
1182
+ search_threshold: nil,
1183
+ analytics_threshold: nil,
1184
+ management_threshold: nil)
1151
1185
  @authenticator = authenticator
1186
+ @enable_metrics = enable_metrics
1187
+ @metrics_emit_interval = metrics_emit_interval
1188
+ @enable_tracing = enable_tracing
1189
+ @orphaned_emit_interval = orphaned_emit_interval
1190
+ @orphaned_sample_size = orphaned_sample_size
1191
+ @threshold_emit_interval = threshold_emit_interval
1192
+ @threshold_sample_size = threshold_sample_size
1193
+ @key_value_threshold = key_value_threshold
1194
+ @query_threshold = query_threshold
1195
+ @view_threshold = view_threshold
1196
+ @search_threshold = search_threshold
1197
+ @analytics_threshold = analytics_threshold
1198
+ @management_threshold = management_threshold
1152
1199
  yield self if block_given?
1153
1200
  end
1154
1201
 
@@ -1157,6 +1204,25 @@ module Couchbase
1157
1204
  def authenticate(username, password)
1158
1205
  @authenticator = PasswordAuthenticator.new(username, password)
1159
1206
  end
1207
+
1208
+ # @api private
1209
+ def to_backend
1210
+ {
1211
+ enable_metrics: @enable_metrics,
1212
+ metrics_emit_interval: Utils::Time.extract_duration(@metrics_emit_interval),
1213
+ enable_tracing: @enable_tracing,
1214
+ orphaned_emit_interval: Utils::Time.extract_duration(@orphaned_emit_interval),
1215
+ orphaned_sample_size: @orphaned_sample_size,
1216
+ threshold_emit_interval: Utils::Time.extract_duration(@threshold_emit_interval),
1217
+ threshold_sample_size: @threshold_sample_size,
1218
+ key_value_threshold: Utils::Time.extract_duration(@key_value_threshold),
1219
+ query_threshold: Utils::Time.extract_duration(@query_threshold),
1220
+ view_threshold: Utils::Time.extract_duration(@view_threshold),
1221
+ search_threshold: Utils::Time.extract_duration(@search_threshold),
1222
+ analytics_threshold: Utils::Time.extract_duration(@analytics_threshold),
1223
+ management_threshold: Utils::Time.extract_duration(@management_threshold),
1224
+ }
1225
+ end
1160
1226
  end
1161
1227
 
1162
1228
  # Options for {Couchbase::Cluster#diagnostics}
@@ -1563,6 +1629,7 @@ module Couchbase
1563
1629
  attr_accessor :highlight_fields # @return [Array<String>]
1564
1630
  attr_accessor :fields # @return [Array<String>]
1565
1631
  attr_accessor :disable_scoring # @return [Boolean]
1632
+ attr_accessor :collections # @return [Array<String>, nil]
1566
1633
  attr_accessor :sort # @return [Array<String, Cluster::SearchSort>]
1567
1634
  attr_accessor :facets # @return [Hash<String => Cluster::SearchFacet>]
1568
1635
  attr_accessor :transcoder # @return [JsonTranscoder, #decode(String)]
@@ -1578,6 +1645,7 @@ module Couchbase
1578
1645
  # were stored while indexing
1579
1646
  # @param [MutationState] mutation_state the mutation tokens this query should be consistent with
1580
1647
  # @param [Boolean] disable_scoring If set to true, the server will not perform any scoring on the hits
1648
+ # @param [Array<String>, nil] collections list of collections by which to filter the results
1581
1649
  # @param [Array<String, Cluster::SearchSort>] sort Ordering rules to apply to the results. The list might contain
1582
1650
  # either strings or special objects, that derive from {Cluster::SearchSort}. In case of String, the value
1583
1651
  # represents the name of the field with optional +-+ in front of the name, which will turn on descending mode
@@ -1601,6 +1669,7 @@ module Couchbase
1601
1669
  fields: nil,
1602
1670
  mutation_state: nil,
1603
1671
  disable_scoring: false,
1672
+ collections: nil,
1604
1673
  sort: nil,
1605
1674
  facets: nil,
1606
1675
  transcoder: JsonTranscoder.new,
@@ -1616,6 +1685,7 @@ module Couchbase
1616
1685
  @highlight_fields = highlight_fields
1617
1686
  @fields = fields
1618
1687
  @disable_scoring = disable_scoring
1688
+ @collections = collections
1619
1689
  @sort = sort
1620
1690
  @facets = facets
1621
1691
  @transcoder = transcoder
@@ -1658,13 +1728,15 @@ module Couchbase
1658
1728
  attr_reader :scan_consistency
1659
1729
 
1660
1730
  # @api private
1661
- def to_backend
1731
+ def to_backend(scope_name: nil)
1662
1732
  {
1663
1733
  timeout: @timeout.respond_to?(:in_milliseconds) ? @timeout.public_send(:in_milliseconds) : @timeout,
1664
1734
  limit: @limit,
1665
1735
  skip: @skip,
1666
1736
  explain: @explain,
1667
1737
  disable_scoring: @disable_scoring,
1738
+ scope: scope_name,
1739
+ collections: scope_name ? @collections : nil,
1668
1740
  highlight_style: @highlight_style,
1669
1741
  highlight_fields: @highlight_fields,
1670
1742
  fields: @fields,
@@ -124,5 +124,107 @@ module Couchbase
124
124
  res.instance_variable_set("@rows", resp[:rows])
125
125
  end
126
126
  end
127
+
128
+ # Performs a Full Text Search (FTS) query
129
+ #
130
+ # @param [String] index_name the name of the search index
131
+ # @param [SearchQuery] query the query tree
132
+ # @param [Options::Search] options the query tree
133
+ #
134
+ # @example Return first 10 results of "hop beer" query and request highlighting
135
+ # cluster.search_query("travel_index", Cluster::SearchQuery.match_phrase("green"),
136
+ # Options::Search(
137
+ # limit: 10,
138
+ # collections: ["landmark", "hotel"]
139
+ # fields: %w[name],
140
+ # highlight_style: :html,
141
+ # highlight_fields: %w[name description]
142
+ # ))
143
+ #
144
+ # @return [SearchResult]
145
+ def search_query(index_name, query, options = Options::Search.new)
146
+ resp = @backend.document_search(index_name, JSON.generate(query), options.to_backend(scope_name: @name))
147
+
148
+ SearchResult.new do |res|
149
+ res.meta_data = SearchMetaData.new do |meta|
150
+ meta.metrics.max_score = resp[:meta_data][:metrics][:max_score]
151
+ meta.metrics.error_partition_count = resp[:meta_data][:metrics][:error_partition_count]
152
+ meta.metrics.success_partition_count = resp[:meta_data][:metrics][:success_partition_count]
153
+ meta.metrics.took = resp[:meta_data][:metrics][:took]
154
+ meta.metrics.total_rows = resp[:meta_data][:metrics][:total_rows]
155
+ meta.errors = resp[:meta_data][:errors]
156
+ end
157
+ res.rows = resp[:rows].map do |r|
158
+ SearchRow.new do |row|
159
+ row.transcoder = options.transcoder
160
+ row.index = r[:index]
161
+ row.id = r[:id]
162
+ row.score = r[:score]
163
+ row.fragments = r[:fragments]
164
+ row.locations = SearchRowLocations.new(
165
+ r[:locations].map do |loc|
166
+ SearchRowLocation.new do |location|
167
+ location.field = loc[:field]
168
+ location.term = loc[:term]
169
+ location.position = loc[:position]
170
+ location.start_offset = loc[:start_offset]
171
+ location.end_offset = loc[:end_offset]
172
+ location.array_positions = loc[:array_positions]
173
+ end
174
+ end
175
+ )
176
+ row.instance_variable_set("@fields", r[:fields])
177
+ row.explanation = JSON.parse(r[:explanation]) if r[:explanation]
178
+ end
179
+ end
180
+ if resp[:facets]
181
+ res.facets = resp[:facets].each_with_object({}) do |(k, v), o|
182
+ facet = case options.facets[k]
183
+ when SearchFacet::SearchFacetTerm
184
+ SearchFacetResult::TermFacetResult.new do |f|
185
+ f.terms =
186
+ if v[:terms]
187
+ v[:terms].map do |t|
188
+ SearchFacetResult::TermFacetResult::TermFacet.new(t[:term], t[:count])
189
+ end
190
+ else
191
+ []
192
+ end
193
+ end
194
+ when SearchFacet::SearchFacetDateRange
195
+ SearchFacetResult::DateRangeFacetResult.new do |f|
196
+ f.date_ranges =
197
+ if v[:date_ranges]
198
+ v[:date_ranges].map do |r|
199
+ SearchFacetResult::DateRangeFacetResult::DateRangeFacet.new(r[:name], r[:count], r[:start_time], r[:end_time])
200
+ end
201
+ else
202
+ []
203
+ end
204
+ end
205
+ when SearchFacet::SearchFacetNumericRange
206
+ SearchFacetResult::NumericRangeFacetResult.new do |f|
207
+ f.numeric_ranges =
208
+ if v[:numeric_ranges]
209
+ v[:numeric_ranges].map do |r|
210
+ SearchFacetResult::NumericRangeFacetResult::NumericRangeFacet.new(r[:name], r[:count], r[:min], r[:max])
211
+ end
212
+ else
213
+ []
214
+ end
215
+ end
216
+ else
217
+ next # ignore unknown facet result
218
+ end
219
+ facet.name = v[:name]
220
+ facet.field = v[:field]
221
+ facet.total = v[:total]
222
+ facet.missing = v[:missing]
223
+ facet.other = v[:other]
224
+ o[k] = facet
225
+ end
226
+ end
227
+ end
228
+ end
127
229
  end
128
230
  end
@@ -47,6 +47,10 @@ module Couchbase
47
47
  time_or_duration
48
48
  end
49
49
  end
50
+
51
+ def extract_duration(number_or_duration)
52
+ number_or_duration.respond_to?(:in_milliseconds) ? number_or_duration.public_send(:in_milliseconds) : number_or_duration
53
+ end
50
54
  end
51
55
  end
52
56
  end
@@ -17,15 +17,15 @@ module Couchbase
17
17
  #
18
18
  # @example Display version and all dependencies in command line
19
19
  # # ruby -rcouchbase -e 'pp Couchbase::VERSION'
20
- # {:sdk=>"3.1.0",
21
- # :backend=>"1.4.0",
22
- # :build_timestamp=>"2021-03-24 11:25:34",
23
- # :revision=>"7ba4f7d8b5b0b59b9971ad765876413be3064adb",
20
+ # {:sdk=>"3.1.1",
21
+ # :backend=>"1.5.0",
22
+ # :build_timestamp=>"2021-04-08 16:29:43",
23
+ # :revision=>"a79d098eb238b3883e49e1738c35167642e8834f",
24
24
  # :platform=>"Linux-4.15.0-66-generic",
25
25
  # :cpu=>"x86_64",
26
26
  # :cc=>"GNU 9.3.1",
27
27
  # :cxx=>"GNU 9.3.1",
28
- # :ruby=>"3.0.0",
28
+ # :ruby=>"2.7.0",
29
29
  # :spdlog=>"1.8.1",
30
30
  # :asio=>"1.18.0",
31
31
  # :snappy=>"1.1.8",
@@ -33,5 +33,5 @@ module Couchbase
33
33
  # :openssl_headers=>"OpenSSL 1.1.1g FIPS 21 Apr 2020",
34
34
  # :openssl_runtime=>"OpenSSL 1.1.1g FIPS 21 Apr 2020"}
35
35
  VERSION = {} unless defined?(VERSION) # rubocop:disable Style/MutableConstant
36
- VERSION.update(:sdk => "3.1.1".freeze)
36
+ VERSION.update(:sdk => "3.2.0".freeze)
37
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: couchbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.2.0
5
5
  platform: universal-darwin-20
6
6
  authors:
7
7
  - Sergey Avseyev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-08 00:00:00.000000000 Z
11
+ date: 2021-08-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Modern SDK for Couchbase Server
14
14
  email:
@@ -88,6 +88,10 @@ files:
88
88
  - ext/couchbase/io/retry_reason.hxx
89
89
  - ext/couchbase/io/retry_strategy.hxx
90
90
  - ext/couchbase/io/streams.hxx
91
+ - ext/couchbase/metrics/logging_meter.hxx
92
+ - ext/couchbase/metrics/logging_meter_options.hxx
93
+ - ext/couchbase/metrics/meter.hxx
94
+ - ext/couchbase/metrics/noop_meter.hxx
91
95
  - ext/couchbase/mutation_token.hxx
92
96
  - ext/couchbase/operations.hxx
93
97
  - ext/couchbase/operations/analytics_dataset_create.hxx
@@ -99,8 +103,16 @@ files:
99
103
  - ext/couchbase/operations/analytics_index_create.hxx
100
104
  - ext/couchbase/operations/analytics_index_drop.hxx
101
105
  - ext/couchbase/operations/analytics_index_get_all.hxx
106
+ - ext/couchbase/operations/analytics_link.hxx
107
+ - ext/couchbase/operations/analytics_link_azure_blob_external.hxx
102
108
  - ext/couchbase/operations/analytics_link_connect.hxx
109
+ - ext/couchbase/operations/analytics_link_couchbase_remote.hxx
110
+ - ext/couchbase/operations/analytics_link_create.hxx
103
111
  - ext/couchbase/operations/analytics_link_disconnect.hxx
112
+ - ext/couchbase/operations/analytics_link_drop.hxx
113
+ - ext/couchbase/operations/analytics_link_get_all.hxx
114
+ - ext/couchbase/operations/analytics_link_replace.hxx
115
+ - ext/couchbase/operations/analytics_link_s3_external.hxx
104
116
  - ext/couchbase/operations/bucket_create.hxx
105
117
  - ext/couchbase/operations/bucket_drop.hxx
106
118
  - ext/couchbase/operations/bucket_flush.hxx
@@ -225,9 +237,15 @@ files:
225
237
  - ext/couchbase/protocol/unsigned_leb128.h
226
238
  - ext/couchbase/service_type.hxx
227
239
  - ext/couchbase/timeout_defaults.hxx
240
+ - ext/couchbase/tracing/constants.hxx
241
+ - ext/couchbase/tracing/noop_tracer.hxx
242
+ - ext/couchbase/tracing/request_tracer.hxx
243
+ - ext/couchbase/tracing/threshold_logging_options.hxx
244
+ - ext/couchbase/tracing/threshold_logging_tracer.hxx
228
245
  - ext/couchbase/utils/byteswap.hxx
229
246
  - ext/couchbase/utils/connection_string.hxx
230
247
  - ext/couchbase/utils/crc32.hxx
248
+ - ext/couchbase/utils/name_codec.hxx
231
249
  - ext/couchbase/utils/url_codec.hxx
232
250
  - ext/couchbase/version.hxx
233
251
  - ext/extconf.rb
@@ -238,6 +256,7 @@ files:
238
256
  - ext/test/test_native_binary_operations.cxx
239
257
  - ext/test/test_native_diagnostics.cxx
240
258
  - ext/test/test_native_trivial_crud.cxx
259
+ - ext/test/test_native_trivial_query.cxx
241
260
  - ext/test/test_ruby_trivial_crud.cxx
242
261
  - ext/test/test_ruby_trivial_query.cxx
243
262
  - ext/third_party/asio/asio/include/asio.hpp
@@ -812,6 +831,30 @@ files:
812
831
  - ext/third_party/gsl/include/gsl/span
813
832
  - ext/third_party/gsl/include/gsl/span_ext
814
833
  - ext/third_party/gsl/include/gsl/string_span
834
+ - ext/third_party/hdr_histogram_c/CMakeLists.txt
835
+ - ext/third_party/hdr_histogram_c/COPYING.txt
836
+ - ext/third_party/hdr_histogram_c/LICENSE.txt
837
+ - ext/third_party/hdr_histogram_c/config.cmake.in
838
+ - ext/third_party/hdr_histogram_c/src/CMakeLists.txt
839
+ - ext/third_party/hdr_histogram_c/src/hdr_atomic.h
840
+ - ext/third_party/hdr_histogram_c/src/hdr_encoding.c
841
+ - ext/third_party/hdr_histogram_c/src/hdr_encoding.h
842
+ - ext/third_party/hdr_histogram_c/src/hdr_endian.h
843
+ - ext/third_party/hdr_histogram_c/src/hdr_histogram.c
844
+ - ext/third_party/hdr_histogram_c/src/hdr_histogram.h
845
+ - ext/third_party/hdr_histogram_c/src/hdr_histogram_log.c
846
+ - ext/third_party/hdr_histogram_c/src/hdr_histogram_log.h
847
+ - ext/third_party/hdr_histogram_c/src/hdr_histogram_log_no_op.c
848
+ - ext/third_party/hdr_histogram_c/src/hdr_interval_recorder.c
849
+ - ext/third_party/hdr_histogram_c/src/hdr_interval_recorder.h
850
+ - ext/third_party/hdr_histogram_c/src/hdr_malloc.h
851
+ - ext/third_party/hdr_histogram_c/src/hdr_tests.h
852
+ - ext/third_party/hdr_histogram_c/src/hdr_thread.c
853
+ - ext/third_party/hdr_histogram_c/src/hdr_thread.h
854
+ - ext/third_party/hdr_histogram_c/src/hdr_time.c
855
+ - ext/third_party/hdr_histogram_c/src/hdr_time.h
856
+ - ext/third_party/hdr_histogram_c/src/hdr_writer_reader_phaser.c
857
+ - ext/third_party/hdr_histogram_c/src/hdr_writer_reader_phaser.h
815
858
  - ext/third_party/http_parser/LICENSE-MIT
816
859
  - ext/third_party/http_parser/http_parser.c
817
860
  - ext/third_party/http_parser/http_parser.h
@@ -1375,9 +1418,9 @@ metadata:
1375
1418
  homepage_uri: https://docs.couchbase.com/ruby-sdk/3.0/hello-world/start-using-sdk.html
1376
1419
  bug_tracker_uri: https://couchbase.com/issues/browse/RCBC
1377
1420
  mailing_list_uri: https://forums.couchbase.com/c/ruby-sdk
1378
- source_code_uri: https://github.com/couchbase/couchbase-ruby-client/tree/3.1.1
1379
- changelog_uri: https://github.com/couchbase/couchbase-ruby-client/releases/tag/3.1.1
1380
- documentation_uri: https://docs.couchbase.com/sdk-api/couchbase-ruby-client-3.1.1/index.html
1421
+ source_code_uri: https://github.com/couchbase/couchbase-ruby-client/tree/3.2.0
1422
+ changelog_uri: https://github.com/couchbase/couchbase-ruby-client/releases/tag/3.2.0
1423
+ documentation_uri: https://docs.couchbase.com/sdk-api/couchbase-ruby-client-3.2.0/index.html
1381
1424
  github_repo: ssh://github.com/couchbase/couchbase-ruby-client
1382
1425
  post_install_message:
1383
1426
  rdoc_options: