cassandra-driver 2.1.7 → 3.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +31 -53
- data/lib/cassandra.rb +22 -3
- data/lib/cassandra/aggregate.rb +109 -0
- data/lib/cassandra/argument.rb +51 -0
- data/lib/cassandra/auth/providers/password.rb +7 -4
- data/lib/cassandra/cluster.rb +14 -3
- data/lib/cassandra/cluster/client.rb +56 -34
- data/lib/cassandra/cluster/connector.rb +6 -6
- data/lib/cassandra/cluster/control_connection.rb +204 -251
- data/lib/cassandra/cluster/metadata.rb +2 -0
- data/lib/cassandra/cluster/schema.rb +131 -209
- data/lib/cassandra/cluster/schema/cql_type_parser.rb +104 -0
- data/lib/cassandra/cluster/schema/fetchers.rb +1174 -0
- data/lib/cassandra/cluster/schema/{type_parser.rb → fqcn_type_parser.rb} +7 -3
- data/lib/cassandra/column.rb +2 -2
- data/lib/cassandra/driver.rb +27 -9
- data/lib/cassandra/errors.rb +179 -25
- data/lib/cassandra/execution/info.rb +8 -1
- data/lib/cassandra/execution/options.rb +34 -0
- data/lib/cassandra/execution/trace.rb +42 -10
- data/lib/cassandra/function.rb +150 -0
- data/lib/cassandra/future.rb +66 -35
- data/lib/cassandra/host.rb +7 -4
- data/lib/cassandra/keyspace.rb +112 -13
- data/lib/cassandra/load_balancing.rb +1 -1
- data/lib/cassandra/protocol.rb +9 -3
- data/lib/cassandra/protocol/coder.rb +434 -155
- data/lib/cassandra/protocol/cql_byte_buffer.rb +43 -0
- data/lib/cassandra/protocol/cql_protocol_handler.rb +4 -1
- data/lib/cassandra/protocol/request.rb +4 -0
- data/lib/cassandra/protocol/requests/auth_response_request.rb +5 -1
- data/lib/cassandra/protocol/requests/batch_request.rb +7 -2
- data/lib/cassandra/protocol/requests/credentials_request.rb +5 -1
- data/lib/cassandra/protocol/requests/execute_request.rb +16 -10
- data/lib/cassandra/protocol/requests/prepare_request.rb +12 -3
- data/lib/cassandra/protocol/requests/query_request.rb +20 -11
- data/lib/cassandra/protocol/responses/already_exists_error_response.rb +4 -4
- data/lib/cassandra/protocol/responses/error_response.rb +14 -14
- data/lib/cassandra/protocol/responses/function_failure_error_response.rb +41 -0
- data/lib/cassandra/protocol/responses/prepared_result_response.rb +12 -9
- data/lib/cassandra/protocol/responses/raw_rows_result_response.rb +5 -3
- data/lib/cassandra/protocol/responses/read_failure_error_response.rb +43 -0
- data/lib/cassandra/protocol/responses/read_timeout_error_response.rb +4 -4
- data/lib/cassandra/protocol/responses/ready_response.rb +5 -1
- data/lib/cassandra/protocol/responses/result_response.rb +3 -3
- data/lib/cassandra/protocol/responses/rows_result_response.rb +2 -2
- data/lib/cassandra/protocol/responses/schema_change_event_response.rb +25 -24
- data/lib/cassandra/protocol/responses/schema_change_result_response.rb +20 -23
- data/lib/cassandra/protocol/responses/set_keyspace_result_response.rb +2 -2
- data/lib/cassandra/protocol/responses/unavailable_error_response.rb +4 -4
- data/lib/cassandra/protocol/responses/unprepared_error_response.rb +4 -4
- data/lib/cassandra/protocol/responses/write_failure_error_response.rb +45 -0
- data/lib/cassandra/protocol/responses/write_timeout_error_response.rb +4 -4
- data/lib/cassandra/protocol/v1.rb +38 -13
- data/lib/cassandra/protocol/v3.rb +34 -29
- data/lib/cassandra/protocol/v4.rb +334 -0
- data/lib/cassandra/result.rb +10 -9
- data/lib/cassandra/retry.rb +17 -3
- data/lib/cassandra/retry/policies/default.rb +9 -3
- data/lib/cassandra/session.rb +15 -7
- data/lib/cassandra/statement.rb +5 -0
- data/lib/cassandra/statements/batch.rb +36 -12
- data/lib/cassandra/statements/bound.rb +2 -1
- data/lib/cassandra/statements/prepared.rb +106 -35
- data/lib/cassandra/statements/simple.rb +4 -2
- data/lib/cassandra/table.rb +70 -105
- data/lib/cassandra/time.rb +98 -0
- data/lib/cassandra/time_uuid.rb +1 -1
- data/lib/cassandra/tuple.rb +7 -0
- data/lib/cassandra/types.rb +472 -272
- data/lib/cassandra/udt.rb +10 -0
- data/lib/cassandra/util.rb +32 -1
- data/lib/cassandra/uuid.rb +6 -1
- data/lib/cassandra/uuid/generator.rb +7 -7
- data/lib/cassandra/version.rb +1 -1
- data/lib/datastax/cassandra.rb +5 -2
- metadata +16 -6
data/lib/cassandra/udt.rb
CHANGED
@@ -408,13 +408,23 @@ module Cassandra
|
|
408
408
|
'{ ' + @values.map {|(n, v)| "#{n}: #{v.inspect}"}.join(', ') + ' }'
|
409
409
|
end
|
410
410
|
|
411
|
+
# @private
|
411
412
|
def inspect
|
412
413
|
"#<Cassandra::UDT:0x#{self.object_id.to_s(16)} #{to_s}>"
|
413
414
|
end
|
414
415
|
|
416
|
+
# @private
|
415
417
|
def eql?(other)
|
416
418
|
other.is_a?(UDT) && @values.all? {|(n, v)| v == other[n]}
|
417
419
|
end
|
418
420
|
alias :== :eql?
|
421
|
+
|
422
|
+
# @private
|
423
|
+
def hash
|
424
|
+
@values.inject(17) do |h, (n, v)|
|
425
|
+
h = 31 * h + n.hash
|
426
|
+
h = 31 * h + v.hash
|
427
|
+
end
|
428
|
+
end
|
419
429
|
end
|
420
430
|
end
|
data/lib/cassandra/util.rb
CHANGED
@@ -99,6 +99,9 @@ module Cassandra
|
|
99
99
|
when ::Numeric then encode_number(object, io)
|
100
100
|
when ::IPAddr then encode_inet(object, io)
|
101
101
|
when Uuid then encode_uuid(object, io)
|
102
|
+
when Tuple then encode_tuple(object, io)
|
103
|
+
when Time then encode_time(object, io)
|
104
|
+
when UDT then encode_udt(object, io)
|
102
105
|
when nil then io.print(NULL_STR)
|
103
106
|
when false then io.print(FALSE_STR)
|
104
107
|
when true then io.print(TRUE_STR)
|
@@ -110,6 +113,14 @@ module Cassandra
|
|
110
113
|
end
|
111
114
|
alias :encode :encode_object
|
112
115
|
|
116
|
+
def encode_time(time, io = StringIO.new)
|
117
|
+
encode_string(time.to_s, io)
|
118
|
+
end
|
119
|
+
|
120
|
+
def encode_udt(udt, io = StringIO.new)
|
121
|
+
encode_hash(udt.to_h, io)
|
122
|
+
end
|
123
|
+
|
113
124
|
def encode_timestamp(time, io = StringIO.new)
|
114
125
|
io.print(time.to_i)
|
115
126
|
io.string
|
@@ -132,6 +143,22 @@ module Cassandra
|
|
132
143
|
io.string
|
133
144
|
end
|
134
145
|
|
146
|
+
def encode_tuple(tuple, io = StringIO.new)
|
147
|
+
first = true
|
148
|
+
|
149
|
+
io.putc(PRN_OPN)
|
150
|
+
tuple.each do |object|
|
151
|
+
if first
|
152
|
+
first = false
|
153
|
+
else
|
154
|
+
io.print(COMMA)
|
155
|
+
end
|
156
|
+
|
157
|
+
encode_object(object, io)
|
158
|
+
end
|
159
|
+
io.putc(PRN_CLS)
|
160
|
+
end
|
161
|
+
|
135
162
|
def escape_name(name)
|
136
163
|
return name if name[LOWERCASE_REGEXP] == name
|
137
164
|
DBL_QUOT + name + DBL_QUOT
|
@@ -282,12 +309,16 @@ module Cassandra
|
|
282
309
|
# @private
|
283
310
|
COMMA = ', '.freeze
|
284
311
|
# @private
|
285
|
-
COLON = '
|
312
|
+
COLON = ': '.freeze
|
286
313
|
# @private
|
287
314
|
QUOT = ?'.freeze
|
288
315
|
# @private
|
289
316
|
ESC_QUOT = "''".freeze
|
290
317
|
# @private
|
291
318
|
DBL_QUOT = ?".freeze
|
319
|
+
# @private
|
320
|
+
PRN_OPN = '('.freeze
|
321
|
+
# @private
|
322
|
+
PRN_CLS = ')'.freeze
|
292
323
|
end
|
293
324
|
end
|
data/lib/cassandra/uuid.rb
CHANGED
@@ -44,7 +44,7 @@ module Cassandra
|
|
44
44
|
# @param [Object<#now>] clock used to generate timeuuid from current time
|
45
45
|
#
|
46
46
|
# @raise [ArgumentError] if clock doesn't respond to `now`
|
47
|
-
def initialize(node_id = (SecureRandom.random_number(2**47) | 0x010000000000), clock_id = SecureRandom.random_number(65536), clock = Time)
|
47
|
+
def initialize(node_id = (::SecureRandom.random_number(2**47) | 0x010000000000), clock_id = ::SecureRandom.random_number(65536), clock = ::Time)
|
48
48
|
raise ::ArgumentError, "invalid clock" unless clock.respond_to?(:now)
|
49
49
|
|
50
50
|
@node_id = Integer(node_id)
|
@@ -84,7 +84,7 @@ module Cassandra
|
|
84
84
|
@sequence += 1
|
85
85
|
elsif @last_usecs && @last_usecs > usecs
|
86
86
|
@sequence = 0
|
87
|
-
@clock_id = SecureRandom.random_number(65536)
|
87
|
+
@clock_id = ::SecureRandom.random_number(65536)
|
88
88
|
else
|
89
89
|
@sequence = 0
|
90
90
|
end
|
@@ -153,12 +153,12 @@ module Cassandra
|
|
153
153
|
raise ::ArgumentError, "not enough arguments" if args.empty?
|
154
154
|
raise ::ArgumentError, "too many arguments" if args.size > 3
|
155
155
|
|
156
|
-
if args.first.is_a?(Time)
|
156
|
+
if args.first.is_a?(::Time)
|
157
157
|
time = args.shift
|
158
|
-
jitter = args.empty? ? SecureRandom.random_number(65536) : Integer(args.shift)
|
158
|
+
jitter = args.empty? ? ::SecureRandom.random_number(65536) : Integer(args.shift)
|
159
159
|
else
|
160
|
-
jitter = args.size > 2 ? Integer(args.pop) : SecureRandom.random_number(65536)
|
161
|
-
time = Time.at(*args)
|
160
|
+
jitter = args.size > 2 ? Integer(args.pop) : ::SecureRandom.random_number(65536)
|
161
|
+
time = ::Time.at(*args)
|
162
162
|
end
|
163
163
|
|
164
164
|
from_usecs(time.to_i * 1_000_000 + time.usec + jitter)
|
@@ -179,7 +179,7 @@ module Cassandra
|
|
179
179
|
#
|
180
180
|
# @return [Cassandra::Uuid] a new UUID
|
181
181
|
def uuid
|
182
|
-
Uuid.new(SecureRandom.uuid)
|
182
|
+
Uuid.new(::SecureRandom.uuid)
|
183
183
|
end
|
184
184
|
|
185
185
|
private
|
data/lib/cassandra/version.rb
CHANGED
data/lib/datastax/cassandra.rb
CHANGED
@@ -33,12 +33,15 @@ module DataStax
|
|
33
33
|
end
|
34
34
|
|
35
35
|
previous = nil
|
36
|
+
murmur3 = nil
|
36
37
|
if defined?(::Cassandra)
|
37
38
|
previous = ::Cassandra
|
39
|
+
murmur3 = ::Cassandra::Murmur3
|
38
40
|
Object.send(:remove_const, :Cassandra)
|
39
41
|
end
|
40
42
|
include 'cassandra'
|
41
|
-
|
42
|
-
|
43
|
+
murmur3 ||= ::Cassandra::Murmur3
|
44
|
+
DataStax::Cassandra::Murmur3 = murmur3
|
45
|
+
Object.send(:remove_const, :Cassandra) if defined?(::Cassandra)
|
43
46
|
::Cassandra = previous if previous
|
44
47
|
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:
|
4
|
+
version: 3.0.0.beta.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Theo Hultberg
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-12-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ione
|
@@ -72,6 +72,8 @@ files:
|
|
72
72
|
- lib/cassandra/address_resolution/policies.rb
|
73
73
|
- lib/cassandra/address_resolution/policies/ec2_multi_region.rb
|
74
74
|
- lib/cassandra/address_resolution/policies/none.rb
|
75
|
+
- lib/cassandra/aggregate.rb
|
76
|
+
- lib/cassandra/argument.rb
|
75
77
|
- lib/cassandra/auth.rb
|
76
78
|
- lib/cassandra/auth/providers.rb
|
77
79
|
- lib/cassandra/auth/providers/password.rb
|
@@ -85,6 +87,9 @@ files:
|
|
85
87
|
- lib/cassandra/cluster/options.rb
|
86
88
|
- lib/cassandra/cluster/registry.rb
|
87
89
|
- lib/cassandra/cluster/schema.rb
|
90
|
+
- lib/cassandra/cluster/schema/cql_type_parser.rb
|
91
|
+
- lib/cassandra/cluster/schema/fetchers.rb
|
92
|
+
- lib/cassandra/cluster/schema/fqcn_type_parser.rb
|
88
93
|
- lib/cassandra/cluster/schema/partitioners.rb
|
89
94
|
- lib/cassandra/cluster/schema/partitioners/murmur3.rb
|
90
95
|
- lib/cassandra/cluster/schema/partitioners/ordered.rb
|
@@ -93,7 +98,6 @@ files:
|
|
93
98
|
- lib/cassandra/cluster/schema/replication_strategies/network_topology.rb
|
94
99
|
- lib/cassandra/cluster/schema/replication_strategies/none.rb
|
95
100
|
- lib/cassandra/cluster/schema/replication_strategies/simple.rb
|
96
|
-
- lib/cassandra/cluster/schema/type_parser.rb
|
97
101
|
- lib/cassandra/column.rb
|
98
102
|
- lib/cassandra/compression.rb
|
99
103
|
- lib/cassandra/compression/compressors/lz4.rb
|
@@ -104,6 +108,7 @@ files:
|
|
104
108
|
- lib/cassandra/execution/options.rb
|
105
109
|
- lib/cassandra/execution/trace.rb
|
106
110
|
- lib/cassandra/executors.rb
|
111
|
+
- lib/cassandra/function.rb
|
107
112
|
- lib/cassandra/future.rb
|
108
113
|
- lib/cassandra/host.rb
|
109
114
|
- lib/cassandra/keyspace.rb
|
@@ -137,8 +142,10 @@ files:
|
|
137
142
|
- lib/cassandra/protocol/responses/authenticate_response.rb
|
138
143
|
- lib/cassandra/protocol/responses/error_response.rb
|
139
144
|
- lib/cassandra/protocol/responses/event_response.rb
|
145
|
+
- lib/cassandra/protocol/responses/function_failure_error_response.rb
|
140
146
|
- lib/cassandra/protocol/responses/prepared_result_response.rb
|
141
147
|
- lib/cassandra/protocol/responses/raw_rows_result_response.rb
|
148
|
+
- lib/cassandra/protocol/responses/read_failure_error_response.rb
|
142
149
|
- lib/cassandra/protocol/responses/read_timeout_error_response.rb
|
143
150
|
- lib/cassandra/protocol/responses/ready_response.rb
|
144
151
|
- lib/cassandra/protocol/responses/result_response.rb
|
@@ -152,9 +159,11 @@ files:
|
|
152
159
|
- lib/cassandra/protocol/responses/unavailable_error_response.rb
|
153
160
|
- lib/cassandra/protocol/responses/unprepared_error_response.rb
|
154
161
|
- lib/cassandra/protocol/responses/void_result_response.rb
|
162
|
+
- lib/cassandra/protocol/responses/write_failure_error_response.rb
|
155
163
|
- lib/cassandra/protocol/responses/write_timeout_error_response.rb
|
156
164
|
- lib/cassandra/protocol/v1.rb
|
157
165
|
- lib/cassandra/protocol/v3.rb
|
166
|
+
- lib/cassandra/protocol/v4.rb
|
158
167
|
- lib/cassandra/reconnection.rb
|
159
168
|
- lib/cassandra/reconnection/policies.rb
|
160
169
|
- lib/cassandra/reconnection/policies/constant.rb
|
@@ -174,6 +183,7 @@ files:
|
|
174
183
|
- lib/cassandra/statements/simple.rb
|
175
184
|
- lib/cassandra/statements/void.rb
|
176
185
|
- lib/cassandra/table.rb
|
186
|
+
- lib/cassandra/time.rb
|
177
187
|
- lib/cassandra/time_uuid.rb
|
178
188
|
- lib/cassandra/tuple.rb
|
179
189
|
- lib/cassandra/types.rb
|
@@ -203,12 +213,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
203
213
|
version: 1.9.3
|
204
214
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
205
215
|
requirements:
|
206
|
-
- - ! '
|
216
|
+
- - ! '>'
|
207
217
|
- !ruby/object:Gem::Version
|
208
|
-
version:
|
218
|
+
version: 1.3.1
|
209
219
|
requirements: []
|
210
220
|
rubyforge_project:
|
211
|
-
rubygems_version: 2.
|
221
|
+
rubygems_version: 2.4.6
|
212
222
|
signing_key:
|
213
223
|
specification_version: 4
|
214
224
|
summary: Datastax Ruby Driver for Apache Cassandra
|