cassandra-driver 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/README.md +18 -9
- data/ext/cassandra_murmur3/cassandra_murmur3.c +1 -1
- data/lib/cassandra.rb +5 -1
- data/lib/cassandra/address_resolution.rb +1 -1
- data/lib/cassandra/address_resolution/policies/ec2_multi_region.rb +1 -1
- data/lib/cassandra/address_resolution/policies/none.rb +1 -1
- data/lib/cassandra/auth.rb +1 -1
- data/lib/cassandra/auth/providers.rb +1 -1
- data/lib/cassandra/auth/providers/password.rb +1 -1
- data/lib/cassandra/cluster.rb +1 -1
- data/lib/cassandra/cluster/client.rb +33 -13
- data/lib/cassandra/cluster/connection_pool.rb +1 -1
- data/lib/cassandra/cluster/connector.rb +1 -36
- data/lib/cassandra/cluster/control_connection.rb +85 -9
- data/lib/cassandra/cluster/failed_connection.rb +1 -1
- data/lib/cassandra/cluster/metadata.rb +1 -1
- data/lib/cassandra/cluster/options.rb +15 -4
- data/lib/cassandra/cluster/registry.rb +1 -1
- data/lib/cassandra/cluster/schema.rb +76 -16
- data/lib/cassandra/cluster/schema/partitioners.rb +1 -1
- data/lib/cassandra/cluster/schema/partitioners/murmur3.rb +1 -1
- data/lib/cassandra/cluster/schema/partitioners/ordered.rb +1 -1
- data/lib/cassandra/cluster/schema/partitioners/random.rb +1 -1
- data/lib/cassandra/cluster/schema/replication_strategies.rb +1 -1
- data/lib/cassandra/cluster/schema/replication_strategies/network_topology.rb +1 -1
- data/lib/cassandra/cluster/schema/replication_strategies/none.rb +1 -1
- data/lib/cassandra/cluster/schema/replication_strategies/simple.rb +1 -1
- data/lib/cassandra/cluster/schema/type_parser.rb +35 -8
- data/lib/cassandra/column.rb +10 -14
- data/lib/cassandra/compression.rb +1 -1
- data/lib/cassandra/compression/compressors/lz4.rb +1 -1
- data/lib/cassandra/compression/compressors/snappy.rb +1 -1
- data/lib/cassandra/driver.rb +2 -2
- data/lib/cassandra/errors.rb +1 -1
- data/lib/cassandra/execution/info.rb +1 -1
- data/lib/cassandra/execution/options.rb +3 -2
- data/lib/cassandra/execution/trace.rb +1 -1
- data/lib/cassandra/executors.rb +1 -1
- data/lib/cassandra/future.rb +1 -1
- data/lib/cassandra/host.rb +1 -1
- data/lib/cassandra/keyspace.rb +55 -5
- data/lib/cassandra/listener.rb +1 -1
- data/lib/cassandra/load_balancing.rb +1 -1
- data/lib/cassandra/load_balancing/policies.rb +1 -1
- data/lib/cassandra/load_balancing/policies/dc_aware_round_robin.rb +1 -1
- data/lib/cassandra/load_balancing/policies/round_robin.rb +1 -1
- data/lib/cassandra/load_balancing/policies/token_aware.rb +1 -1
- data/lib/cassandra/load_balancing/policies/white_list.rb +1 -1
- data/lib/cassandra/null_logger.rb +1 -1
- data/lib/cassandra/protocol.rb +6 -1
- data/lib/cassandra/protocol/coder.rb +319 -84
- data/lib/cassandra/protocol/cql_byte_buffer.rb +1 -1
- data/lib/cassandra/protocol/cql_protocol_handler.rb +24 -10
- data/lib/cassandra/protocol/request.rb +1 -1
- data/lib/cassandra/protocol/requests/auth_response_request.rb +1 -1
- data/lib/cassandra/protocol/requests/batch_request.rb +1 -1
- data/lib/cassandra/protocol/requests/credentials_request.rb +1 -1
- data/lib/cassandra/protocol/requests/execute_request.rb +1 -1
- data/lib/cassandra/protocol/requests/options_request.rb +1 -1
- data/lib/cassandra/protocol/requests/prepare_request.rb +1 -1
- data/lib/cassandra/protocol/requests/query_request.rb +5 -3
- data/lib/cassandra/protocol/requests/register_request.rb +1 -1
- data/lib/cassandra/protocol/requests/startup_request.rb +1 -1
- data/lib/cassandra/protocol/requests/void_query_request.rb +1 -1
- data/lib/cassandra/protocol/response.rb +1 -1
- data/lib/cassandra/protocol/responses/already_exists_error_response.rb +1 -1
- data/lib/cassandra/protocol/responses/auth_challenge_response.rb +1 -1
- data/lib/cassandra/protocol/responses/auth_success_response.rb +1 -1
- data/lib/cassandra/protocol/responses/authenticate_response.rb +1 -1
- data/lib/cassandra/protocol/responses/error_response.rb +1 -1
- data/lib/cassandra/protocol/responses/event_response.rb +1 -1
- data/lib/cassandra/protocol/responses/prepared_result_response.rb +1 -1
- data/lib/cassandra/protocol/responses/raw_rows_result_response.rb +9 -2
- data/lib/cassandra/protocol/responses/read_timeout_error_response.rb +1 -1
- data/lib/cassandra/protocol/responses/ready_response.rb +1 -1
- data/lib/cassandra/protocol/responses/result_response.rb +1 -1
- data/lib/cassandra/protocol/responses/rows_result_response.rb +1 -1
- data/lib/cassandra/protocol/responses/schema_change_event_response.rb +21 -6
- data/lib/cassandra/protocol/responses/schema_change_result_response.rb +18 -8
- data/lib/cassandra/protocol/responses/set_keyspace_result_response.rb +1 -1
- data/lib/cassandra/protocol/responses/status_change_event_response.rb +1 -1
- data/lib/cassandra/protocol/responses/supported_response.rb +1 -1
- data/lib/cassandra/protocol/responses/topology_change_event_response.rb +1 -1
- data/lib/cassandra/protocol/responses/unavailable_error_response.rb +1 -1
- data/lib/cassandra/protocol/responses/unprepared_error_response.rb +1 -1
- data/lib/cassandra/protocol/responses/void_result_response.rb +1 -1
- data/lib/cassandra/protocol/responses/write_timeout_error_response.rb +1 -1
- data/lib/cassandra/protocol/v1.rb +4 -2
- data/lib/cassandra/protocol/v3.rb +280 -0
- data/lib/cassandra/reconnection.rb +1 -1
- data/lib/cassandra/reconnection/policies.rb +1 -1
- data/lib/cassandra/reconnection/policies/constant.rb +1 -1
- data/lib/cassandra/reconnection/policies/exponential.rb +1 -1
- data/lib/cassandra/result.rb +1 -1
- data/lib/cassandra/retry.rb +1 -1
- data/lib/cassandra/retry/policies.rb +1 -1
- data/lib/cassandra/retry/policies/default.rb +1 -1
- data/lib/cassandra/retry/policies/downgrading_consistency.rb +1 -1
- data/lib/cassandra/retry/policies/fallthrough.rb +1 -1
- data/lib/cassandra/session.rb +14 -80
- data/lib/cassandra/statement.rb +1 -1
- data/lib/cassandra/statements.rb +1 -1
- data/lib/cassandra/statements/batch.rb +10 -25
- data/lib/cassandra/statements/bound.rb +1 -1
- data/lib/cassandra/statements/prepared.rb +24 -31
- data/lib/cassandra/statements/simple.rb +22 -66
- data/lib/cassandra/statements/void.rb +1 -1
- data/lib/cassandra/table.rb +36 -5
- data/lib/cassandra/time_uuid.rb +1 -1
- data/lib/cassandra/tuple.rb +124 -0
- data/lib/cassandra/types.rb +1406 -0
- data/lib/cassandra/udt.rb +420 -0
- data/lib/cassandra/util.rb +42 -64
- data/lib/cassandra/uuid.rb +1 -1
- data/lib/cassandra/uuid/generator.rb +1 -1
- data/lib/cassandra/version.rb +2 -2
- metadata +19 -15
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright 2013-
|
4
|
+
# Copyright 2013-2015 DataStax, Inc.
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
@@ -40,9 +40,23 @@ module Cassandra
|
|
40
40
|
@compressor = compressor
|
41
41
|
@connection.on_data(&method(:receive_data))
|
42
42
|
@connection.on_closed(&method(:socket_closed))
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
|
44
|
+
if protocol_version > 2
|
45
|
+
@streams = Array.new(1024) {|i| i}
|
46
|
+
else
|
47
|
+
@streams = Array.new(128) {|i| i}
|
48
|
+
end
|
49
|
+
|
50
|
+
@promises = Hash.new
|
51
|
+
|
52
|
+
if protocol_version > 2
|
53
|
+
@frame_encoder = V3::Encoder.new(@compressor, protocol_version)
|
54
|
+
@frame_decoder = V3::Decoder.new(self, @compressor)
|
55
|
+
else
|
56
|
+
@frame_encoder = V1::Encoder.new(@compressor, protocol_version)
|
57
|
+
@frame_decoder = V1::Decoder.new(self, @compressor)
|
58
|
+
end
|
59
|
+
|
46
60
|
@request_queue_in = []
|
47
61
|
@request_queue_out = []
|
48
62
|
@event_listeners = []
|
@@ -211,15 +225,15 @@ module Cassandra
|
|
211
225
|
promise = nil
|
212
226
|
@lock.lock
|
213
227
|
begin
|
214
|
-
promise = @promises
|
215
|
-
@
|
228
|
+
promise = @promises.delete(id)
|
229
|
+
@streams.unshift(id)
|
216
230
|
ensure
|
217
231
|
@lock.unlock
|
218
232
|
end
|
219
233
|
if response.is_a?(Protocol::SetKeyspaceResultResponse)
|
220
234
|
@keyspace = response.keyspace
|
221
235
|
end
|
222
|
-
if response.is_a?(Protocol::SchemaChangeResultResponse) && response.change == 'DROPPED' && response.keyspace == @keyspace && response.
|
236
|
+
if response.is_a?(Protocol::SchemaChangeResultResponse) && response.change == 'DROPPED' && response.keyspace == @keyspace && response.target == Protocol::Constants::SCHEMA_CHANGE_TARGET_KEYSPACE
|
223
237
|
@keyspace = nil
|
224
238
|
end
|
225
239
|
flush_request_queue
|
@@ -310,10 +324,10 @@ module Cassandra
|
|
310
324
|
@heartbeat = nil
|
311
325
|
@terminate = nil
|
312
326
|
|
313
|
-
promises_to_fail = @promises.
|
327
|
+
promises_to_fail = @promises.values
|
314
328
|
promises_to_fail.concat(@request_queue_in)
|
315
329
|
promises_to_fail.concat(@request_queue_out)
|
316
|
-
@promises.
|
330
|
+
@promises.clear
|
317
331
|
@request_queue_in.clear
|
318
332
|
@request_queue_out.clear
|
319
333
|
end
|
@@ -363,7 +377,7 @@ module Cassandra
|
|
363
377
|
end
|
364
378
|
|
365
379
|
def next_stream_id
|
366
|
-
if (stream_id = @
|
380
|
+
if (stream_id = @streams.shift)
|
367
381
|
stream_id
|
368
382
|
else
|
369
383
|
nil
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright 2013-
|
4
|
+
# Copyright 2013-2015 DataStax, Inc.
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
@@ -22,7 +22,7 @@ module Cassandra
|
|
22
22
|
attr_reader :cql, :values, :type_hints, :serial_consistency, :page_size, :paging_state
|
23
23
|
attr_accessor :consistency, :retries
|
24
24
|
|
25
|
-
def initialize(cql, values, type_hints, consistency, serial_consistency = nil, page_size = nil, paging_state = nil, trace = false)
|
25
|
+
def initialize(cql, values, type_hints, consistency, serial_consistency = nil, page_size = nil, paging_state = nil, trace = false, names = EMPTY_LIST)
|
26
26
|
super(7, trace)
|
27
27
|
@cql = cql
|
28
28
|
@values = values
|
@@ -31,6 +31,7 @@ module Cassandra
|
|
31
31
|
@serial_consistency = serial_consistency
|
32
32
|
@page_size = page_size
|
33
33
|
@paging_state = paging_state
|
34
|
+
@names = names
|
34
35
|
end
|
35
36
|
|
36
37
|
def write(buffer, protocol_version, encoder)
|
@@ -43,8 +44,9 @@ module Cassandra
|
|
43
44
|
flags |= 0x10 if @serial_consistency
|
44
45
|
if @values && @values.size > 0
|
45
46
|
flags |= 0x01
|
47
|
+
flags |= 0x40 unless @names.empty?
|
46
48
|
buffer.append(flags.chr)
|
47
|
-
encoder.write_parameters(buffer, @values, @type_hints)
|
49
|
+
encoder.write_parameters(buffer, @values, @type_hints, @names)
|
48
50
|
else
|
49
51
|
buffer.append(flags.chr)
|
50
52
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright 2013-
|
4
|
+
# Copyright 2013-2015 DataStax, Inc.
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
@@ -27,7 +27,14 @@ module Cassandra
|
|
27
27
|
|
28
28
|
def materialize(metadata)
|
29
29
|
@metadata = metadata
|
30
|
-
|
30
|
+
|
31
|
+
if @protocol_version == 3
|
32
|
+
@rows = Coder.read_values_v3(@raw_rows, @metadata)
|
33
|
+
else
|
34
|
+
@rows = Coder.read_values_v1(@raw_rows, @metadata)
|
35
|
+
end
|
36
|
+
|
37
|
+
@rows
|
31
38
|
end
|
32
39
|
|
33
40
|
def rows
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright 2013-
|
4
|
+
# Copyright 2013-2015 DataStax, Inc.
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
@@ -21,13 +21,28 @@ module Cassandra
|
|
21
21
|
class SchemaChangeEventResponse < EventResponse
|
22
22
|
TYPE = 'SCHEMA_CHANGE'.freeze
|
23
23
|
|
24
|
-
attr_reader :
|
24
|
+
attr_reader :change, :keyspace, :table, :type, :target
|
25
25
|
|
26
|
-
def initialize(
|
27
|
-
@change
|
28
|
-
@
|
26
|
+
def initialize(change, keyspace, name, target = nil)
|
27
|
+
@change = change
|
28
|
+
@keyspace = keyspace
|
29
|
+
|
30
|
+
if target
|
31
|
+
@target = target
|
32
|
+
@table = @type = name
|
33
|
+
else
|
34
|
+
if name.empty?
|
35
|
+
@target = Constants::SCHEMA_CHANGE_TARGET_KEYSPACE
|
36
|
+
else
|
37
|
+
@target = Constants::SCHEMA_CHANGE_TARGET_TABLE
|
38
|
+
@table = name
|
39
|
+
end
|
40
|
+
end
|
29
41
|
end
|
30
42
|
|
43
|
+
def type
|
44
|
+
TYPE
|
45
|
+
end
|
31
46
|
|
32
47
|
def eql?(rs)
|
33
48
|
rs.type == self.type && rs.change == self.change && rs.keyspace == self.keyspace && rs.table == self.table
|
@@ -46,7 +61,7 @@ module Cassandra
|
|
46
61
|
end
|
47
62
|
|
48
63
|
def to_s
|
49
|
-
%(EVENT
|
64
|
+
%(EVENT SCHEMA_CHANGE #@change #@target "#@keyspace" "#@table")
|
50
65
|
end
|
51
66
|
|
52
67
|
private
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright 2013-
|
4
|
+
# Copyright 2013-2015 DataStax, Inc.
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
@@ -19,15 +19,25 @@
|
|
19
19
|
module Cassandra
|
20
20
|
module Protocol
|
21
21
|
class SchemaChangeResultResponse < ResultResponse
|
22
|
-
attr_reader :change, :keyspace, :table
|
22
|
+
attr_reader :change, :keyspace, :table, :type, :target
|
23
23
|
|
24
|
-
def initialize(change, keyspace,
|
24
|
+
def initialize(change, keyspace, name, trace_id, target = nil)
|
25
25
|
super(trace_id)
|
26
|
-
@change, @keyspace, @table = change, keyspace, table
|
27
|
-
end
|
28
26
|
|
29
|
-
|
30
|
-
|
27
|
+
@change = change
|
28
|
+
@keyspace = keyspace
|
29
|
+
|
30
|
+
if target
|
31
|
+
@target = target
|
32
|
+
@table = @type = name
|
33
|
+
else
|
34
|
+
if name.empty?
|
35
|
+
@target = Constants::SCHEMA_CHANGE_TARGET_KEYSPACE
|
36
|
+
else
|
37
|
+
@target = Constants::SCHEMA_CHANGE_TARGET_TABLE
|
38
|
+
@table = name
|
39
|
+
end
|
40
|
+
end
|
31
41
|
end
|
32
42
|
|
33
43
|
def eql?(other)
|
@@ -46,7 +56,7 @@ module Cassandra
|
|
46
56
|
end
|
47
57
|
|
48
58
|
def to_s
|
49
|
-
%(RESULT SCHEMA_CHANGE #@change "#@keyspace" "#@table")
|
59
|
+
%(RESULT SCHEMA_CHANGE #@change #@target "#@keyspace" "#@table")
|
50
60
|
end
|
51
61
|
|
52
62
|
private
|