cassandra-driver 3.2.4-java → 3.2.5-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -12
- data/lib/cassandra.rb +2 -1
- data/lib/cassandra/cluster/schema/cql_type_parser.rb +1 -0
- data/lib/cassandra/duration.rb +100 -0
- data/lib/cassandra/protocol/cql_byte_buffer.rb +42 -0
- data/lib/cassandra/protocol/requests/query_request.rb +10 -2
- data/lib/cassandra/protocol/v4.rb +3 -0
- data/lib/cassandra/types.rb +4 -0
- data/lib/cassandra/util.rb +20 -0
- data/lib/cassandra/version.rb +1 -1
- data/lib/cassandra_murmur3.jar +0 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adcc351cebf1729957fd2025e3dda1cf7fc321ab
|
4
|
+
data.tar.gz: d42716e5990eca3d78e8bcafb0dd81d822e3682d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e7aac57c3abc6ac87a67e786185166e0415bfee8904f1ff225df934a0566b0f1906092a12c85f938f612e47802979ac02f3f3d527eb95ad60358197c5a35ef6
|
7
|
+
data.tar.gz: 7939cfefe9c669fecc346b1e7b8cbb4eb55d68be75a57927682f1c0fe522740658c2d775dbaebc700dc218fe8d789dd75ceb4b8bdecc87030eeebc5551b166aa
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
:warning: **The Ruby driver is in maintenance mode. We are still accepting pull-requests and we will occasionally release critical bug fixes, but no ongoing active development is being done currently.**
|
2
|
+
|
1
3
|
# Datastax Ruby Driver for Apache Cassandra
|
2
4
|
|
3
5
|
*If you're reading this on GitHub, please note that this is the readme for the development version and that some
|
@@ -9,7 +11,7 @@ version [here](http://docs.datastax.com/en/developer/ruby-driver/latest).*
|
|
9
11
|
A Ruby client driver for Apache Cassandra. This driver works exclusively with
|
10
12
|
the Cassandra Query Language version 3 (CQL3) and Cassandra's native protocol.
|
11
13
|
|
12
|
-
Use the [Ruby DSE driver](https://
|
14
|
+
Use the [Ruby DSE driver](https://docs.datastax.com/en/developer/ruby-driver-dse/2.1/) for
|
13
15
|
better compatibility and support for DataStax Enterprise.
|
14
16
|
|
15
17
|
- Code: https://github.com/datastax/ruby-driver
|
@@ -37,7 +39,7 @@ This driver is based on [the cql-rb gem](https://github.com/iconara/cql-rb) by [
|
|
37
39
|
This driver works exclusively with the Cassandra Query Language v3 (CQL3) and Cassandra's native protocol. The current version works with:
|
38
40
|
|
39
41
|
* Apache Cassandra versions 2.1, 2.2, and 3.x
|
40
|
-
* DataStax Enterprise 4.8 and above. However, the [Ruby DSE driver](https://
|
42
|
+
* DataStax Enterprise 4.8 and above. However, the [Ruby DSE driver](https://docs.datastax.com/en/developer/ruby-driver-dse/2.1/) provides more features and is recommended for use with DataStax Enterprise.
|
41
43
|
* Ruby (MRI) 2.2, 2.3, 2.4
|
42
44
|
* JRuby 9k
|
43
45
|
|
@@ -45,10 +47,6 @@ __Note__: Rubinius is not supported.
|
|
45
47
|
|
46
48
|
__Note__: Big-endian systems are not supported.
|
47
49
|
|
48
|
-
## Feedback Requested
|
49
|
-
|
50
|
-
*Help us focus our efforts!* [Provide your input](http://goo.gl/forms/pCs8PTpHLf) on the Ruby Driver Platform and Runtime Survey (we kept it short).
|
51
|
-
|
52
50
|
## Quick start
|
53
51
|
|
54
52
|
```ruby
|
@@ -101,18 +99,17 @@ __Note__: if you want to use compression you should also install [snappy](http:/
|
|
101
99
|
|
102
100
|
Some of the new features added to the driver have unfortunately led to changes in the original cql-rb API.
|
103
101
|
In the examples directory, you can find [an example of how to wrap the ruby driver to achieve almost complete
|
104
|
-
interface parity with cql-rb](https://github.com/datastax/ruby-driver/blob/v3.2.
|
102
|
+
interface parity with cql-rb](https://github.com/datastax/ruby-driver/blob/v3.2.5/examples/cql-rb-wrapper.rb)
|
105
103
|
to assist you with gradual upgrade.
|
106
104
|
|
107
|
-
If you are upgrading to DataStax Enterprise, use the [Ruby DSE driver](https://
|
108
|
-
for more features and better compatibility.
|
105
|
+
If you are upgrading to DataStax Enterprise, use the [Ruby DSE driver](https://docs.datastax.com/en/developer/ruby-driver-dse/2.1/) for more features and better compatibility.
|
109
106
|
|
110
107
|
## What's new in v3.2
|
111
108
|
This minor release adds support for MRI 2.4.x and also contains a few miscellaneous defect fixes. It also removes
|
112
109
|
support for Ruby versions prior to 2.2. This was already officially the case, but the minimum version limit is
|
113
110
|
now enforced.
|
114
111
|
|
115
|
-
See the [changelog](https://github.com/datastax/ruby-driver/blob/v3.2.
|
112
|
+
See the [changelog](https://github.com/datastax/ruby-driver/blob/v3.2.5/CHANGELOG.md) for more information on all
|
116
113
|
changes in this version and past versions.
|
117
114
|
|
118
115
|
## What's new in v3.1
|
@@ -180,7 +177,7 @@ examples in the `features/` directory.
|
|
180
177
|
## Running tests
|
181
178
|
|
182
179
|
If you don't feel like reading through the following instructions on how to run
|
183
|
-
ruby-driver tests, feel free to [check out .travis.yml for the entire build code](https://github.com/datastax/ruby-driver/blob/v3.2.
|
180
|
+
ruby-driver tests, feel free to [check out .travis.yml for the entire build code](https://github.com/datastax/ruby-driver/blob/v3.2.5/.travis.yml).
|
184
181
|
|
185
182
|
* Check out the driver codebase and install test dependencies:
|
186
183
|
|
@@ -204,7 +201,7 @@ CASSANDRA_VERSION=2.1.12 bundle exec rake test # run both as well as integration
|
|
204
201
|
## Changelog & versioning
|
205
202
|
|
206
203
|
Check out the [releases on GitHub](https://github.com/datastax/ruby-driver/releases) and
|
207
|
-
[changelog](https://github.com/datastax/ruby-driver/blob/v3.2.
|
204
|
+
[changelog](https://github.com/datastax/ruby-driver/blob/v3.2.5/CHANGELOG.md). Version
|
208
205
|
numbering follows the [semantic versioning](http://semver.org/) scheme.
|
209
206
|
|
210
207
|
Private and experimental APIs, defined as whatever is not in the
|
data/lib/cassandra.rb
CHANGED
@@ -777,6 +777,8 @@ require 'cassandra/udt'
|
|
777
777
|
require 'cassandra/time'
|
778
778
|
|
779
779
|
require 'cassandra/types'
|
780
|
+
require 'cassandra/custom_data'
|
781
|
+
require 'cassandra/duration'
|
780
782
|
|
781
783
|
require 'cassandra/errors'
|
782
784
|
require 'cassandra/compression'
|
@@ -788,7 +790,6 @@ require 'cassandra/null_logger'
|
|
788
790
|
require 'cassandra/executors'
|
789
791
|
require 'cassandra/future'
|
790
792
|
require 'cassandra/cluster'
|
791
|
-
require 'cassandra/custom_data'
|
792
793
|
require 'cassandra/driver'
|
793
794
|
require 'cassandra/host'
|
794
795
|
require 'cassandra/session'
|
@@ -60,6 +60,7 @@ module Cassandra
|
|
60
60
|
when 'smallint' then Cassandra::Types.smallint
|
61
61
|
when 'time' then Cassandra::Types.time
|
62
62
|
when 'tinyint' then Cassandra::Types.tinyint
|
63
|
+
when 'duration' then Cassandra::Types.duration
|
63
64
|
when 'map' then
|
64
65
|
Cassandra::Types.map(*node.children.map { |t| lookup_type(t, types)})
|
65
66
|
when 'set' then
|
@@ -0,0 +1,100 @@
|
|
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
|
+
module Cassandra
|
19
|
+
module Types
|
20
|
+
|
21
|
+
class Duration < Type
|
22
|
+
include CustomData
|
23
|
+
|
24
|
+
@@four_byte_max = 2 ** 32
|
25
|
+
@@eight_byte_max = 2 ** 64
|
26
|
+
|
27
|
+
# @private
|
28
|
+
attr_reader :months, :days, :nanos
|
29
|
+
|
30
|
+
# @private
|
31
|
+
def initialize(months, days, nanos)
|
32
|
+
super(:duration)
|
33
|
+
@months = months
|
34
|
+
@days = days
|
35
|
+
@nanos = nanos
|
36
|
+
end
|
37
|
+
|
38
|
+
def new(*values)
|
39
|
+
Util.assert_size(3, values, "Duration type expects three values, #{values.size} were provided")
|
40
|
+
values.each { |v| Util.assert_type(Int, v) }
|
41
|
+
Util.assert (Util.encode_zigzag32(values[0]) < @@four_byte_max), "Months value must be a valid 32-bit integer"
|
42
|
+
Util.assert (Util.encode_zigzag32(values[1]) < @@four_byte_max), "Days value must be a valid 32-bit integer"
|
43
|
+
Util.assert (Util.encode_zigzag64(values[2]) < @@eight_byte_max), "Nanos value must be a valid 64-bit integer"
|
44
|
+
all_positive = values.all? {|i| i >= 0 }
|
45
|
+
all_negative = values.all? {|i| i <= 0 }
|
46
|
+
Util.assert (all_positive or all_negative), "Values in a duration must be uniformly positive or negative"
|
47
|
+
Duration.new *values
|
48
|
+
end
|
49
|
+
|
50
|
+
def assert(value, message = nil, &block)
|
51
|
+
Util.assert_instance_of(Duration, value, message, &block)
|
52
|
+
end
|
53
|
+
|
54
|
+
def to_s
|
55
|
+
"Duration: months => #{@months}, days => #{@days}, nanos => #{@nanos}"
|
56
|
+
end
|
57
|
+
|
58
|
+
def hash
|
59
|
+
@hash ||= begin
|
60
|
+
h = 17
|
61
|
+
h = 31 * h + @months.hash
|
62
|
+
h = 31 * h + @days.hash
|
63
|
+
h = 31 * h + @nanos.hash
|
64
|
+
h
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def eql?(other)
|
69
|
+
other.is_a?(Duration) &&
|
70
|
+
@months == other.months &&
|
71
|
+
@days == other.days &&
|
72
|
+
@nanos == other.nanos
|
73
|
+
end
|
74
|
+
|
75
|
+
alias == eql?
|
76
|
+
|
77
|
+
def self.cql_type
|
78
|
+
Type.new(@kind)
|
79
|
+
end
|
80
|
+
|
81
|
+
# Requirements for CustomData module
|
82
|
+
def self.deserialize(bytestr)
|
83
|
+
buffer = Cassandra::Protocol::CqlByteBuffer.new.append(bytestr)
|
84
|
+
Cassandra::Types::Duration.new(buffer.read_signed_vint,buffer.read_signed_vint,buffer.read_signed_vint)
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.type
|
88
|
+
Cassandra::Types::Custom.new('org.apache.cassandra.db.marshal.DurationType')
|
89
|
+
end
|
90
|
+
|
91
|
+
def serialize
|
92
|
+
rv = Cassandra::Protocol::CqlByteBuffer.new
|
93
|
+
rv.append_signed_vint32(@months)
|
94
|
+
rv.append_signed_vint32(@days)
|
95
|
+
rv.append_signed_vint64(@nanos)
|
96
|
+
rv
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -287,6 +287,29 @@ module Cassandra
|
|
287
287
|
"Not enough bytes available to decode a tinyint: #{e.message}", e.backtrace
|
288
288
|
end
|
289
289
|
|
290
|
+
def read_vint
|
291
|
+
n = read_byte
|
292
|
+
|
293
|
+
# Bits are indexed in Integer in little-endian order
|
294
|
+
bytes_to_read = 7.downto(0).take_while {|i| n[i] == 1}.size
|
295
|
+
return n unless bytes_to_read > 0
|
296
|
+
|
297
|
+
rv = n & (0xff >> bytes_to_read)
|
298
|
+
1.upto(bytes_to_read) do |idx|
|
299
|
+
new_byte = read_byte
|
300
|
+
rv <<= 8
|
301
|
+
rv |= (new_byte & 0xff)
|
302
|
+
end
|
303
|
+
|
304
|
+
rv
|
305
|
+
rescue RangeError => e
|
306
|
+
raise Errors::DecodingError, e.message, e.backtrace
|
307
|
+
end
|
308
|
+
|
309
|
+
def read_signed_vint
|
310
|
+
Util.decode_zigzag(read_vint)
|
311
|
+
end
|
312
|
+
|
290
313
|
def append_tinyint(n)
|
291
314
|
append([n].pack(Formats::CHAR_FORMAT))
|
292
315
|
end
|
@@ -409,6 +432,25 @@ module Cassandra
|
|
409
432
|
append([n].pack(Formats::FLOAT_FORMAT))
|
410
433
|
end
|
411
434
|
|
435
|
+
def append_vint(n)
|
436
|
+
send_bytes = Util.to_min_byte_array(n)
|
437
|
+
send_cnt = send_bytes.length
|
438
|
+
|
439
|
+
raise Errors::EncodingError, "Too many bytes (#{bytes_to_send.length}) to send!" if send_cnt > 8
|
440
|
+
|
441
|
+
send_cnt_byte = (0xff << (8 - send_cnt)) & 0xff
|
442
|
+
append([send_cnt_byte].pack(Formats::BYTES_FORMAT))
|
443
|
+
append(send_bytes.pack(Formats::BYTES_FORMAT))
|
444
|
+
end
|
445
|
+
|
446
|
+
def append_signed_vint32(n)
|
447
|
+
append_vint(Util.encode_zigzag32(n))
|
448
|
+
end
|
449
|
+
|
450
|
+
def append_signed_vint64(n)
|
451
|
+
append_vint(Util.encode_zigzag64(n))
|
452
|
+
end
|
453
|
+
|
412
454
|
def eql?(other)
|
413
455
|
other.eql?(to_str)
|
414
456
|
end
|
@@ -51,6 +51,14 @@ module Cassandra
|
|
51
51
|
!!@payload
|
52
52
|
end
|
53
53
|
|
54
|
+
def append_flags(buffer,flags,protocol_version)
|
55
|
+
if protocol_version < 5
|
56
|
+
buffer.append(flags.chr)
|
57
|
+
else
|
58
|
+
buffer.append_int(flags)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
54
62
|
def write(buffer, protocol_version, encoder)
|
55
63
|
buffer.append_long_string(@cql)
|
56
64
|
buffer.append_consistency(@consistency)
|
@@ -63,10 +71,10 @@ module Cassandra
|
|
63
71
|
if @values && !@values.empty?
|
64
72
|
flags |= 0x01
|
65
73
|
flags |= 0x40 if protocol_version > 2 && !@names.empty?
|
66
|
-
buffer
|
74
|
+
append_flags(buffer, flags, protocol_version)
|
67
75
|
encoder.write_parameters(buffer, @values, @type_hints, @names)
|
68
76
|
else
|
69
|
-
buffer
|
77
|
+
append_flags(buffer, flags, protocol_version)
|
70
78
|
end
|
71
79
|
buffer.append_int(@page_size) if @page_size
|
72
80
|
buffer.append_bytes(@paging_state) if @paging_state
|
@@ -61,6 +61,9 @@ module Cassandra
|
|
61
61
|
|
62
62
|
class Decoder
|
63
63
|
def initialize(handler, compressor = nil, custom_type_handlers = {})
|
64
|
+
# In v4 the duration type is represented as a custom type so we always want to have
|
65
|
+
# a handler included here. This handler can be overridden via the connection options.
|
66
|
+
custom_type_handlers[Cassandra::Types::Duration.type] ||= Cassandra::Types::Duration
|
64
67
|
@handler = handler
|
65
68
|
@compressor = compressor
|
66
69
|
@state = :initial
|
data/lib/cassandra/types.rb
CHANGED
data/lib/cassandra/util.rb
CHANGED
@@ -302,6 +302,26 @@ module Cassandra
|
|
302
302
|
end
|
303
303
|
end
|
304
304
|
|
305
|
+
def to_byte_array(n)
|
306
|
+
[n].pack("Q>").unpack("C*")
|
307
|
+
end
|
308
|
+
|
309
|
+
def to_min_byte_array(n)
|
310
|
+
to_byte_array(n).drop_while {|i| i == 0}
|
311
|
+
end
|
312
|
+
|
313
|
+
def decode_zigzag(n)
|
314
|
+
(n >> 1) ^ -(n & 1)
|
315
|
+
end
|
316
|
+
|
317
|
+
def encode_zigzag32(n)
|
318
|
+
(n >> 31) ^ (n << 1)
|
319
|
+
end
|
320
|
+
|
321
|
+
def encode_zigzag64(n)
|
322
|
+
(n >> 63) ^ (n << 1)
|
323
|
+
end
|
324
|
+
|
305
325
|
# @private
|
306
326
|
LOWERCASE_REGEXP = /[[:lower:]\_]*/
|
307
327
|
# @private
|
data/lib/cassandra/version.rb
CHANGED
data/lib/cassandra_murmur3.jar
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cassandra-driver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.5
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Theo Hultberg
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-
|
13
|
+
date: 2020-10-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,6 +106,7 @@ files:
|
|
106
106
|
- lib/cassandra/compression/compressors/snappy.rb
|
107
107
|
- lib/cassandra/custom_data.rb
|
108
108
|
- lib/cassandra/driver.rb
|
109
|
+
- lib/cassandra/duration.rb
|
109
110
|
- lib/cassandra/errors.rb
|
110
111
|
- lib/cassandra/execution/info.rb
|
111
112
|
- lib/cassandra/execution/options.rb
|