yugabyte-ycql-driver 3.2.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +13 -0
  3. data/README.md +242 -0
  4. data/ext/cassandra_murmur3/cassandra_murmur3.c +178 -0
  5. data/ext/cassandra_murmur3/extconf.rb +2 -0
  6. data/lib/cassandra/address_resolution.rb +36 -0
  7. data/lib/cassandra/address_resolution/policies.rb +2 -0
  8. data/lib/cassandra/address_resolution/policies/ec2_multi_region.rb +56 -0
  9. data/lib/cassandra/address_resolution/policies/none.rb +35 -0
  10. data/lib/cassandra/aggregate.rb +123 -0
  11. data/lib/cassandra/argument.rb +51 -0
  12. data/lib/cassandra/attr_boolean.rb +33 -0
  13. data/lib/cassandra/auth.rb +100 -0
  14. data/lib/cassandra/auth/providers.rb +17 -0
  15. data/lib/cassandra/auth/providers/password.rb +65 -0
  16. data/lib/cassandra/cassandra_logger.rb +80 -0
  17. data/lib/cassandra/cluster.rb +331 -0
  18. data/lib/cassandra/cluster/client.rb +1612 -0
  19. data/lib/cassandra/cluster/connection_pool.rb +78 -0
  20. data/lib/cassandra/cluster/connector.rb +372 -0
  21. data/lib/cassandra/cluster/control_connection.rb +962 -0
  22. data/lib/cassandra/cluster/failed_connection.rb +35 -0
  23. data/lib/cassandra/cluster/metadata.rb +142 -0
  24. data/lib/cassandra/cluster/options.rb +145 -0
  25. data/lib/cassandra/cluster/registry.rb +284 -0
  26. data/lib/cassandra/cluster/schema.rb +405 -0
  27. data/lib/cassandra/cluster/schema/cql_type_parser.rb +112 -0
  28. data/lib/cassandra/cluster/schema/fetchers.rb +1627 -0
  29. data/lib/cassandra/cluster/schema/fqcn_type_parser.rb +175 -0
  30. data/lib/cassandra/cluster/schema/partitioners.rb +21 -0
  31. data/lib/cassandra/cluster/schema/partitioners/murmur3.rb +45 -0
  32. data/lib/cassandra/cluster/schema/partitioners/ordered.rb +37 -0
  33. data/lib/cassandra/cluster/schema/partitioners/random.rb +37 -0
  34. data/lib/cassandra/cluster/schema/replication_strategies.rb +21 -0
  35. data/lib/cassandra/cluster/schema/replication_strategies/network_topology.rb +102 -0
  36. data/lib/cassandra/cluster/schema/replication_strategies/none.rb +39 -0
  37. data/lib/cassandra/cluster/schema/replication_strategies/simple.rb +44 -0
  38. data/lib/cassandra/column.rb +66 -0
  39. data/lib/cassandra/column_container.rb +326 -0
  40. data/lib/cassandra/compression.rb +69 -0
  41. data/lib/cassandra/compression/compressors/lz4.rb +73 -0
  42. data/lib/cassandra/compression/compressors/snappy.rb +69 -0
  43. data/lib/cassandra/custom_data.rb +53 -0
  44. data/lib/cassandra/driver.rb +260 -0
  45. data/lib/cassandra/errors.rb +784 -0
  46. data/lib/cassandra/execution/info.rb +69 -0
  47. data/lib/cassandra/execution/options.rb +267 -0
  48. data/lib/cassandra/execution/profile.rb +153 -0
  49. data/lib/cassandra/execution/profile_manager.rb +71 -0
  50. data/lib/cassandra/execution/trace.rb +192 -0
  51. data/lib/cassandra/executors.rb +113 -0
  52. data/lib/cassandra/function.rb +156 -0
  53. data/lib/cassandra/function_collection.rb +85 -0
  54. data/lib/cassandra/future.rb +794 -0
  55. data/lib/cassandra/host.rb +102 -0
  56. data/lib/cassandra/index.rb +118 -0
  57. data/lib/cassandra/keyspace.rb +473 -0
  58. data/lib/cassandra/listener.rb +87 -0
  59. data/lib/cassandra/load_balancing.rb +121 -0
  60. data/lib/cassandra/load_balancing/policies.rb +20 -0
  61. data/lib/cassandra/load_balancing/policies/dc_aware_round_robin.rb +172 -0
  62. data/lib/cassandra/load_balancing/policies/round_robin.rb +141 -0
  63. data/lib/cassandra/load_balancing/policies/token_aware.rb +149 -0
  64. data/lib/cassandra/load_balancing/policies/white_list.rb +100 -0
  65. data/lib/cassandra/materialized_view.rb +92 -0
  66. data/lib/cassandra/null_logger.rb +56 -0
  67. data/lib/cassandra/protocol.rb +102 -0
  68. data/lib/cassandra/protocol/coder.rb +1085 -0
  69. data/lib/cassandra/protocol/cql_byte_buffer.rb +418 -0
  70. data/lib/cassandra/protocol/cql_protocol_handler.rb +448 -0
  71. data/lib/cassandra/protocol/request.rb +41 -0
  72. data/lib/cassandra/protocol/requests/auth_response_request.rb +51 -0
  73. data/lib/cassandra/protocol/requests/batch_request.rb +117 -0
  74. data/lib/cassandra/protocol/requests/credentials_request.rb +51 -0
  75. data/lib/cassandra/protocol/requests/execute_request.rb +122 -0
  76. data/lib/cassandra/protocol/requests/options_request.rb +39 -0
  77. data/lib/cassandra/protocol/requests/prepare_request.rb +59 -0
  78. data/lib/cassandra/protocol/requests/query_request.rb +112 -0
  79. data/lib/cassandra/protocol/requests/register_request.rb +38 -0
  80. data/lib/cassandra/protocol/requests/startup_request.rb +49 -0
  81. data/lib/cassandra/protocol/requests/void_query_request.rb +24 -0
  82. data/lib/cassandra/protocol/response.rb +28 -0
  83. data/lib/cassandra/protocol/responses/already_exists_error_response.rb +50 -0
  84. data/lib/cassandra/protocol/responses/auth_challenge_response.rb +36 -0
  85. data/lib/cassandra/protocol/responses/auth_success_response.rb +36 -0
  86. data/lib/cassandra/protocol/responses/authenticate_response.rb +36 -0
  87. data/lib/cassandra/protocol/responses/error_response.rb +142 -0
  88. data/lib/cassandra/protocol/responses/event_response.rb +30 -0
  89. data/lib/cassandra/protocol/responses/function_failure_error_response.rb +52 -0
  90. data/lib/cassandra/protocol/responses/prepared_result_response.rb +62 -0
  91. data/lib/cassandra/protocol/responses/raw_rows_result_response.rb +59 -0
  92. data/lib/cassandra/protocol/responses/read_failure_error_response.rb +71 -0
  93. data/lib/cassandra/protocol/responses/read_timeout_error_response.rb +61 -0
  94. data/lib/cassandra/protocol/responses/ready_response.rb +43 -0
  95. data/lib/cassandra/protocol/responses/result_response.rb +42 -0
  96. data/lib/cassandra/protocol/responses/rows_result_response.rb +39 -0
  97. data/lib/cassandra/protocol/responses/schema_change_event_response.rb +73 -0
  98. data/lib/cassandra/protocol/responses/schema_change_result_response.rb +70 -0
  99. data/lib/cassandra/protocol/responses/set_keyspace_result_response.rb +37 -0
  100. data/lib/cassandra/protocol/responses/status_change_event_response.rb +39 -0
  101. data/lib/cassandra/protocol/responses/supported_response.rb +36 -0
  102. data/lib/cassandra/protocol/responses/topology_change_event_response.rb +33 -0
  103. data/lib/cassandra/protocol/responses/unavailable_error_response.rb +58 -0
  104. data/lib/cassandra/protocol/responses/unprepared_error_response.rb +48 -0
  105. data/lib/cassandra/protocol/responses/void_result_response.rb +34 -0
  106. data/lib/cassandra/protocol/responses/write_failure_error_response.rb +73 -0
  107. data/lib/cassandra/protocol/responses/write_timeout_error_response.rb +63 -0
  108. data/lib/cassandra/protocol/v1.rb +326 -0
  109. data/lib/cassandra/protocol/v3.rb +358 -0
  110. data/lib/cassandra/protocol/v4.rb +478 -0
  111. data/lib/cassandra/reconnection.rb +49 -0
  112. data/lib/cassandra/reconnection/policies.rb +20 -0
  113. data/lib/cassandra/reconnection/policies/constant.rb +46 -0
  114. data/lib/cassandra/reconnection/policies/exponential.rb +79 -0
  115. data/lib/cassandra/result.rb +276 -0
  116. data/lib/cassandra/retry.rb +154 -0
  117. data/lib/cassandra/retry/policies.rb +21 -0
  118. data/lib/cassandra/retry/policies/default.rb +53 -0
  119. data/lib/cassandra/retry/policies/downgrading_consistency.rb +73 -0
  120. data/lib/cassandra/retry/policies/fallthrough.rb +39 -0
  121. data/lib/cassandra/session.rb +270 -0
  122. data/lib/cassandra/statement.rb +32 -0
  123. data/lib/cassandra/statements.rb +23 -0
  124. data/lib/cassandra/statements/batch.rb +146 -0
  125. data/lib/cassandra/statements/bound.rb +65 -0
  126. data/lib/cassandra/statements/prepared.rb +235 -0
  127. data/lib/cassandra/statements/simple.rb +118 -0
  128. data/lib/cassandra/statements/void.rb +38 -0
  129. data/lib/cassandra/table.rb +240 -0
  130. data/lib/cassandra/time.rb +103 -0
  131. data/lib/cassandra/time_uuid.rb +78 -0
  132. data/lib/cassandra/timestamp_generator.rb +37 -0
  133. data/lib/cassandra/timestamp_generator/simple.rb +38 -0
  134. data/lib/cassandra/timestamp_generator/ticking_on_duplicate.rb +58 -0
  135. data/lib/cassandra/trigger.rb +67 -0
  136. data/lib/cassandra/tuple.rb +131 -0
  137. data/lib/cassandra/types.rb +1704 -0
  138. data/lib/cassandra/udt.rb +443 -0
  139. data/lib/cassandra/util.rb +464 -0
  140. data/lib/cassandra/uuid.rb +110 -0
  141. data/lib/cassandra/uuid/generator.rb +212 -0
  142. data/lib/cassandra/version.rb +21 -0
  143. data/lib/datastax/cassandra.rb +47 -0
  144. data/lib/ycql.rb +842 -0
  145. metadata +243 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0420f05d4a063e020526b1869f3c2a4bf61b7eb7
4
+ data.tar.gz: 594ee209ed49626772e68fcbe0b9331f1e0d8412
5
+ SHA512:
6
+ metadata.gz: ef47feef7a8915c1bc87ef13f21ebc07b01520dc67690cdaa98ba8e7d691c428a9ef6a2c7c52d0e1607e910e82fbc86a7a630f4a4b681f7e80fc58922e77bae8
7
+ data.tar.gz: e298797101462cd87d89d0408204f34ea8dca108e2fd4ebe0ec34255d2d6bdc71d02eed339a37a161799867eddb27c3ca5b7c375dad88f666d01be1c1f67f428
data/.yardopts ADDED
@@ -0,0 +1,13 @@
1
+ --no-private
2
+ --markup markdown
3
+ --type-tag expected_errors:"Expected Errors"
4
+ --tag jira_ticket:"JIRA Ticket"
5
+ --type-tag expected_result:"Expected Result"
6
+ --tag test_assumptions:"Test Assumptions"
7
+ --tag test_category:"Test Category"
8
+
9
+ lib/**/*.rb
10
+ integration/**/*.rb
11
+ -- README
12
+
13
+ load_plugins: true
data/README.md ADDED
@@ -0,0 +1,242 @@
1
+ # YugaByte Ruby Driver for YugaByte DB's Cassandra compatible YCQL API
2
+
3
+ *If you're reading this on GitHub, please note that this is the readme for the development version and that some
4
+ features described here might not yet have been released. You can view the documentation for the latest released
5
+ version [here](http://docs.datastax.com/en/developer/ruby-driver/latest).*
6
+
7
+ [![Build Status](https://travis-ci.org/datastax/ruby-driver.svg?branch=master)](https://travis-ci.org/datastax/ruby-driver)
8
+
9
+ A Ruby client driver for YugaByte DB's Cassandra compatible YCQL API. This driver works exclusively with
10
+ the Cassandra Query Language version 3 (CQL3) and Cassandra's native protocol.
11
+
12
+ - Code: https://github.com/yugabyte/cassandra-ruby-driver
13
+ - Docs: http://docs.datastax.com/en/developer/ruby-driver
14
+ - Mailing List: https://groups.google.com/a/lists.datastax.com/forum/#!forum/ruby-driver-user
15
+
16
+ This driver is based on [the cql-rb gem](https://github.com/iconara/cql-rb) by [Theo Hultberg](https://github.com/iconara) and we added support for:
17
+
18
+ * [Asynchronous execution](http://docs.datastax.com/en/developer/ruby-driver/3.1/features/asynchronous_io/)
19
+ * One-off, [prepared](http://docs.datastax.com/en/developer/ruby-driver/3.1/features/basics/prepared_statements/) and [batch statements](http://docs.datastax.com/en/developer/ruby-driver/3.1/features/basics/batch_statements/)
20
+ * Automatic peer discovery and cluster metadata with [support for change notifications](http://docs.datastax.com/en/developer/ruby-driver/3.1/features/state_listeners/)
21
+ * Various [load-balancing](http://docs.datastax.com/en/developer/ruby-driver/3.1/features/load_balancing/), [retry](http://docs.datastax.com/en/developer/ruby-driver/3.1/features/retry_policies/) and [reconnection](http://docs.datastax.com/en/developer/ruby-driver/3.1/features/reconnection/) policies with [ability to write your own](http://docs.datastax.com/en/developer/ruby-driver/3.1/features/load_balancing/implementing_a_policy/)
22
+ * [SSL encryption](http://docs.datastax.com/en/developer/ruby-driver/3.1/features/security/ssl_encryption/)
23
+ * [Flexible and robust error handling](http://docs.datastax.com/en/developer/ruby-driver/3.1/features/error_handling/)
24
+ * [Per-request execution information and tracing](http://docs.datastax.com/en/developer/ruby-driver/3.1/features/debugging/)
25
+ * [Configurable address resolution](http://docs.datastax.com/en/developer/ruby-driver/3.1/features/address_resolution/)
26
+
27
+ [Check out the slides from Ruby Driver Explained](https://speakerdeck.com/avalanche123/ruby-driver-explained) for a detailed overview of the Ruby Driver architecture.
28
+
29
+ ## Compatibility
30
+
31
+ This driver works exclusively with the Cassandra Query Language v3 (CQL3) and Cassandra's native protocol.
32
+
33
+ __Note__: Rubinius is not supported.
34
+
35
+ __Note__: Big-endian systems are not supported.
36
+
37
+ ## Quick start
38
+
39
+ ```ruby
40
+ require 'ycql'
41
+
42
+ cluster = Cassandra.cluster # connects to localhost by default
43
+
44
+ cluster.each_host do |host| # automatically discovers all peers
45
+ puts "Host #{host.ip}: id=#{host.id} datacenter=#{host.datacenter} rack=#{host.rack}"
46
+ end
47
+
48
+ keyspace = 'system_schema'
49
+ session = cluster.connect(keyspace) # create session, optionally scoped to a keyspace, to execute queries
50
+
51
+ future = session.execute_async('SELECT keyspace_name, table_name FROM tables') # fully asynchronous api
52
+ future.on_success do |rows|
53
+ rows.each do |row|
54
+ puts "The keyspace #{row['keyspace_name']} has a table called #{row['table_name']}"
55
+ end
56
+ end
57
+ future.join
58
+ ```
59
+
60
+ __Note__: The host you specify is just a seed node, the driver will automatically discover all peers in the cluster.
61
+
62
+ Read more:
63
+
64
+ * [`Cassandra.cluster` options](http://docs.datastax.com/en/developer/ruby-driver/3.1/api/cassandra/#cluster-class_method)
65
+ * [`Session#execute_async` options](http://docs.datastax.com/en/developer/ruby-driver/3.1/api/cassandra/session/#execute_async-instance_method)
66
+ * [Usage documentation](http://docs.datastax.com/en/developer/ruby-driver/3.1/features)
67
+
68
+ ## Installation
69
+
70
+ Install via rubygems
71
+
72
+ ```bash
73
+ gem install yugabyte-ycql-driver
74
+ ```
75
+
76
+ Install via Gemfile
77
+
78
+ ```ruby
79
+ gem 'yugabyte-ycql-driver'
80
+ ```
81
+
82
+ __Note__: if you want to use compression you should also install [snappy](http://rubygems.org/gems/snappy) or [lz4-ruby](http://rubygems.org/gems/lz4-ruby). [Read more about compression.](http://docs.datastax.com/en/developer/ruby-driver/3.1/features/#compression)
83
+
84
+
85
+ ## Upgrading from cql-rb
86
+
87
+ Some of the new features added to the driver have unfortunately led to changes in the original cql-rb API.
88
+ In the examples directory, you can find [an example of how to wrap the ruby driver to achieve almost complete
89
+ interface parity with cql-rb](https://github.com/datastax/ruby-driver/blob/v3.2.3/examples/cql-rb-wrapper.rb)
90
+ to assist you with gradual upgrade.
91
+
92
+ ## What's new in v3.2
93
+ This minor release adds support for MRI 2.4.x and also contains a few miscellaneous defect fixes. It also removes
94
+ support for Ruby versions prior to 2.2. This was already officially the case, but the minimum version limit is
95
+ now enforced.
96
+
97
+ See the [changelog](https://github.com/datastax/ruby-driver/blob/v3.2.3/CHANGELOG.md) for more information on all
98
+ changes in this version and past versions.
99
+
100
+ ## What's new in v3.1
101
+
102
+ This minor release introduces features and fixes around resiliency, schema metadata, usability, and performance. One
103
+ of the most user-impacting of these is the introduction of
104
+ [execution profiles](http://docs.datastax.com/en/developer/ruby-driver/3.1/features/basics/execution_profiles).
105
+ Execution profiles allow you to group various execution options into a 'profile' and you reference the desired
106
+ profile at execution time. Get the scoop
107
+ [here](http://docs.datastax.com/en/developer/ruby-driver/3.1/features/basics/execution_profiles).
108
+
109
+ ## What's new in v3.0
110
+
111
+ ### Features:
112
+
113
+ * Add support for Apache Cassandra native protocol v4
114
+ * Add support for smallint, tinyint, date (`Cassandra::Date`) and time (`Cassandra::Time`) data types.
115
+ * Include schema metadata for User Defined Functions and User Defined Aggregates.
116
+ * Augment the `Cassandra::Table` object to expose many more attributes: `id`, `options`, `keyspace`, `partition_key`, `clustering_columns`, and `clustering_order`. This makes it significantly easier to write administration scripts that report various attributes of your schema, which may help to highlight areas for improvement.
117
+ * Include client ip addresses in request traces, only on Cassandra 3.x.
118
+ * Add new retry policy decision `Cassandra::Retry::Policy#try_next_host`.
119
+ * Support specifying statement idempotence with the new `idempotent` option when executing.
120
+ * Support sending custom payloads when preparing or executing statements using the new `payload` option.
121
+ * Expose custom payloads received with responses on server exceptions and `Cassandra::Execution::Info` instances.
122
+ * Expose server warnings on server exceptions and `Cassandra::Execution::Info` instances.
123
+ * Add `connections_per_local_node`, `connections_per_remote_node`, `requests_per_connection` cluster configuration options to tune parallel query execution and resource usage.
124
+ * Add `Cassandra::Logger` class to make it easy for users to enable debug logging in the client.
125
+ * Add `protocol_version` configuration option to allow the user to force the protocol version to use for communication with nodes.
126
+ * Add support for materialized views and indexes in the schema metadata.
127
+ * Support the `ReadError`, `WriteError`, and `FunctionCallError` Cassandra error responses introduced in Cassandra 2.2.
128
+ * Add support for unset variables in bound statements.
129
+ * Support DSE security (`DseAuthenticator`, configured for LDAP).
130
+ * Add a timeout option to `Cassandra::Future#get`.
131
+
132
+ ### Breaking Changes from 2.x:
133
+
134
+ * `Cassandra::Future#join` is now an alias to Cassandra::Future#get and will raise an error if the future is resolved with one.
135
+ * Default consistency level is now LOCAL_ONE.
136
+ * Enable tcp no-delay by default.
137
+ * Unavailable errors are retried on the next host in the load balancing plan by default.
138
+ * Statement execution no longer retried on timeouts, unless the statement is marked as idempotent in the call to `Cassandra::Session#execute*` or when creating a `Cassandra::Statement` object.
139
+ * `Cassandra::Statements::Batch#add` and `Cassandra::Session#execute*` signatures have changed in how one specifies query parameters. Specify the query parameters array as the value of the arguments key:
140
+
141
+ ```ruby
142
+ batch.add(query, ['val1', 'val2'])
143
+ # becomes
144
+ batch.add(query, arguments: ['val1', 'val2'])
145
+
146
+ batch.add(query, {p1: 'val1'})
147
+ # becomes
148
+ batch.add(query, arguments: {p1: 'val1'})
149
+ ```
150
+ * The Datacenter-aware load balancing policy (`Cassandra::LoadBalancing::Policies::DCAwareRoundRobin`) defaults to using
151
+ nodes in the local DC only. In prior releases, the policy would fall back to remote nodes after exhausting local nodes.
152
+ Specify a positive value (or nil for unlimited) for `max_remote_hosts_to_use` when initializing the policy to allow remote node use.
153
+ * Unspecified variables in statements previously resulted in an exception. Now they are essentially ignored or treated as null.
154
+
155
+ ## Code examples
156
+
157
+ The DataStax Ruby Driver uses the awesome [Cucumber Framework](http://cukes.info/) for
158
+ both end-to-end, or acceptance, testing and constructing documentation. All of the
159
+ features supported by the driver have appropriate acceptance tests with easy-to-copy code
160
+ examples in the `features/` directory.
161
+
162
+ ## Running tests
163
+
164
+ If you don't feel like reading through the following instructions on how to run
165
+ ruby-driver tests, feel free to [check out .travis.yml for the entire build code](https://github.com/datastax/ruby-driver/blob/v3.2.3/.travis.yml).
166
+
167
+ * Check out the driver codebase and install test dependencies:
168
+
169
+ ```bash
170
+ git clone https://github.com/yugabyte/cassandra-ruby-driver.git
171
+ cd ruby-driver
172
+ bundle install --without docs
173
+ ```
174
+
175
+ * [Install ccm](http://www.datastax.com/dev/blog/ccm-a-development-tool-for-creating-local-cassandra-clusters)
176
+
177
+ * Run tests against different versions of Cassandra:
178
+
179
+ ```bash
180
+ CASSANDRA_VERSION=3.1.1 bundle exec cucumber # runs end-to-end tests (or bundle exec rake cucumber)
181
+ CASSANDRA_VERSION=3.0.0 bundle exec rspec # runs unit tests (or bundle exec rake rspec)
182
+ CASSANDRA_VERSION=2.1.12 bundle exec rake integration # run integration tests
183
+ CASSANDRA_VERSION=2.1.12 bundle exec rake test # run both as well as integration tests
184
+ ```
185
+
186
+ ## Changelog & versioning
187
+
188
+ Check out the [releases on GitHub](https://github.com/yugabyte/cassandra-ruby-driver/releases) and
189
+ [changelog](https://github.com/yugabyte/cassandra-ruby-driver/blob/v3.2.3/CHANGELOG.md). Version
190
+ numbering follows the [semantic versioning](http://semver.org/) scheme.
191
+
192
+ Private and experimental APIs, defined as whatever is not in the
193
+ [public API documentation][1], i.e. classes and methods marked as `@private`, will change
194
+ without warning. If you've been recommended to try an experimental API by the maintainers,
195
+ please let them know if you depend on that API. Experimental APIs will eventually become
196
+ public, and knowing how they are used helps in determining their maturity.
197
+
198
+ Prereleases will be stable, in the sense that they will have finished and properly tested
199
+ features only, but may introduce APIs that will change before the final release. Please
200
+ use the prereleases and report bugs, but don't deploy them to production without
201
+ consulting the maintainers, or doing extensive testing yourself. If you do deploy to
202
+ production please let the maintainers know as this helps in determining the maturity of
203
+ the release.
204
+
205
+ ## Known bugs & limitations
206
+
207
+ * Specifying a `protocol_version` option of 1 or 2 in cluster options will fail with a
208
+ `NoHostsAvailable` error rather than a `ProtocolError` against Cassandra node versions 3.0-3.4.
209
+ * Because the driver reactor is using `IO.select`, the maximum number of tcp connections allowed is 1024.
210
+ * Because the driver uses `IO#write_nonblock`, Windows is not supported.
211
+
212
+ Please [refer to the usage documentation for more information on common pitfalls](http://docs.datastax.com/en/developer/ruby-driver/3.1/features/)
213
+
214
+ ## Contributing
215
+
216
+ For contributing read [CONTRIBUTING.md](https://github.com/yugabyte/cassandra-ruby-driver/blob/master/CONTRIBUTING.md)
217
+
218
+ ## Credits
219
+
220
+ This driver is based on the original work of [Theo Hultberg](https://github.com/iconara)
221
+ on [cql-rb](https://github.com/iconara/cql-rb/) and adds a series of advanced features
222
+ that are common across all other DataStax drivers for Apache Cassandra.
223
+
224
+ The development effort to provide an up to date, high performance, fully featured Ruby
225
+ Driver for Apache Cassandra will continue on this project, while
226
+ [cql-rb](https://github.com/iconara/cql-rb/) has been discontinued.
227
+
228
+ ## Copyright
229
+
230
+ Copyright DataStax, Inc.
231
+
232
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
233
+ except in compliance with the License. You may obtain a copy of the License at
234
+
235
+ [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
236
+
237
+ Unless required by applicable law or agreed to in writing, software distributed under the
238
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
239
+ either express or implied. See the License for the specific language governing permissions
240
+ and limitations under the License.
241
+
242
+ [1]: http://docs.datastax.com/en/developer/ruby-driver/3.1/api
@@ -0,0 +1,178 @@
1
+ // Copyright DataStax, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ #include <ruby.h>
16
+
17
+ /*-----------------------------------------------------------------------------
18
+ * MurmurHash3 was written by Austin Appleby, and is placed in the public
19
+ * domain. The author hereby disclaims copyright to this source code.
20
+ */
21
+
22
+ //-----------------------------------------------------------------------------
23
+ // Platform-specific functions and macros
24
+
25
+ #ifdef _MSC_VER
26
+ typedef unsigned __int64 uint64_t;
27
+ typedef __int64 int64_t;
28
+
29
+ #define FORCE_INLINE __forceinline
30
+ #else
31
+ #include <stdint.h>
32
+ #ifdef __GNUC__
33
+ #define FORCE_INLINE __attribute__((always_inline)) inline
34
+ #else
35
+ #define FORCE_INLINE inline
36
+ #endif
37
+ #endif
38
+
39
+ #define BIG_CONSTANT(x) (x##LLU)
40
+
41
+ static FORCE_INLINE int64_t
42
+ rotl(int64_t x, int8_t r)
43
+ {
44
+ // cast to unsigned for logical right bitshift (to match C* MM3 implementation)
45
+ return (x << r) | ((int64_t) (((uint64_t) x) >> (64 - r)));
46
+ }
47
+
48
+ static FORCE_INLINE int64_t
49
+ getblock(const int64_t* p, int i)
50
+ {
51
+ return p[i];
52
+ }
53
+
54
+ static FORCE_INLINE int64_t
55
+ fmix(int64_t k)
56
+ {
57
+ // cast to unsigned for logical right bitshift (to match C* MM3 implementation)
58
+ k ^= ((uint64_t) k) >> 33;
59
+ k *= BIG_CONSTANT(0xff51afd7ed558ccd);
60
+ k ^= ((uint64_t) k) >> 33;
61
+ k *= BIG_CONSTANT(0xc4ceb9fe1a85ec53);
62
+ k ^= ((uint64_t) k) >> 33;
63
+
64
+ return k;
65
+ }
66
+
67
+ static VALUE
68
+ rb_murmur3_hash(VALUE self, VALUE rb_string)
69
+ {
70
+ char* bytes;
71
+ int64_t length;
72
+
73
+ Check_Type(rb_string, T_STRING);
74
+
75
+ bytes = RSTRING_PTR(rb_string);
76
+ length = RSTRING_LEN(rb_string);
77
+
78
+ const int nblocks = length / 16;
79
+ int i;
80
+
81
+ int64_t h1 = 0;
82
+ int64_t h2 = 0;
83
+
84
+ int64_t c1 = BIG_CONSTANT(0x87c37b91114253d5);
85
+ int64_t c2 = BIG_CONSTANT(0x4cf5ad432745937f);
86
+
87
+ //----------
88
+ // body
89
+
90
+ const int64_t* blocks = (const int64_t*)(bytes);
91
+
92
+ for(i = 0; i < nblocks; i++)
93
+ {
94
+ int64_t k1 = getblock(blocks, i * 2 + 0);
95
+ int64_t k2 = getblock(blocks, i * 2 + 1);
96
+
97
+ k1 *= c1;
98
+ k1 = rotl(k1, 31);
99
+ k1 *= c2;
100
+ h1 ^= k1;
101
+
102
+ h1 = rotl(h1, 27);
103
+ h1 += h2;
104
+ h1 = h1 * 5 + 0x52dce729;
105
+
106
+ k2 *= c2;
107
+ k2 = rotl(k2, 33);
108
+ k2 *= c1;
109
+ h2 ^= k2;
110
+
111
+ h2 = rotl(h2, 31);
112
+ h2 += h1;
113
+ h2 = h2 * 5 + 0x38495ab5;
114
+ }
115
+
116
+ //----------
117
+ // tail
118
+
119
+ const int8_t* tail = (const int8_t*) (bytes + nblocks * 16);
120
+
121
+ int64_t k1 = 0;
122
+ int64_t k2 = 0;
123
+
124
+ switch(length & 15)
125
+ {
126
+ case 15: k2 ^= ((int64_t) tail[14]) << 48;
127
+ case 14: k2 ^= ((int64_t) tail[13]) << 40;
128
+ case 13: k2 ^= ((int64_t) tail[12]) << 32;
129
+ case 12: k2 ^= ((int64_t) tail[11]) << 24;
130
+ case 11: k2 ^= ((int64_t) tail[10]) << 16;
131
+ case 10: k2 ^= ((int64_t) tail[ 9]) << 8;
132
+ case 9: k2 ^= ((int64_t) tail[ 8]) << 0;
133
+ k2 *= c2;
134
+ k2 = rotl(k2, 33);
135
+ k2 *= c1;
136
+ h2 ^= k2;
137
+ case 8: k1 ^= ((int64_t) tail[7]) << 56;
138
+ case 7: k1 ^= ((int64_t) tail[6]) << 48;
139
+ case 6: k1 ^= ((int64_t) tail[5]) << 40;
140
+ case 5: k1 ^= ((int64_t) tail[4]) << 32;
141
+ case 4: k1 ^= ((int64_t) tail[3]) << 24;
142
+ case 3: k1 ^= ((int64_t) tail[2]) << 16;
143
+ case 2: k1 ^= ((int64_t) tail[1]) << 8;
144
+ case 1: k1 ^= ((int64_t) tail[0]) << 0;
145
+ k1 *= c1;
146
+ k1 = rotl(k1, 31);
147
+ k1 *= c2;
148
+ h1 ^= k1;
149
+ };
150
+
151
+ //----------
152
+ // finalization
153
+
154
+ h1 ^= length;
155
+ h2 ^= length;
156
+
157
+ h1 += h2;
158
+ h2 += h1;
159
+
160
+ h1 = fmix(h1);
161
+ h2 = fmix(h2);
162
+
163
+ h1 += h2;
164
+ h2 += h1;
165
+
166
+ return LL2NUM(h1);
167
+ }
168
+
169
+ void
170
+ Init_cassandra_murmur3()
171
+ {
172
+ VALUE mCassandra, mMurmur3;
173
+
174
+ mCassandra = rb_define_module_under(rb_cObject, "Cassandra");
175
+ mMurmur3 = rb_define_module_under(mCassandra, "Murmur3");
176
+
177
+ rb_define_module_function(mMurmur3, "hash", rb_murmur3_hash, 1);
178
+ }
@@ -0,0 +1,2 @@
1
+ require 'mkmf'
2
+ create_makefile('cassandra_murmur3')
@@ -0,0 +1,36 @@
1
+ # encoding: utf-8
2
+
3
+ #--
4
+ # Copyright DataStax, Inc.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #++
18
+
19
+ module Cassandra
20
+ # Address Resolution policy allows translating a node ip address from what is
21
+ # recorded in Cassandra's system tables to an actual ip address for the driver
22
+ # to use. It is very useful in various multi-region scenarios (e.g. on EC2).
23
+ module AddressResolution
24
+ class Policy
25
+ # Resolves a node ip address.
26
+ #
27
+ # @param address [IPAddr] node ip address from Cassandra's system table
28
+ #
29
+ # @return [IPAddr] actual ip address of the node
30
+ def resolve(address)
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ require 'cassandra/address_resolution/policies'