cassandra-driver 3.2.4 → 3.2.5.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0aa334a3d307fd76859ce7a0182bd96ca27b454c8e80532091872dd7bbeba56
4
- data.tar.gz: 75dda83c9ec236bbc76987fcae00a7970b2d9d31db5b71b51cf8d50de71ae8b8
3
+ metadata.gz: 8bc3b6ca9089580d9ca2d60bc86ac4dacbd08b8a98bf35f4e764e83643081926
4
+ data.tar.gz: ec137f2ffd776d135e7a7ea6baa144731b738d973e8bbc84353326fa7d87db3d
5
5
  SHA512:
6
- metadata.gz: 8318028554e6ad8d9377657c09b6b2a82bb004ca397eca52326364e04b52b4a5f43d8ac1783dbb0af2ac3ebbaab7d9ad0e64c452864b58a42a0a5a373ca73f54
7
- data.tar.gz: d561999a9a759c4b5ec8bf2e9558cb5673a8f5786c855e40e8c2a5586b99d77c319b72f0ae995a1ccebabe3d6b0b5cff3f4d46c35fd724e9c06900b5bf9ab854
6
+ metadata.gz: cc34c092c48ac9a1bbd83a499b32447dfd8484e426efbe9939700a80bee96bb3d0aa839623a217895c4c360bdaedc1940ae1252a195ecc2ce81628b770bb7937
7
+ data.tar.gz: 554b684dea005d8cdd4f0033bdbae4ca5767f86d402041ec51691317d8cb3cff83852e0ca6b1605f0b3c526ccc387e026dc163c7981ff80d27cca2c77c8bc18e
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://github.com/datastax/ruby-dse-driver.git) for
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://github.com/datastax/ruby-dse-driver.git) provides more features and is recommended for use with DataStax Enterprise.
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://github.com/datastax/ruby-dse-driver.git)
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
@@ -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
@@ -1700,5 +1700,9 @@ module Cassandra
1700
1700
  def custom(name)
1701
1701
  Custom.new(name)
1702
1702
  end
1703
+
1704
+ def duration
1705
+ Duration.new 0,0,0
1706
+ end
1703
1707
  end
1704
1708
  end
@@ -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
@@ -17,5 +17,5 @@
17
17
  #++
18
18
 
19
19
  module Cassandra
20
- VERSION = '3.2.4'.freeze
20
+ VERSION = '3.2.5.rc1'.freeze
21
21
  end
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
4
+ version: 3.2.5.rc1
5
5
  platform: ruby
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-04-01 00:00:00.000000000 Z
13
+ date: 2020-10-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ione
@@ -109,6 +109,7 @@ files:
109
109
  - lib/cassandra/compression/compressors/snappy.rb
110
110
  - lib/cassandra/custom_data.rb
111
111
  - lib/cassandra/driver.rb
112
+ - lib/cassandra/duration.rb
112
113
  - lib/cassandra/errors.rb
113
114
  - lib/cassandra/execution/info.rb
114
115
  - lib/cassandra/execution/options.rb
@@ -228,9 +229,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
228
229
  version: 2.2.0
229
230
  required_rubygems_version: !ruby/object:Gem::Requirement
230
231
  requirements:
231
- - - ">="
232
+ - - ">"
232
233
  - !ruby/object:Gem::Version
233
- version: '0'
234
+ version: 1.3.1
234
235
  requirements: []
235
236
  rubygems_version: 3.0.8
236
237
  signing_key: