cassandra-driver 3.2.4-java → 3.2.5.rc1-java
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.
- checksums.yaml +4 -4
- data/README.md +5 -8
- 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/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 +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7c6c180e3e95e0dcb2b165a945a2b6f6f3da0be
|
4
|
+
data.tar.gz: dfb7aad73dcb9eab0b42fd3d15e1d017a6a9f486
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22fc0ee683c5ec364e79314a59e55b0c8672152b000ed429ce5148a9844bd18fd86ad6e708dcedea2ec290576e1fbade54c6d62963d8d3187cbbdf40f32137a5
|
7
|
+
data.tar.gz: 831421e9a3c617c7caa3217c636408f8a15e1febecf35166c10622037fb18b7fa1376582b1583983cfa0246face23b57ee16eb8cf967532c95b265ce29faa28e
|
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
|
@@ -104,8 +102,7 @@ In the examples directory, you can find [an example of how to wrap the ruby driv
|
|
104
102
|
interface parity with cql-rb](https://github.com/datastax/ruby-driver/blob/v3.2.4/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
|
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
|
@@ -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.rc1
|
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-01 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
|
@@ -226,9 +227,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
226
227
|
version: 2.2.0
|
227
228
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
228
229
|
requirements:
|
229
|
-
- - "
|
230
|
+
- - ">"
|
230
231
|
- !ruby/object:Gem::Version
|
231
|
-
version:
|
232
|
+
version: 1.3.1
|
232
233
|
requirements: []
|
233
234
|
rubyforge_project:
|
234
235
|
rubygems_version: 2.4.8
|