cassandra-driver 3.0.0.beta.1 → 3.0.0.rc.1

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.
Files changed (131) hide show
  1. checksums.yaml +8 -8
  2. data/README.md +90 -38
  3. data/ext/cassandra_murmur3/cassandra_murmur3.c +1 -1
  4. data/lib/cassandra.rb +327 -130
  5. data/lib/cassandra/address_resolution.rb +1 -1
  6. data/lib/cassandra/address_resolution/policies/ec2_multi_region.rb +1 -1
  7. data/lib/cassandra/address_resolution/policies/none.rb +1 -1
  8. data/lib/cassandra/aggregate.rb +21 -7
  9. data/lib/cassandra/argument.rb +2 -2
  10. data/lib/cassandra/auth.rb +4 -4
  11. data/lib/cassandra/auth/providers.rb +1 -1
  12. data/lib/cassandra/auth/providers/password.rb +9 -5
  13. data/lib/cassandra/cassandra_logger.rb +80 -0
  14. data/lib/cassandra/cluster.rb +38 -9
  15. data/lib/cassandra/cluster/client.rb +801 -205
  16. data/lib/cassandra/cluster/connection_pool.rb +2 -2
  17. data/lib/cassandra/cluster/connector.rb +74 -25
  18. data/lib/cassandra/cluster/control_connection.rb +217 -82
  19. data/lib/cassandra/cluster/failed_connection.rb +1 -1
  20. data/lib/cassandra/cluster/metadata.rb +12 -4
  21. data/lib/cassandra/cluster/options.rb +60 -11
  22. data/lib/cassandra/cluster/registry.rb +69 -16
  23. data/lib/cassandra/cluster/schema.rb +25 -7
  24. data/lib/cassandra/cluster/schema/cql_type_parser.rb +15 -10
  25. data/lib/cassandra/cluster/schema/fetchers.rb +263 -106
  26. data/lib/cassandra/cluster/schema/fqcn_type_parser.rb +41 -36
  27. data/lib/cassandra/cluster/schema/partitioners.rb +1 -1
  28. data/lib/cassandra/cluster/schema/partitioners/murmur3.rb +3 -3
  29. data/lib/cassandra/cluster/schema/partitioners/ordered.rb +1 -1
  30. data/lib/cassandra/cluster/schema/partitioners/random.rb +1 -1
  31. data/lib/cassandra/cluster/schema/replication_strategies.rb +1 -1
  32. data/lib/cassandra/cluster/schema/replication_strategies/network_topology.rb +19 -18
  33. data/lib/cassandra/cluster/schema/replication_strategies/none.rb +1 -1
  34. data/lib/cassandra/cluster/schema/replication_strategies/simple.rb +1 -1
  35. data/lib/cassandra/column.rb +3 -3
  36. data/lib/cassandra/compression.rb +1 -1
  37. data/lib/cassandra/compression/compressors/lz4.rb +4 -3
  38. data/lib/cassandra/compression/compressors/snappy.rb +4 -3
  39. data/lib/cassandra/driver.rb +103 -41
  40. data/lib/cassandra/errors.rb +265 -30
  41. data/lib/cassandra/execution/info.rb +16 -5
  42. data/lib/cassandra/execution/options.rb +99 -54
  43. data/lib/cassandra/execution/trace.rb +16 -9
  44. data/lib/cassandra/executors.rb +1 -1
  45. data/lib/cassandra/function.rb +19 -13
  46. data/lib/cassandra/function_collection.rb +85 -0
  47. data/lib/cassandra/future.rb +106 -48
  48. data/lib/cassandra/host.rb +10 -4
  49. data/lib/cassandra/keyspace.rb +90 -33
  50. data/lib/cassandra/listener.rb +1 -1
  51. data/lib/cassandra/load_balancing.rb +2 -2
  52. data/lib/cassandra/load_balancing/policies.rb +1 -1
  53. data/lib/cassandra/load_balancing/policies/dc_aware_round_robin.rb +18 -18
  54. data/lib/cassandra/load_balancing/policies/round_robin.rb +1 -1
  55. data/lib/cassandra/load_balancing/policies/token_aware.rb +15 -13
  56. data/lib/cassandra/load_balancing/policies/white_list.rb +11 -5
  57. data/lib/cassandra/null_logger.rb +27 -6
  58. data/lib/cassandra/protocol.rb +1 -1
  59. data/lib/cassandra/protocol/coder.rb +78 -39
  60. data/lib/cassandra/protocol/cql_byte_buffer.rb +50 -33
  61. data/lib/cassandra/protocol/cql_protocol_handler.rb +44 -45
  62. data/lib/cassandra/protocol/request.rb +2 -2
  63. data/lib/cassandra/protocol/requests/auth_response_request.rb +3 -3
  64. data/lib/cassandra/protocol/requests/batch_request.rb +16 -7
  65. data/lib/cassandra/protocol/requests/credentials_request.rb +3 -3
  66. data/lib/cassandra/protocol/requests/execute_request.rb +41 -20
  67. data/lib/cassandra/protocol/requests/options_request.rb +1 -1
  68. data/lib/cassandra/protocol/requests/prepare_request.rb +5 -5
  69. data/lib/cassandra/protocol/requests/query_request.rb +27 -22
  70. data/lib/cassandra/protocol/requests/register_request.rb +2 -2
  71. data/lib/cassandra/protocol/requests/startup_request.rb +6 -4
  72. data/lib/cassandra/protocol/requests/void_query_request.rb +1 -1
  73. data/lib/cassandra/protocol/response.rb +2 -2
  74. data/lib/cassandra/protocol/responses/already_exists_error_response.rb +12 -2
  75. data/lib/cassandra/protocol/responses/auth_challenge_response.rb +1 -1
  76. data/lib/cassandra/protocol/responses/auth_success_response.rb +1 -1
  77. data/lib/cassandra/protocol/responses/authenticate_response.rb +1 -1
  78. data/lib/cassandra/protocol/responses/error_response.rb +101 -13
  79. data/lib/cassandra/protocol/responses/event_response.rb +1 -1
  80. data/lib/cassandra/protocol/responses/function_failure_error_response.rb +13 -2
  81. data/lib/cassandra/protocol/responses/prepared_result_response.rb +11 -5
  82. data/lib/cassandra/protocol/responses/raw_rows_result_response.rb +14 -9
  83. data/lib/cassandra/protocol/responses/read_failure_error_response.rb +26 -4
  84. data/lib/cassandra/protocol/responses/read_timeout_error_response.rb +22 -3
  85. data/lib/cassandra/protocol/responses/ready_response.rb +3 -3
  86. data/lib/cassandra/protocol/responses/result_response.rb +4 -2
  87. data/lib/cassandra/protocol/responses/rows_result_response.rb +5 -3
  88. data/lib/cassandra/protocol/responses/schema_change_event_response.rb +5 -4
  89. data/lib/cassandra/protocol/responses/schema_change_result_response.rb +16 -9
  90. data/lib/cassandra/protocol/responses/set_keyspace_result_response.rb +2 -2
  91. data/lib/cassandra/protocol/responses/status_change_event_response.rb +2 -2
  92. data/lib/cassandra/protocol/responses/supported_response.rb +1 -1
  93. data/lib/cassandra/protocol/responses/topology_change_event_response.rb +1 -1
  94. data/lib/cassandra/protocol/responses/unavailable_error_response.rb +20 -3
  95. data/lib/cassandra/protocol/responses/unprepared_error_response.rb +11 -2
  96. data/lib/cassandra/protocol/responses/void_result_response.rb +1 -1
  97. data/lib/cassandra/protocol/responses/write_failure_error_response.rb +26 -4
  98. data/lib/cassandra/protocol/responses/write_timeout_error_response.rb +22 -3
  99. data/lib/cassandra/protocol/v1.rb +101 -36
  100. data/lib/cassandra/protocol/v3.rb +124 -51
  101. data/lib/cassandra/protocol/v4.rb +172 -68
  102. data/lib/cassandra/reconnection.rb +1 -1
  103. data/lib/cassandra/reconnection/policies.rb +1 -1
  104. data/lib/cassandra/reconnection/policies/constant.rb +2 -4
  105. data/lib/cassandra/reconnection/policies/exponential.rb +6 -6
  106. data/lib/cassandra/result.rb +53 -19
  107. data/lib/cassandra/retry.rb +8 -8
  108. data/lib/cassandra/retry/policies.rb +1 -1
  109. data/lib/cassandra/retry/policies/default.rb +1 -1
  110. data/lib/cassandra/retry/policies/downgrading_consistency.rb +7 -3
  111. data/lib/cassandra/retry/policies/fallthrough.rb +1 -1
  112. data/lib/cassandra/session.rb +22 -16
  113. data/lib/cassandra/statement.rb +1 -1
  114. data/lib/cassandra/statements.rb +1 -1
  115. data/lib/cassandra/statements/batch.rb +16 -10
  116. data/lib/cassandra/statements/bound.rb +10 -3
  117. data/lib/cassandra/statements/prepared.rb +59 -15
  118. data/lib/cassandra/statements/simple.rb +23 -10
  119. data/lib/cassandra/statements/void.rb +1 -1
  120. data/lib/cassandra/table.rb +79 -30
  121. data/lib/cassandra/time.rb +11 -6
  122. data/lib/cassandra/time_uuid.rb +7 -7
  123. data/lib/cassandra/tuple.rb +16 -8
  124. data/lib/cassandra/types.rb +20 -9
  125. data/lib/cassandra/udt.rb +32 -36
  126. data/lib/cassandra/util.rb +20 -13
  127. data/lib/cassandra/uuid.rb +22 -15
  128. data/lib/cassandra/uuid/generator.rb +7 -5
  129. data/lib/cassandra/version.rb +2 -2
  130. data/lib/datastax/cassandra.rb +1 -1
  131. metadata +5 -3
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2015 DataStax, Inc.
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.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2015 DataStax, Inc.
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#{self.object_id.to_s(16)}>"
86
+ "#<#{self.class.name}:0x#{object_id.to_s(16)}>"
87
87
  end
88
88
  end
89
89
 
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright 2013-2015 DataStax, Inc.
2
+ # Copyright 2013-2016 DataStax, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2015 DataStax, Inc.
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, max_remote_hosts_to_use = nil, use_remote_hosts_for_local_consistency = false)
60
- datacenter = datacenter && String(datacenter)
61
- max_remote_hosts_to_use = max_remote_hosts_to_use && Integer(max_remote_hosts_to_use)
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) { "datacenter cannot be empty" }
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) { "max_remote_hosts_to_use must be nil or >= 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
- else
90
- if @max_remote.nil? || @remote.size < @max_remote
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
- remote = EMPTY_ARRAY
135
- else
136
- remote = @remote
137
- end
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-2015 DataStax, Inc.
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.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2015 DataStax, Inc.
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
- if @policy.distance(host) == :local
39
- @seen[host] = true
40
- @next = host
41
- break
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, :distance, :plan]
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) { "supplied policy must respond to #{methods.inspect}, but doesn't" }
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
- replicas = replicas.shuffle
131
- else
132
- replicas = replicas.dup
133
- end
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-2015 DataStax, Inc.
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) { "ips must be an Enumerable, #{ips.inspect} given" }
39
- methods = [:host_up, :host_down, :host_found, :host_lost, :setup, :teardown, :distance, :plan]
40
- Util.assert_responds_to_all(methods, wrapped_policy) { "supplied policy must respond to #{methods.inspect}, but doesn't" }
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, "each ip must be a String or IPAddr, #{ip.inspect} given"
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-2015 DataStax, Inc.
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
- def debug?; false end
25
+
26
+ def debug?
27
+ false
28
+ end
29
+
25
30
  def error(*); end
26
- def error?; false end
31
+
32
+ def error?
33
+ false
34
+ end
35
+
27
36
  def fatal(*); end
28
- def fatal?; false end
37
+
38
+ def fatal?
39
+ false
40
+ end
41
+
29
42
  def info(*); end
30
- def info?; false end
43
+
44
+ def info?
45
+ false
46
+ end
47
+
31
48
  def unknown(*); end
49
+
32
50
  def warn(*); end
33
- def warn?; false end
51
+
52
+ def warn?
53
+ false
54
+ end
34
55
  end
35
56
  end
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2015 DataStax, Inc.
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.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2015 DataStax, Inc.
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; extend self
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, type.key_type, type.value_type)
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) {|i| buffer.read_short}
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 |i|
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 |i|
135
- [buffer.read_string, buffer.read_string, buffer.read_string, read_type_v4(buffer)]
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 |i|
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 |i|
160
- [buffer.read_string, buffer.read_string, buffer.read_string, read_type_v4(buffer)]
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) { [buffer.read_string, read_type_v4(buffer)] }
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(*::Array.new(buffer.read_short) { read_type_v4(buffer) })
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 |i|
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
- values[field.name] = nil
279
- else
280
- values[field.name] = read_value_v4(buffer, field.type)
281
- end
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, value, type.key_type, type.value_type)
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 |i|
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
- values[field.name] = nil
458
- else
459
- values[field.name] = read_value_v3(buffer, field.type)
460
- end
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 |i|
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 |i|
501
- [buffer.read_string, buffer.read_string, buffer.read_string, read_type_v3(buffer)]
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) { [buffer.read_string, read_type_v3(buffer)] }
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(*::Array.new(buffer.read_short) { read_type_v3(buffer) })
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, value, type.key_type, type.value_type)
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 |i|
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)] = read_short_value(buffer, value_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 |i|
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 |i|
686
- [buffer.read_string, buffer.read_string, buffer.read_string, read_type_v1(buffer)]
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 = buffer.read_bytes
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 :read_counter :read_bigint
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 :write_counter :write_bigint
852
+ alias write_counter write_bigint
814
853
 
815
854
  def write_blob(buffer, value)
816
855
  buffer.append_bytes(value.encode(::Encoding::BINARY))