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
@@ -0,0 +1,121 @@
1
+ Creative Commons Legal Code
2
+
3
+ CC0 1.0 Universal
4
+
5
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6
+ LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9
+ REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10
+ PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11
+ THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12
+ HEREUNDER.
13
+
14
+ Statement of Purpose
15
+
16
+ The laws of most jurisdictions throughout the world automatically confer
17
+ exclusive Copyright and Related Rights (defined below) upon the creator
18
+ and subsequent owner(s) (each and all, an "owner") of an original work of
19
+ authorship and/or a database (each, a "Work").
20
+
21
+ Certain owners wish to permanently relinquish those rights to a Work for
22
+ the purpose of contributing to a commons of creative, cultural and
23
+ scientific works ("Commons") that the public can reliably and without fear
24
+ of later claims of infringement build upon, modify, incorporate in other
25
+ works, reuse and redistribute as freely as possible in any form whatsoever
26
+ and for any purposes, including without limitation commercial purposes.
27
+ These owners may contribute to the Commons to promote the ideal of a free
28
+ culture and the further production of creative, cultural and scientific
29
+ works, or to gain reputation or greater distribution for their Work in
30
+ part through the use and efforts of others.
31
+
32
+ For these and/or other purposes and motivations, and without any
33
+ expectation of additional consideration or compensation, the person
34
+ associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35
+ is an owner of Copyright and Related Rights in the Work, voluntarily
36
+ elects to apply CC0 to the Work and publicly distribute the Work under its
37
+ terms, with knowledge of his or her Copyright and Related Rights in the
38
+ Work and the meaning and intended legal effect of CC0 on those rights.
39
+
40
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
41
+ protected by copyright and related or neighboring rights ("Copyright and
42
+ Related Rights"). Copyright and Related Rights include, but are not
43
+ limited to, the following:
44
+
45
+ i. the right to reproduce, adapt, distribute, perform, display,
46
+ communicate, and translate a Work;
47
+ ii. moral rights retained by the original author(s) and/or performer(s);
48
+ iii. publicity and privacy rights pertaining to a person's image or
49
+ likeness depicted in a Work;
50
+ iv. rights protecting against unfair competition in regards to a Work,
51
+ subject to the limitations in paragraph 4(a), below;
52
+ v. rights protecting the extraction, dissemination, use and reuse of data
53
+ in a Work;
54
+ vi. database rights (such as those arising under Directive 96/9/EC of the
55
+ European Parliament and of the Council of 11 March 1996 on the legal
56
+ protection of databases, and under any national implementation
57
+ thereof, including any amended or successor version of such
58
+ directive); and
59
+ vii. other similar, equivalent or corresponding rights throughout the
60
+ world based on applicable law or treaty, and any national
61
+ implementations thereof.
62
+
63
+ 2. Waiver. To the greatest extent permitted by, but not in contravention
64
+ of, applicable law, Affirmer hereby overtly, fully, permanently,
65
+ irrevocably and unconditionally waives, abandons, and surrenders all of
66
+ Affirmer's Copyright and Related Rights and associated claims and causes
67
+ of action, whether now known or unknown (including existing as well as
68
+ future claims and causes of action), in the Work (i) in all territories
69
+ worldwide, (ii) for the maximum duration provided by applicable law or
70
+ treaty (including future time extensions), (iii) in any current or future
71
+ medium and for any number of copies, and (iv) for any purpose whatsoever,
72
+ including without limitation commercial, advertising or promotional
73
+ purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74
+ member of the public at large and to the detriment of Affirmer's heirs and
75
+ successors, fully intending that such Waiver shall not be subject to
76
+ revocation, rescission, cancellation, termination, or any other legal or
77
+ equitable action to disrupt the quiet enjoyment of the Work by the public
78
+ as contemplated by Affirmer's express Statement of Purpose.
79
+
80
+ 3. Public License Fallback. Should any part of the Waiver for any reason
81
+ be judged legally invalid or ineffective under applicable law, then the
82
+ Waiver shall be preserved to the maximum extent permitted taking into
83
+ account Affirmer's express Statement of Purpose. In addition, to the
84
+ extent the Waiver is so judged Affirmer hereby grants to each affected
85
+ person a royalty-free, non transferable, non sublicensable, non exclusive,
86
+ irrevocable and unconditional license to exercise Affirmer's Copyright and
87
+ Related Rights in the Work (i) in all territories worldwide, (ii) for the
88
+ maximum duration provided by applicable law or treaty (including future
89
+ time extensions), (iii) in any current or future medium and for any number
90
+ of copies, and (iv) for any purpose whatsoever, including without
91
+ limitation commercial, advertising or promotional purposes (the
92
+ "License"). The License shall be deemed effective as of the date CC0 was
93
+ applied by Affirmer to the Work. Should any part of the License for any
94
+ reason be judged legally invalid or ineffective under applicable law, such
95
+ partial invalidity or ineffectiveness shall not invalidate the remainder
96
+ of the License, and in such case Affirmer hereby affirms that he or she
97
+ will not (i) exercise any of his or her remaining Copyright and Related
98
+ Rights in the Work or (ii) assert any associated claims and causes of
99
+ action with respect to the Work, in either case contrary to Affirmer's
100
+ express Statement of Purpose.
101
+
102
+ 4. Limitations and Disclaimers.
103
+
104
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
105
+ surrendered, licensed or otherwise affected by this document.
106
+ b. Affirmer offers the Work as-is and makes no representations or
107
+ warranties of any kind concerning the Work, express, implied,
108
+ statutory or otherwise, including without limitation warranties of
109
+ title, merchantability, fitness for a particular purpose, non
110
+ infringement, or the absence of latent or other defects, accuracy, or
111
+ the present or absence of errors, whether or not discoverable, all to
112
+ the greatest extent permissible under applicable law.
113
+ c. Affirmer disclaims responsibility for clearing rights of other persons
114
+ that may apply to the Work or any use thereof, including without
115
+ limitation any person's Copyright and Related Rights in the Work.
116
+ Further, Affirmer disclaims responsibility for obtaining any necessary
117
+ consents, permissions or other rights required for any use of the
118
+ Work.
119
+ d. Affirmer understands and acknowledges that Creative Commons is not a
120
+ party to this document and has no duty or obligation with respect to
121
+ this CC0 or use of the Work.
@@ -0,0 +1,41 @@
1
+ The code in this repository code was Written by Gil Tene, Michael Barker,
2
+ and Matt Warren, and released to the public domain, as explained at
3
+ http://creativecommons.org/publicdomain/zero/1.0/
4
+
5
+ For users of this code who wish to consume it under the "BSD" license
6
+ rather than under the public domain or CC0 contribution text mentioned
7
+ above, the code found under this directory is *also* provided under the
8
+ following license (commonly referred to as the BSD 2-Clause License). This
9
+ license does not detract from the above stated release of the code into
10
+ the public domain, and simply represents an additional license granted by
11
+ the Author.
12
+
13
+ -----------------------------------------------------------------------------
14
+ ** Beginning of "BSD 2-Clause License" text. **
15
+
16
+ Copyright (c) 2012, 2013, 2014 Gil Tene
17
+ Copyright (c) 2014 Michael Barker
18
+ Copyright (c) 2014 Matt Warren
19
+ All rights reserved.
20
+
21
+ Redistribution and use in source and binary forms, with or without
22
+ modification, are permitted provided that the following conditions are met:
23
+
24
+ 1. Redistributions of source code must retain the above copyright notice,
25
+ this list of conditions and the following disclaimer.
26
+
27
+ 2. Redistributions in binary form must reproduce the above copyright notice,
28
+ this list of conditions and the following disclaimer in the documentation
29
+ and/or other materials provided with the distribution.
30
+
31
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
32
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
33
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
34
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
35
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
36
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
39
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
41
+ THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,6 @@
1
+ include(CMakeFindDependencyMacro)
2
+
3
+ find_dependency(ZLIB)
4
+ find_dependency(Threads)
5
+
6
+ include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake)
@@ -0,0 +1,83 @@
1
+
2
+ include(CheckLibraryExists)
3
+ check_library_exists(m ceil "" HAVE_LIBM)
4
+ check_library_exists(rt clock_gettime "" HAVE_LIBRT)
5
+
6
+ if (HDR_LOG_ENABLED)
7
+ set(HDR_LOG_IMPLEMENTATION hdr_histogram_log.c)
8
+ set(HDR_ZLIB ZLIB::ZLIB)
9
+ else()
10
+ set(HDR_LOG_IMPLEMENTATION hdr_histogram_log_no_op.c)
11
+ set(HDR_ZLIB "")
12
+ endif()
13
+
14
+ set(HDR_HISTOGRAM_SOURCES
15
+ hdr_encoding.c
16
+ hdr_histogram.c
17
+ ${HDR_LOG_IMPLEMENTATION}
18
+ hdr_interval_recorder.c
19
+ hdr_thread.c
20
+ hdr_time.c
21
+ hdr_writer_reader_phaser.c)
22
+
23
+ set(HDR_HISTOGRAM_PRIVATE_HEADERS
24
+ hdr_atomic.h
25
+ hdr_encoding.h
26
+ hdr_endian.h
27
+ hdr_tests.h
28
+ hdr_malloc.h)
29
+
30
+ set(HDR_HISTOGRAM_PUBLIC_HEADERS
31
+ hdr_histogram.h
32
+ hdr_histogram_log.h
33
+ hdr_interval_recorder.h
34
+ hdr_thread.h
35
+ hdr_time.h
36
+ hdr_writer_reader_phaser.h)
37
+
38
+ function(hdr_histogram_add_library NAME LIBRARY_TYPE DO_INSTALL)
39
+ add_library(${NAME} ${LIBRARY_TYPE}
40
+ ${HDR_HISTOGRAM_SOURCES}
41
+ ${HDR_HISTOGRAM_PRIVATE_HEADERS}
42
+ ${HDR_HISTOGRAM_PUBLIC_HEADERS})
43
+ target_link_libraries(${NAME}
44
+ PRIVATE
45
+ # ZLIB::ZLIB
46
+ ${HDR_ZLIB}
47
+ # $<$<BOOL:${ZLIB_FOUND}>ZLIB::ZLIB>
48
+ Threads::Threads
49
+ $<$<BOOL:${HAVE_LIBM}>:m>
50
+ $<$<BOOL:${HAVE_LIBRT}>:rt>
51
+ $<$<BOOL:${WIN32}>:ws2_32>)
52
+ target_include_directories(${NAME}
53
+ PUBLIC
54
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
55
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
56
+ if(DO_INSTALL)
57
+ install(
58
+ TARGETS ${NAME}
59
+ EXPORT ${PROJECT_NAME}-targets
60
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
61
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
62
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
63
+ endif()
64
+ endfunction()
65
+
66
+ option(HDR_HISTOGRAM_BUILD_SHARED "Build shared library" ON)
67
+ option(HDR_HISTOGRAM_INSTALL_SHARED "Install shared library" ON)
68
+ if(HDR_HISTOGRAM_BUILD_SHARED)
69
+ hdr_histogram_add_library(hdr_histogram SHARED ${HDR_HISTOGRAM_INSTALL_SHARED})
70
+ set_target_properties(hdr_histogram PROPERTIES
71
+ VERSION ${HDR_VERSION}
72
+ SOVERSION ${HDR_SOVERSION})
73
+ endif()
74
+
75
+ option(HDR_HISTOGRAM_BUILD_STATIC "Build static library" ON)
76
+ option(HDR_HISTOGRAM_INSTALL_STATIC "Install static library" ON)
77
+ if(HDR_HISTOGRAM_BUILD_STATIC)
78
+ hdr_histogram_add_library(hdr_histogram_static STATIC ${HDR_HISTOGRAM_INSTALL_STATIC})
79
+ endif()
80
+
81
+ install(
82
+ FILES ${HDR_HISTOGRAM_PUBLIC_HEADERS}
83
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hdr)
@@ -0,0 +1,146 @@
1
+ /**
2
+ * hdr_atomic.h
3
+ * Written by Philip Orwig and released to the public domain,
4
+ * as explained at http://creativecommons.org/publicdomain/zero/1.0/
5
+ */
6
+
7
+ #ifndef HDR_ATOMIC_H__
8
+ #define HDR_ATOMIC_H__
9
+
10
+
11
+ #if defined(_MSC_VER)
12
+
13
+ #include <stdint.h>
14
+ #include <intrin.h>
15
+ #include <stdbool.h>
16
+
17
+ static void __inline * hdr_atomic_load_pointer(void** pointer)
18
+ {
19
+ _ReadBarrier();
20
+ return *pointer;
21
+ }
22
+
23
+ static void hdr_atomic_store_pointer(void** pointer, void* value)
24
+ {
25
+ _WriteBarrier();
26
+ *pointer = value;
27
+ }
28
+
29
+ static int64_t __inline hdr_atomic_load_64(int64_t* field)
30
+ {
31
+ _ReadBarrier();
32
+ return *field;
33
+ }
34
+
35
+ static void __inline hdr_atomic_store_64(int64_t* field, int64_t value)
36
+ {
37
+ _WriteBarrier();
38
+ *field = value;
39
+ }
40
+
41
+ static int64_t __inline hdr_atomic_exchange_64(volatile int64_t* field, int64_t value)
42
+ {
43
+ #if defined(_WIN64)
44
+ return _InterlockedExchange64(field, value);
45
+ #else
46
+ int64_t comparand;
47
+ int64_t initial_value = *field;
48
+ do
49
+ {
50
+ comparand = initial_value;
51
+ initial_value = _InterlockedCompareExchange64(field, value, comparand);
52
+ }
53
+ while (comparand != initial_value);
54
+
55
+ return initial_value;
56
+ #endif
57
+ }
58
+
59
+ static int64_t __inline hdr_atomic_add_fetch_64(volatile int64_t* field, int64_t value)
60
+ {
61
+ #if defined(_WIN64)
62
+ return _InterlockedExchangeAdd64(field, value) + value;
63
+ #else
64
+ int64_t comparand;
65
+ int64_t initial_value = *field;
66
+ do
67
+ {
68
+ comparand = initial_value;
69
+ initial_value = _InterlockedCompareExchange64(field, comparand + value, comparand);
70
+ }
71
+ while (comparand != initial_value);
72
+
73
+ return initial_value + value;
74
+ #endif
75
+ }
76
+
77
+ static bool __inline hdr_atomic_compare_exchange_64(volatile int64_t* field, int64_t* expected, int64_t desired)
78
+ {
79
+ return *expected == _InterlockedCompareExchange64(field, desired, *expected);
80
+ }
81
+
82
+ #elif defined(__ATOMIC_SEQ_CST)
83
+
84
+ #define hdr_atomic_load_pointer(x) __atomic_load_n(x, __ATOMIC_SEQ_CST)
85
+ #define hdr_atomic_store_pointer(f,v) __atomic_store_n(f,v, __ATOMIC_SEQ_CST)
86
+ #define hdr_atomic_load_64(x) __atomic_load_n(x, __ATOMIC_SEQ_CST)
87
+ #define hdr_atomic_store_64(f,v) __atomic_store_n(f,v, __ATOMIC_SEQ_CST)
88
+ #define hdr_atomic_exchange_64(f,i) __atomic_exchange_n(f,i, __ATOMIC_SEQ_CST)
89
+ #define hdr_atomic_add_fetch_64(field, value) __atomic_add_fetch(field, value, __ATOMIC_SEQ_CST)
90
+ #define hdr_atomic_compare_exchange_64(field, expected, desired) __atomic_compare_exchange_n(field, expected, desired, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)
91
+
92
+ #elif defined(__x86_64__)
93
+
94
+ #include <stdint.h>
95
+ #include <stdbool.h>
96
+
97
+ static inline void* hdr_atomic_load_pointer(void** pointer)
98
+ {
99
+ void* p = *pointer;
100
+ asm volatile ("" ::: "memory");
101
+ return p;
102
+ }
103
+
104
+ static inline void hdr_atomic_store_pointer(void** pointer, void* value)
105
+ {
106
+ asm volatile ("lock; xchgq %0, %1" : "+q" (value), "+m" (*pointer));
107
+ }
108
+
109
+ static inline int64_t hdr_atomic_load_64(int64_t* field)
110
+ {
111
+ int64_t i = *field;
112
+ asm volatile ("" ::: "memory");
113
+ return i;
114
+ }
115
+
116
+ static inline void hdr_atomic_store_64(int64_t* field, int64_t value)
117
+ {
118
+ asm volatile ("lock; xchgq %0, %1" : "+q" (value), "+m" (*field));
119
+ }
120
+
121
+ static inline int64_t hdr_atomic_exchange_64(volatile int64_t* field, int64_t value)
122
+ {
123
+ int64_t result = 0;
124
+ asm volatile ("lock; xchgq %1, %2" : "=r" (result), "+q" (value), "+m" (*field));
125
+ return result;
126
+ }
127
+
128
+ static inline int64_t hdr_atomic_add_fetch_64(volatile int64_t* field, int64_t value)
129
+ {
130
+ return __sync_add_and_fetch(field, value);
131
+ }
132
+
133
+ static inline bool hdr_atomic_compare_exchange_64(volatile int64_t* field, int64_t* expected, int64_t desired)
134
+ {
135
+ int64_t original;
136
+ asm volatile( "lock; cmpxchgq %2, %1" : "=a"(original), "+m"(*field) : "q"(desired), "0"(*expected));
137
+ return original == *expected;
138
+ }
139
+
140
+ #else
141
+
142
+ #error "Unable to determine atomic operations for your platform"
143
+
144
+ #endif
145
+
146
+ #endif /* HDR_ATOMIC_H__ */
@@ -0,0 +1,322 @@
1
+ /**
2
+ * hdr_encoding.c
3
+ * Written by Michael Barker and released to the public domain,
4
+ * as explained at http://creativecommons.org/publicdomain/zero/1.0/
5
+ */
6
+
7
+ #include <errno.h>
8
+ #include <stddef.h>
9
+ #include <math.h>
10
+
11
+ #include "hdr_encoding.h"
12
+ #include "hdr_tests.h"
13
+
14
+ int zig_zag_encode_i64(uint8_t* buffer, int64_t signed_value)
15
+ {
16
+ int bytesWritten;
17
+ int64_t value = signed_value;
18
+
19
+ value = (value << 1) ^ (value >> 63);
20
+ if (value >> 7 == 0)
21
+ {
22
+ buffer[0] = (uint8_t) value;
23
+ bytesWritten = 1;
24
+ }
25
+ else
26
+ {
27
+ buffer[0] = (uint8_t) ((value & 0x7F) | 0x80);
28
+ if (value >> 14 == 0)
29
+ {
30
+ buffer[1] = (uint8_t) (value >> 7);
31
+ bytesWritten = 2;
32
+ }
33
+ else
34
+ {
35
+ buffer[1] = (uint8_t) ((value >> 7 | 0x80));
36
+ if (value >> 21 == 0)
37
+ {
38
+ buffer[2] = (uint8_t) (value >> 14);
39
+ bytesWritten = 3;
40
+ }
41
+ else
42
+ {
43
+ buffer[2] = (uint8_t) (value >> 14 | 0x80);
44
+ if (value >> 28 == 0)
45
+ {
46
+ buffer[3] = (uint8_t) (value >> 21);
47
+ bytesWritten = 4;
48
+ }
49
+ else
50
+ {
51
+ buffer[3] = (uint8_t) (value >> 21 | 0x80);
52
+ if (value >> 35 == 0)
53
+ {
54
+ buffer[4] = (uint8_t) (value >> 28);
55
+ bytesWritten = 5;
56
+ }
57
+ else
58
+ {
59
+ buffer[4] = (uint8_t) (value >> 28 | 0x80);
60
+ if (value >> 42 == 0)
61
+ {
62
+ buffer[5] = (uint8_t) (value >> 35);
63
+ bytesWritten = 6;
64
+ }
65
+ else
66
+ {
67
+ buffer[5] = (uint8_t) (value >> 35 | 0x80);
68
+ if (value >> 49 == 0)
69
+ {
70
+ buffer[6] = (uint8_t) (value >> 42);
71
+ bytesWritten = 7;
72
+ }
73
+ else
74
+ {
75
+ buffer[6] = (uint8_t) (value >> 42 | 0x80);
76
+ if (value >> 56 == 0)
77
+ {
78
+ buffer[7] = (uint8_t) (value >> 49);
79
+ bytesWritten = 8;
80
+ }
81
+ else
82
+ {
83
+ buffer[7] = (uint8_t) (value >> 49 | 0x80);
84
+ buffer[8] = (uint8_t) (value >> 56);
85
+ bytesWritten = 9;
86
+ }
87
+ }
88
+ }
89
+ }
90
+ }
91
+ }
92
+ }
93
+ }
94
+
95
+ return bytesWritten;
96
+ }
97
+
98
+ int zig_zag_decode_i64(const uint8_t* buffer, int64_t* signed_value)
99
+ {
100
+ uint64_t v = buffer[0];
101
+ uint64_t value = v & 0x7F;
102
+ int bytesRead = 1;
103
+ if ((v & 0x80) != 0)
104
+ {
105
+ bytesRead = 2;
106
+ v = buffer[1];
107
+ value |= (v & 0x7F) << 7;
108
+ if ((v & 0x80) != 0)
109
+ {
110
+ bytesRead = 3;
111
+ v = buffer[2];
112
+ value |= (v & 0x7F) << 14;
113
+ if ((v & 0x80) != 0)
114
+ {
115
+ bytesRead = 4;
116
+ v = buffer[3];
117
+ value |= (v & 0x7F) << 21;
118
+ if ((v & 0x80) != 0)
119
+ {
120
+ bytesRead = 5;
121
+ v = buffer[4];
122
+ value |= (v & 0x7F) << 28;
123
+ if ((v & 0x80) != 0)
124
+ {
125
+ bytesRead = 6;
126
+ v = buffer[5];
127
+ value |= (v & 0x7F) << 35;
128
+ if ((v & 0x80) != 0)
129
+ {
130
+ bytesRead = 7;
131
+ v = buffer[6];
132
+ value |= (v & 0x7F) << 42;
133
+ if ((v & 0x80) != 0)
134
+ {
135
+ bytesRead = 8;
136
+ v = buffer[7];
137
+ value |= (v & 0x7F) << 49;
138
+ if ((v & 0x80) != 0)
139
+ {
140
+ bytesRead = 9;
141
+ v = buffer[8];
142
+ value |= v << 56;
143
+ }
144
+ }
145
+ }
146
+ }
147
+ }
148
+ }
149
+ }
150
+ }
151
+
152
+ #if defined(_MSC_VER)
153
+ #pragma warning(push)
154
+ #pragma warning(disable: 4146) /* C4146: unary minus operator applied to unsigned type, result still unsigned */
155
+ #endif
156
+ value = (value >> 1) ^ (-(value & 1));
157
+ #if defined(_MSC_VER)
158
+ #pragma warning(pop)
159
+ #endif
160
+ *signed_value = (int64_t) value;
161
+
162
+ return bytesRead;
163
+ }
164
+
165
+ static const char base64_table[] =
166
+ {
167
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
168
+ 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
169
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
170
+ 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
171
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', '\0'
172
+ };
173
+
174
+ static char get_base_64(uint32_t _24_bit_value, int shift)
175
+ {
176
+ uint32_t _6_bit_value = 0x3F & (_24_bit_value >> shift);
177
+ return base64_table[_6_bit_value];
178
+ }
179
+
180
+ static int from_base_64(int c)
181
+ {
182
+ if ('A' <= c && c <= 'Z')
183
+ {
184
+ return c - 'A';
185
+ }
186
+ else if ('a' <= c && c <= 'z')
187
+ {
188
+ return (c - 'a') + 26;
189
+ }
190
+ else if ('0' <= c && c <= '9')
191
+ {
192
+ return (c - '0') + 52;
193
+ }
194
+ else if ('+' == c)
195
+ {
196
+ return 62;
197
+ }
198
+ else if ('/' == c)
199
+ {
200
+ return 63;
201
+ }
202
+ else if ('=' == c)
203
+ {
204
+ return 0;
205
+ }
206
+
207
+ return EINVAL;
208
+ }
209
+
210
+ size_t hdr_base64_encoded_len(size_t decoded_size)
211
+ {
212
+ return (size_t) (ceil(decoded_size / 3.0) * 4.0);
213
+ }
214
+
215
+ size_t hdr_base64_decoded_len(size_t encoded_size)
216
+ {
217
+ return (encoded_size / 4) * 3;
218
+ }
219
+
220
+ static void hdr_base64_encode_block_pad(const uint8_t* input, char* output, size_t pad)
221
+ {
222
+ uint32_t _24_bit_value = 0;
223
+
224
+ switch (pad)
225
+ {
226
+ case 2:
227
+ _24_bit_value = (input[0] << 16) + (input[1] << 8);
228
+
229
+ output[0] = get_base_64(_24_bit_value, 18);
230
+ output[1] = get_base_64(_24_bit_value, 12);
231
+ output[2] = get_base_64(_24_bit_value, 6);
232
+ output[3] = '=';
233
+
234
+ break;
235
+
236
+ case 1:
237
+ _24_bit_value = (input[0] << 16);
238
+
239
+ output[0] = get_base_64(_24_bit_value, 18);
240
+ output[1] = get_base_64(_24_bit_value, 12);
241
+ output[2] = '=';
242
+ output[3] = '=';
243
+
244
+ break;
245
+
246
+ default:
247
+ /* No-op */
248
+ break;
249
+ }
250
+ }
251
+
252
+ /**
253
+ * Assumes that there is 3 input bytes and 4 output chars.
254
+ */
255
+ void hdr_base64_encode_block(const uint8_t* input, char* output)
256
+ {
257
+ uint32_t _24_bit_value = (input[0] << 16) + (input[1] << 8) + (input[2]);
258
+
259
+ output[0] = get_base_64(_24_bit_value, 18);
260
+ output[1] = get_base_64(_24_bit_value, 12);
261
+ output[2] = get_base_64(_24_bit_value, 6);
262
+ output[3] = get_base_64(_24_bit_value, 0);
263
+ }
264
+
265
+ int hdr_base64_encode(
266
+ const uint8_t* input, size_t input_len, char* output, size_t output_len)
267
+ {
268
+ size_t i, j, remaining;
269
+
270
+ if (hdr_base64_encoded_len(input_len) != output_len)
271
+ {
272
+ return EINVAL;
273
+ }
274
+
275
+ for (i = 0, j = 0; input_len - i >= 3 && j < output_len; i += 3, j += 4)
276
+ {
277
+ hdr_base64_encode_block(&input[i], &output[j]);
278
+ }
279
+
280
+ remaining = input_len - i;
281
+
282
+ hdr_base64_encode_block_pad(&input[i], &output[j], remaining);
283
+
284
+ return 0;
285
+ }
286
+
287
+ /**
288
+ * Assumes that there is 4 input chars available and 3 output chars.
289
+ */
290
+ void hdr_base64_decode_block(const char* input, uint8_t* output)
291
+ {
292
+ uint32_t _24_bit_value = 0;
293
+
294
+ _24_bit_value |= from_base_64(input[0]) << 18;
295
+ _24_bit_value |= from_base_64(input[1]) << 12;
296
+ _24_bit_value |= from_base_64(input[2]) << 6;
297
+ _24_bit_value |= from_base_64(input[3]);
298
+
299
+ output[0] = (uint8_t) ((_24_bit_value >> 16) & 0xFF);
300
+ output[1] = (uint8_t) ((_24_bit_value >> 8) & 0xFF);
301
+ output[2] = (uint8_t) ((_24_bit_value) & 0xFF);
302
+ }
303
+
304
+ int hdr_base64_decode(
305
+ const char* input, size_t input_len, uint8_t* output, size_t output_len)
306
+ {
307
+ size_t i, j;
308
+
309
+ if (input_len < 4 ||
310
+ (input_len & 3u) != 0 ||
311
+ (input_len / 4) * 3 != output_len)
312
+ {
313
+ return -EINVAL;
314
+ }
315
+
316
+ for (i = 0, j = 0; i < input_len; i += 4, j += 3)
317
+ {
318
+ hdr_base64_decode_block(&input[i], &output[j]);
319
+ }
320
+
321
+ return 0;
322
+ }