cassandra-driver 3.0.0.beta.1 → 3.0.0.rc.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 +90 -38
- data/ext/cassandra_murmur3/cassandra_murmur3.c +1 -1
- data/lib/cassandra.rb +327 -130
- 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/aggregate.rb +21 -7
- data/lib/cassandra/argument.rb +2 -2
- data/lib/cassandra/auth.rb +4 -4
- data/lib/cassandra/auth/providers.rb +1 -1
- data/lib/cassandra/auth/providers/password.rb +9 -5
- data/lib/cassandra/cassandra_logger.rb +80 -0
- data/lib/cassandra/cluster.rb +38 -9
- data/lib/cassandra/cluster/client.rb +801 -205
- data/lib/cassandra/cluster/connection_pool.rb +2 -2
- data/lib/cassandra/cluster/connector.rb +74 -25
- data/lib/cassandra/cluster/control_connection.rb +217 -82
- data/lib/cassandra/cluster/failed_connection.rb +1 -1
- data/lib/cassandra/cluster/metadata.rb +12 -4
- data/lib/cassandra/cluster/options.rb +60 -11
- data/lib/cassandra/cluster/registry.rb +69 -16
- data/lib/cassandra/cluster/schema.rb +25 -7
- data/lib/cassandra/cluster/schema/cql_type_parser.rb +15 -10
- data/lib/cassandra/cluster/schema/fetchers.rb +263 -106
- data/lib/cassandra/cluster/schema/fqcn_type_parser.rb +41 -36
- data/lib/cassandra/cluster/schema/partitioners.rb +1 -1
- data/lib/cassandra/cluster/schema/partitioners/murmur3.rb +3 -3
- 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 +19 -18
- 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/column.rb +3 -3
- data/lib/cassandra/compression.rb +1 -1
- data/lib/cassandra/compression/compressors/lz4.rb +4 -3
- data/lib/cassandra/compression/compressors/snappy.rb +4 -3
- data/lib/cassandra/driver.rb +103 -41
- data/lib/cassandra/errors.rb +265 -30
- data/lib/cassandra/execution/info.rb +16 -5
- data/lib/cassandra/execution/options.rb +99 -54
- data/lib/cassandra/execution/trace.rb +16 -9
- data/lib/cassandra/executors.rb +1 -1
- data/lib/cassandra/function.rb +19 -13
- data/lib/cassandra/function_collection.rb +85 -0
- data/lib/cassandra/future.rb +106 -48
- data/lib/cassandra/host.rb +10 -4
- data/lib/cassandra/keyspace.rb +90 -33
- data/lib/cassandra/listener.rb +1 -1
- data/lib/cassandra/load_balancing.rb +2 -2
- data/lib/cassandra/load_balancing/policies.rb +1 -1
- data/lib/cassandra/load_balancing/policies/dc_aware_round_robin.rb +18 -18
- data/lib/cassandra/load_balancing/policies/round_robin.rb +1 -1
- data/lib/cassandra/load_balancing/policies/token_aware.rb +15 -13
- data/lib/cassandra/load_balancing/policies/white_list.rb +11 -5
- data/lib/cassandra/null_logger.rb +27 -6
- data/lib/cassandra/protocol.rb +1 -1
- data/lib/cassandra/protocol/coder.rb +78 -39
- data/lib/cassandra/protocol/cql_byte_buffer.rb +50 -33
- data/lib/cassandra/protocol/cql_protocol_handler.rb +44 -45
- data/lib/cassandra/protocol/request.rb +2 -2
- data/lib/cassandra/protocol/requests/auth_response_request.rb +3 -3
- data/lib/cassandra/protocol/requests/batch_request.rb +16 -7
- data/lib/cassandra/protocol/requests/credentials_request.rb +3 -3
- data/lib/cassandra/protocol/requests/execute_request.rb +41 -20
- data/lib/cassandra/protocol/requests/options_request.rb +1 -1
- data/lib/cassandra/protocol/requests/prepare_request.rb +5 -5
- data/lib/cassandra/protocol/requests/query_request.rb +27 -22
- data/lib/cassandra/protocol/requests/register_request.rb +2 -2
- data/lib/cassandra/protocol/requests/startup_request.rb +6 -4
- data/lib/cassandra/protocol/requests/void_query_request.rb +1 -1
- data/lib/cassandra/protocol/response.rb +2 -2
- data/lib/cassandra/protocol/responses/already_exists_error_response.rb +12 -2
- 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 +101 -13
- data/lib/cassandra/protocol/responses/event_response.rb +1 -1
- data/lib/cassandra/protocol/responses/function_failure_error_response.rb +13 -2
- data/lib/cassandra/protocol/responses/prepared_result_response.rb +11 -5
- data/lib/cassandra/protocol/responses/raw_rows_result_response.rb +14 -9
- data/lib/cassandra/protocol/responses/read_failure_error_response.rb +26 -4
- data/lib/cassandra/protocol/responses/read_timeout_error_response.rb +22 -3
- data/lib/cassandra/protocol/responses/ready_response.rb +3 -3
- data/lib/cassandra/protocol/responses/result_response.rb +4 -2
- data/lib/cassandra/protocol/responses/rows_result_response.rb +5 -3
- data/lib/cassandra/protocol/responses/schema_change_event_response.rb +5 -4
- data/lib/cassandra/protocol/responses/schema_change_result_response.rb +16 -9
- data/lib/cassandra/protocol/responses/set_keyspace_result_response.rb +2 -2
- data/lib/cassandra/protocol/responses/status_change_event_response.rb +2 -2
- 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 +20 -3
- data/lib/cassandra/protocol/responses/unprepared_error_response.rb +11 -2
- data/lib/cassandra/protocol/responses/void_result_response.rb +1 -1
- data/lib/cassandra/protocol/responses/write_failure_error_response.rb +26 -4
- data/lib/cassandra/protocol/responses/write_timeout_error_response.rb +22 -3
- data/lib/cassandra/protocol/v1.rb +101 -36
- data/lib/cassandra/protocol/v3.rb +124 -51
- data/lib/cassandra/protocol/v4.rb +172 -68
- data/lib/cassandra/reconnection.rb +1 -1
- data/lib/cassandra/reconnection/policies.rb +1 -1
- data/lib/cassandra/reconnection/policies/constant.rb +2 -4
- data/lib/cassandra/reconnection/policies/exponential.rb +6 -6
- data/lib/cassandra/result.rb +53 -19
- data/lib/cassandra/retry.rb +8 -8
- 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 +7 -3
- data/lib/cassandra/retry/policies/fallthrough.rb +1 -1
- data/lib/cassandra/session.rb +22 -16
- data/lib/cassandra/statement.rb +1 -1
- data/lib/cassandra/statements.rb +1 -1
- data/lib/cassandra/statements/batch.rb +16 -10
- data/lib/cassandra/statements/bound.rb +10 -3
- data/lib/cassandra/statements/prepared.rb +59 -15
- data/lib/cassandra/statements/simple.rb +23 -10
- data/lib/cassandra/statements/void.rb +1 -1
- data/lib/cassandra/table.rb +79 -30
- data/lib/cassandra/time.rb +11 -6
- data/lib/cassandra/time_uuid.rb +7 -7
- data/lib/cassandra/tuple.rb +16 -8
- data/lib/cassandra/types.rb +20 -9
- data/lib/cassandra/udt.rb +32 -36
- data/lib/cassandra/util.rb +20 -13
- data/lib/cassandra/uuid.rb +22 -15
- data/lib/cassandra/uuid/generator.rb +7 -5
- data/lib/cassandra/version.rb +2 -2
- data/lib/datastax/cassandra.rb +1 -1
- metadata +5 -3
data/lib/cassandra/listener.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright 2013-
|
4
|
+
# Copyright 2013-2016 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.
|
@@ -83,7 +83,7 @@ module Cassandra
|
|
83
83
|
|
84
84
|
# @private
|
85
85
|
def inspect
|
86
|
-
"#<#{self.class.name}:0x#{
|
86
|
+
"#<#{self.class.name}:0x#{object_id.to_s(16)}>"
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright 2013-
|
4
|
+
# Copyright 2013-2016 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.
|
@@ -56,16 +56,20 @@ module Cassandra
|
|
56
56
|
|
57
57
|
include MonitorMixin
|
58
58
|
|
59
|
-
def initialize(datacenter = nil,
|
60
|
-
|
61
|
-
|
59
|
+
def initialize(datacenter = nil,
|
60
|
+
max_remote_hosts_to_use = nil,
|
61
|
+
use_remote_hosts_for_local_consistency = false)
|
62
|
+
datacenter &&= String(datacenter)
|
63
|
+
max_remote_hosts_to_use &&= Integer(max_remote_hosts_to_use)
|
62
64
|
|
63
65
|
unless datacenter.nil?
|
64
|
-
Util.assert_not_empty(datacenter) {
|
66
|
+
Util.assert_not_empty(datacenter) { 'datacenter cannot be empty' }
|
65
67
|
end
|
66
68
|
|
67
69
|
unless max_remote_hosts_to_use.nil?
|
68
|
-
Util.assert(max_remote_hosts_to_use >= 0)
|
70
|
+
Util.assert(max_remote_hosts_to_use >= 0) do
|
71
|
+
'max_remote_hosts_to_use must be nil or >= 0'
|
72
|
+
end
|
69
73
|
end
|
70
74
|
|
71
75
|
@datacenter = datacenter
|
@@ -80,16 +84,12 @@ module Cassandra
|
|
80
84
|
end
|
81
85
|
|
82
86
|
def host_up(host)
|
83
|
-
if !@datacenter && host.datacenter
|
84
|
-
@datacenter = host.datacenter
|
85
|
-
end
|
87
|
+
@datacenter = host.datacenter if !@datacenter && host.datacenter
|
86
88
|
|
87
89
|
if host.datacenter.nil? || host.datacenter == @datacenter
|
88
90
|
synchronize { @local = @local.dup.push(host) }
|
89
|
-
|
90
|
-
|
91
|
-
synchronize { @remote = @remote.dup.push(host) }
|
92
|
-
end
|
91
|
+
elsif @max_remote.nil? || @remote.size < @max_remote
|
92
|
+
synchronize { @remote = @remote.dup.push(host) }
|
93
93
|
end
|
94
94
|
|
95
95
|
self
|
@@ -130,11 +130,11 @@ module Cassandra
|
|
130
130
|
def plan(keyspace, statement, options)
|
131
131
|
local = @local
|
132
132
|
|
133
|
-
if LOCAL_CONSISTENCIES.include?(options.consistency) && !@use_remote
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
133
|
+
remote = if LOCAL_CONSISTENCIES.include?(options.consistency) && !@use_remote
|
134
|
+
EMPTY_ARRAY
|
135
|
+
else
|
136
|
+
@remote
|
137
|
+
end
|
138
138
|
|
139
139
|
total = local.size + remote.size
|
140
140
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright 2013-
|
4
|
+
# Copyright 2013-2016 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.
|
@@ -35,11 +35,10 @@ module Cassandra
|
|
35
35
|
until @hosts.empty?
|
36
36
|
host = @hosts.shift
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
38
|
+
next unless @policy.distance(host) == :local
|
39
|
+
@seen[host] = true
|
40
|
+
@next = host
|
41
|
+
break
|
43
42
|
end
|
44
43
|
|
45
44
|
return true if @next
|
@@ -100,9 +99,12 @@ module Cassandra
|
|
100
99
|
# under-utilizes read caching and forces multiple replicas to cache
|
101
100
|
# the same read statements.
|
102
101
|
def initialize(wrapped_policy, shuffle = true)
|
103
|
-
methods = [:host_up, :host_down, :host_found, :host_lost, :setup, :teardown,
|
102
|
+
methods = [:host_up, :host_down, :host_found, :host_lost, :setup, :teardown,
|
103
|
+
:distance, :plan]
|
104
104
|
|
105
|
-
Util.assert_responds_to_all(methods, wrapped_policy)
|
105
|
+
Util.assert_responds_to_all(methods, wrapped_policy) do
|
106
|
+
"supplied policy must respond to #{methods.inspect}, but doesn't"
|
107
|
+
end
|
106
108
|
|
107
109
|
@policy = wrapped_policy
|
108
110
|
@shuffle = !!shuffle
|
@@ -126,11 +128,11 @@ module Cassandra
|
|
126
128
|
replicas = @cluster.find_replicas(keyspace, statement)
|
127
129
|
return @policy.plan(keyspace, statement, options) if replicas.empty?
|
128
130
|
|
129
|
-
if @shuffle
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
131
|
+
replicas = if @shuffle
|
132
|
+
replicas.shuffle
|
133
|
+
else
|
134
|
+
replicas.dup
|
135
|
+
end
|
134
136
|
|
135
137
|
Plan.new(replicas, @policy, keyspace, statement, options)
|
136
138
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright 2013-
|
4
|
+
# Copyright 2013-2016 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.
|
@@ -35,9 +35,14 @@ module Cassandra
|
|
35
35
|
# @param wrapped_policy [Cassandra::LoadBalancing::Policy] actual policy to filter
|
36
36
|
# @raise [ArgumentError] if arguments are of unexpected types
|
37
37
|
def initialize(ips, wrapped_policy)
|
38
|
-
Util.assert_instance_of(::Enumerable, ips)
|
39
|
-
|
40
|
-
|
38
|
+
Util.assert_instance_of(::Enumerable, ips) do
|
39
|
+
"ips must be an Enumerable, #{ips.inspect} given"
|
40
|
+
end
|
41
|
+
methods = [:host_up, :host_down, :host_found, :host_lost, :setup, :teardown,
|
42
|
+
:distance, :plan]
|
43
|
+
Util.assert_responds_to_all(methods, wrapped_policy) do
|
44
|
+
"supplied policy must respond to #{methods.inspect}, but doesn't"
|
45
|
+
end
|
41
46
|
|
42
47
|
@ips = ::Set.new
|
43
48
|
@policy = wrapped_policy
|
@@ -49,7 +54,8 @@ module Cassandra
|
|
49
54
|
when ::String
|
50
55
|
@ips << ::IPAddr.new(ip)
|
51
56
|
else
|
52
|
-
raise ::ArgumentError,
|
57
|
+
raise ::ArgumentError, 'each ip must be a String or IPAddr, ' \
|
58
|
+
"#{ip.inspect} given"
|
53
59
|
end
|
54
60
|
end
|
55
61
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright 2013-
|
4
|
+
# Copyright 2013-2016 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.
|
@@ -20,16 +20,37 @@ module Cassandra
|
|
20
20
|
# @private
|
21
21
|
class NullLogger
|
22
22
|
def close(*); end
|
23
|
+
|
23
24
|
def debug(*); end
|
24
|
-
|
25
|
+
|
26
|
+
def debug?
|
27
|
+
false
|
28
|
+
end
|
29
|
+
|
25
30
|
def error(*); end
|
26
|
-
|
31
|
+
|
32
|
+
def error?
|
33
|
+
false
|
34
|
+
end
|
35
|
+
|
27
36
|
def fatal(*); end
|
28
|
-
|
37
|
+
|
38
|
+
def fatal?
|
39
|
+
false
|
40
|
+
end
|
41
|
+
|
29
42
|
def info(*); end
|
30
|
-
|
43
|
+
|
44
|
+
def info?
|
45
|
+
false
|
46
|
+
end
|
47
|
+
|
31
48
|
def unknown(*); end
|
49
|
+
|
32
50
|
def warn(*); end
|
33
|
-
|
51
|
+
|
52
|
+
def warn?
|
53
|
+
false
|
54
|
+
end
|
34
55
|
end
|
35
56
|
end
|
data/lib/cassandra/protocol.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright 2013-
|
4
|
+
# Copyright 2013-2016 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.
|
@@ -18,7 +18,9 @@
|
|
18
18
|
|
19
19
|
module Cassandra
|
20
20
|
module Protocol
|
21
|
-
module Coder
|
21
|
+
module Coder
|
22
|
+
module_function
|
23
|
+
|
22
24
|
GLOBAL_TABLES_SPEC_FLAG = 0x01
|
23
25
|
HAS_MORE_PAGES_FLAG = 0x02
|
24
26
|
NO_METADATA_FLAG = 0x04
|
@@ -109,7 +111,9 @@ module Cassandra
|
|
109
111
|
when :time then write_time(buffer, value)
|
110
112
|
when :date then write_date(buffer, value)
|
111
113
|
when :list, :set then write_list_v4(buffer, value, type.value_type)
|
112
|
-
when :map then write_map_v4(buffer, value,
|
114
|
+
when :map then write_map_v4(buffer, value,
|
115
|
+
type.key_type,
|
116
|
+
type.value_type)
|
113
117
|
when :udt then write_udt_v4(buffer, value, type.fields)
|
114
118
|
when :tuple then write_tuple_v4(buffer, value, type.members)
|
115
119
|
else
|
@@ -121,18 +125,23 @@ module Cassandra
|
|
121
125
|
flags = buffer.read_int
|
122
126
|
columns_count = buffer.read_int
|
123
127
|
pk_count = buffer.read_int
|
124
|
-
pk_specs = ::Array.new(pk_count) {|
|
128
|
+
pk_specs = ::Array.new(pk_count) {|_i| buffer.read_short}
|
125
129
|
|
126
130
|
if flags & GLOBAL_TABLES_SPEC_FLAG == GLOBAL_TABLES_SPEC_FLAG
|
127
131
|
keyspace_name = buffer.read_string
|
128
132
|
table_name = buffer.read_string
|
129
133
|
|
130
|
-
column_specs = ::Array.new(columns_count) do |
|
134
|
+
column_specs = ::Array.new(columns_count) do |_i|
|
131
135
|
[keyspace_name, table_name, buffer.read_string, read_type_v4(buffer)]
|
132
136
|
end
|
133
137
|
else
|
134
|
-
column_specs = ::Array.new(columns_count) do |
|
135
|
-
[
|
138
|
+
column_specs = ::Array.new(columns_count) do |_i|
|
139
|
+
[
|
140
|
+
buffer.read_string,
|
141
|
+
buffer.read_string,
|
142
|
+
buffer.read_string,
|
143
|
+
read_type_v4(buffer)
|
144
|
+
]
|
136
145
|
end
|
137
146
|
end
|
138
147
|
|
@@ -152,12 +161,17 @@ module Cassandra
|
|
152
161
|
keyspace_name = buffer.read_string
|
153
162
|
table_name = buffer.read_string
|
154
163
|
|
155
|
-
column_specs = ::Array.new(count) do |
|
164
|
+
column_specs = ::Array.new(count) do |_i|
|
156
165
|
[keyspace_name, table_name, buffer.read_string, read_type_v4(buffer)]
|
157
166
|
end
|
158
167
|
else
|
159
|
-
column_specs = ::Array.new(count) do |
|
160
|
-
[
|
168
|
+
column_specs = ::Array.new(count) do |_i|
|
169
|
+
[
|
170
|
+
buffer.read_string,
|
171
|
+
buffer.read_string,
|
172
|
+
buffer.read_string,
|
173
|
+
read_type_v4(buffer)
|
174
|
+
]
|
161
175
|
end
|
162
176
|
end
|
163
177
|
end
|
@@ -194,17 +208,21 @@ module Cassandra
|
|
194
208
|
when 0x0030
|
195
209
|
keyspace = buffer.read_string
|
196
210
|
name = buffer.read_string
|
197
|
-
fields = ::Array.new(buffer.read_short)
|
211
|
+
fields = ::Array.new(buffer.read_short) do
|
212
|
+
[buffer.read_string, read_type_v4(buffer)]
|
213
|
+
end
|
198
214
|
|
199
215
|
Types.udt(keyspace, name, fields)
|
200
|
-
when 0x0031 then Types.tuple(
|
216
|
+
when 0x0031 then Types.tuple(
|
217
|
+
*::Array.new(buffer.read_short) { read_type_v4(buffer) }
|
218
|
+
)
|
201
219
|
else
|
202
220
|
raise Errors::DecodingError, %(Unsupported column type: #{id})
|
203
221
|
end
|
204
222
|
end
|
205
223
|
|
206
224
|
def read_values_v4(buffer, column_metadata)
|
207
|
-
::Array.new(buffer.read_int) do |
|
225
|
+
::Array.new(buffer.read_int) do |_i|
|
208
226
|
row = ::Hash.new
|
209
227
|
|
210
228
|
column_metadata.each do |(_, _, column, type)|
|
@@ -274,11 +292,11 @@ module Cassandra
|
|
274
292
|
values = ::Hash.new
|
275
293
|
|
276
294
|
fields.each do |field|
|
277
|
-
if length - buffer.length >= size
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
295
|
+
values[field.name] = if length - buffer.length >= size
|
296
|
+
nil
|
297
|
+
else
|
298
|
+
read_value_v4(buffer, field.type)
|
299
|
+
end
|
282
300
|
end
|
283
301
|
|
284
302
|
Cassandra::UDT::Strict.new(keyspace, name, fields, values)
|
@@ -378,7 +396,10 @@ module Cassandra
|
|
378
396
|
when :text then write_text(buffer, value)
|
379
397
|
when :varint then write_varint(buffer, value)
|
380
398
|
when :list, :set then write_list_v3(buffer, value, type.value_type)
|
381
|
-
when :map then write_map_v3(buffer,
|
399
|
+
when :map then write_map_v3(buffer,
|
400
|
+
value,
|
401
|
+
type.key_type,
|
402
|
+
type.value_type)
|
382
403
|
when :udt then write_udt_v3(buffer, value, type.fields)
|
383
404
|
when :tuple then write_tuple_v3(buffer, value, type.members)
|
384
405
|
else
|
@@ -387,7 +408,7 @@ module Cassandra
|
|
387
408
|
end
|
388
409
|
|
389
410
|
def read_values_v3(buffer, column_metadata)
|
390
|
-
::Array.new(buffer.read_int) do |
|
411
|
+
::Array.new(buffer.read_int) do |_i|
|
391
412
|
row = ::Hash.new
|
392
413
|
|
393
414
|
column_metadata.each do |(_, _, column, type)|
|
@@ -453,11 +474,11 @@ module Cassandra
|
|
453
474
|
values = ::Hash.new
|
454
475
|
|
455
476
|
fields.each do |field|
|
456
|
-
if length - buffer.length >= size
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
477
|
+
values[field.name] = if length - buffer.length >= size
|
478
|
+
nil
|
479
|
+
else
|
480
|
+
read_value_v3(buffer, field.type)
|
481
|
+
end
|
461
482
|
end
|
462
483
|
|
463
484
|
Cassandra::UDT::Strict.new(keyspace, name, fields, values)
|
@@ -493,12 +514,17 @@ module Cassandra
|
|
493
514
|
keyspace_name = buffer.read_string
|
494
515
|
table_name = buffer.read_string
|
495
516
|
|
496
|
-
column_specs = ::Array.new(count) do |
|
517
|
+
column_specs = ::Array.new(count) do |_i|
|
497
518
|
[keyspace_name, table_name, buffer.read_string, read_type_v3(buffer)]
|
498
519
|
end
|
499
520
|
else
|
500
|
-
column_specs = ::Array.new(count) do |
|
501
|
-
[
|
521
|
+
column_specs = ::Array.new(count) do |_i|
|
522
|
+
[
|
523
|
+
buffer.read_string,
|
524
|
+
buffer.read_string,
|
525
|
+
buffer.read_string,
|
526
|
+
read_type_v3(buffer)
|
527
|
+
]
|
502
528
|
end
|
503
529
|
end
|
504
530
|
end
|
@@ -531,10 +557,14 @@ module Cassandra
|
|
531
557
|
when 0x0030
|
532
558
|
keyspace = buffer.read_string
|
533
559
|
name = buffer.read_string
|
534
|
-
fields = ::Array.new(buffer.read_short)
|
560
|
+
fields = ::Array.new(buffer.read_short) do
|
561
|
+
[buffer.read_string, read_type_v3(buffer)]
|
562
|
+
end
|
535
563
|
|
536
564
|
Types.udt(keyspace, name, fields)
|
537
|
-
when 0x0031 then Types.tuple(
|
565
|
+
when 0x0031 then Types.tuple(
|
566
|
+
*::Array.new(buffer.read_short) { read_type_v3(buffer) }
|
567
|
+
)
|
538
568
|
else
|
539
569
|
raise Errors::DecodingError, %(Unsupported column type: #{id})
|
540
570
|
end
|
@@ -596,14 +626,17 @@ module Cassandra
|
|
596
626
|
when :timeuuid, :uuid then write_uuid(buffer, value)
|
597
627
|
when :varint then write_varint(buffer, value)
|
598
628
|
when :list, :set then write_list_v1(buffer, value, type.value_type)
|
599
|
-
when :map then write_map_v1(buffer,
|
629
|
+
when :map then write_map_v1(buffer,
|
630
|
+
value,
|
631
|
+
type.key_type,
|
632
|
+
type.value_type)
|
600
633
|
else
|
601
634
|
raise Errors::EncodingError, %(Unsupported value type: #{type})
|
602
635
|
end
|
603
636
|
end
|
604
637
|
|
605
638
|
def read_values_v1(buffer, column_metadata)
|
606
|
-
::Array.new(buffer.read_int) do |
|
639
|
+
::Array.new(buffer.read_int) do |_i|
|
607
640
|
row = ::Hash.new
|
608
641
|
|
609
642
|
column_metadata.each do |(_, _, column, type)|
|
@@ -644,7 +677,8 @@ module Cassandra
|
|
644
677
|
value = ::Hash.new
|
645
678
|
|
646
679
|
buffer.read_short.times do
|
647
|
-
value[read_short_value(buffer, key_type)] =
|
680
|
+
value[read_short_value(buffer, key_type)] =
|
681
|
+
read_short_value(buffer, value_type)
|
648
682
|
end
|
649
683
|
|
650
684
|
value
|
@@ -678,12 +712,17 @@ module Cassandra
|
|
678
712
|
keyspace_name = buffer.read_string
|
679
713
|
table_name = buffer.read_string
|
680
714
|
|
681
|
-
column_specs = ::Array.new(count) do |
|
715
|
+
column_specs = ::Array.new(count) do |_i|
|
682
716
|
[keyspace_name, table_name, buffer.read_string, read_type_v1(buffer)]
|
683
717
|
end
|
684
718
|
else
|
685
|
-
column_specs = ::Array.new(count) do |
|
686
|
-
[
|
719
|
+
column_specs = ::Array.new(count) do |_i|
|
720
|
+
[
|
721
|
+
buffer.read_string,
|
722
|
+
buffer.read_string,
|
723
|
+
buffer.read_string,
|
724
|
+
read_type_v1(buffer)
|
725
|
+
]
|
687
726
|
end
|
688
727
|
end
|
689
728
|
end
|
@@ -721,7 +760,7 @@ module Cassandra
|
|
721
760
|
end
|
722
761
|
|
723
762
|
def read_ascii(buffer)
|
724
|
-
value
|
763
|
+
value = buffer.read_bytes
|
725
764
|
value && value.force_encoding(::Encoding::ASCII)
|
726
765
|
end
|
727
766
|
|
@@ -729,7 +768,7 @@ module Cassandra
|
|
729
768
|
read_size(buffer) && buffer.read_long
|
730
769
|
end
|
731
770
|
|
732
|
-
alias
|
771
|
+
alias read_counter read_bigint
|
733
772
|
|
734
773
|
def read_boolean(buffer)
|
735
774
|
read_size(buffer) && buffer.read(1) == Constants::TRUE_BYTE
|
@@ -810,7 +849,7 @@ module Cassandra
|
|
810
849
|
buffer.append_long(value)
|
811
850
|
end
|
812
851
|
|
813
|
-
alias
|
852
|
+
alias write_counter write_bigint
|
814
853
|
|
815
854
|
def write_blob(buffer, value)
|
816
855
|
buffer.append_bytes(value.encode(::Encoding::BINARY))
|