cassandra-driver 2.1.7-java → 3.0.0.beta.1-java

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 (79) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +31 -53
  3. data/lib/cassandra.rb +22 -3
  4. data/lib/cassandra/aggregate.rb +109 -0
  5. data/lib/cassandra/argument.rb +51 -0
  6. data/lib/cassandra/auth/providers/password.rb +7 -4
  7. data/lib/cassandra/cluster.rb +14 -3
  8. data/lib/cassandra/cluster/client.rb +56 -34
  9. data/lib/cassandra/cluster/connector.rb +6 -6
  10. data/lib/cassandra/cluster/control_connection.rb +204 -251
  11. data/lib/cassandra/cluster/metadata.rb +2 -0
  12. data/lib/cassandra/cluster/schema.rb +131 -209
  13. data/lib/cassandra/cluster/schema/cql_type_parser.rb +104 -0
  14. data/lib/cassandra/cluster/schema/fetchers.rb +1174 -0
  15. data/lib/cassandra/cluster/schema/{type_parser.rb → fqcn_type_parser.rb} +7 -3
  16. data/lib/cassandra/column.rb +2 -2
  17. data/lib/cassandra/driver.rb +27 -9
  18. data/lib/cassandra/errors.rb +179 -25
  19. data/lib/cassandra/execution/info.rb +8 -1
  20. data/lib/cassandra/execution/options.rb +34 -0
  21. data/lib/cassandra/execution/trace.rb +42 -10
  22. data/lib/cassandra/function.rb +150 -0
  23. data/lib/cassandra/future.rb +66 -35
  24. data/lib/cassandra/host.rb +7 -4
  25. data/lib/cassandra/keyspace.rb +112 -13
  26. data/lib/cassandra/load_balancing.rb +1 -1
  27. data/lib/cassandra/protocol.rb +9 -3
  28. data/lib/cassandra/protocol/coder.rb +434 -155
  29. data/lib/cassandra/protocol/cql_byte_buffer.rb +43 -0
  30. data/lib/cassandra/protocol/cql_protocol_handler.rb +4 -1
  31. data/lib/cassandra/protocol/request.rb +4 -0
  32. data/lib/cassandra/protocol/requests/auth_response_request.rb +5 -1
  33. data/lib/cassandra/protocol/requests/batch_request.rb +7 -2
  34. data/lib/cassandra/protocol/requests/credentials_request.rb +5 -1
  35. data/lib/cassandra/protocol/requests/execute_request.rb +16 -10
  36. data/lib/cassandra/protocol/requests/prepare_request.rb +12 -3
  37. data/lib/cassandra/protocol/requests/query_request.rb +20 -11
  38. data/lib/cassandra/protocol/responses/already_exists_error_response.rb +4 -4
  39. data/lib/cassandra/protocol/responses/error_response.rb +14 -14
  40. data/lib/cassandra/protocol/responses/function_failure_error_response.rb +41 -0
  41. data/lib/cassandra/protocol/responses/prepared_result_response.rb +12 -9
  42. data/lib/cassandra/protocol/responses/raw_rows_result_response.rb +5 -3
  43. data/lib/cassandra/protocol/responses/read_failure_error_response.rb +43 -0
  44. data/lib/cassandra/protocol/responses/read_timeout_error_response.rb +4 -4
  45. data/lib/cassandra/protocol/responses/ready_response.rb +5 -1
  46. data/lib/cassandra/protocol/responses/result_response.rb +3 -3
  47. data/lib/cassandra/protocol/responses/rows_result_response.rb +2 -2
  48. data/lib/cassandra/protocol/responses/schema_change_event_response.rb +25 -24
  49. data/lib/cassandra/protocol/responses/schema_change_result_response.rb +20 -23
  50. data/lib/cassandra/protocol/responses/set_keyspace_result_response.rb +2 -2
  51. data/lib/cassandra/protocol/responses/unavailable_error_response.rb +4 -4
  52. data/lib/cassandra/protocol/responses/unprepared_error_response.rb +4 -4
  53. data/lib/cassandra/protocol/responses/write_failure_error_response.rb +45 -0
  54. data/lib/cassandra/protocol/responses/write_timeout_error_response.rb +4 -4
  55. data/lib/cassandra/protocol/v1.rb +38 -13
  56. data/lib/cassandra/protocol/v3.rb +34 -29
  57. data/lib/cassandra/protocol/v4.rb +334 -0
  58. data/lib/cassandra/result.rb +10 -9
  59. data/lib/cassandra/retry.rb +17 -3
  60. data/lib/cassandra/retry/policies/default.rb +9 -3
  61. data/lib/cassandra/session.rb +15 -7
  62. data/lib/cassandra/statement.rb +5 -0
  63. data/lib/cassandra/statements/batch.rb +36 -12
  64. data/lib/cassandra/statements/bound.rb +2 -1
  65. data/lib/cassandra/statements/prepared.rb +106 -35
  66. data/lib/cassandra/statements/simple.rb +4 -2
  67. data/lib/cassandra/table.rb +70 -105
  68. data/lib/cassandra/time.rb +98 -0
  69. data/lib/cassandra/time_uuid.rb +1 -1
  70. data/lib/cassandra/tuple.rb +7 -0
  71. data/lib/cassandra/types.rb +472 -272
  72. data/lib/cassandra/udt.rb +10 -0
  73. data/lib/cassandra/util.rb +32 -1
  74. data/lib/cassandra/uuid.rb +6 -1
  75. data/lib/cassandra/uuid/generator.rb +7 -7
  76. data/lib/cassandra/version.rb +1 -1
  77. data/lib/cassandra_murmur3.jar +0 -0
  78. data/lib/datastax/cassandra.rb +5 -2
  79. metadata +27 -17
@@ -18,6 +18,7 @@
18
18
 
19
19
  module Cassandra
20
20
  module Protocol
21
+ # @private
21
22
  module V3
22
23
  class Encoder
23
24
  HEADER_FORMAT = 'c2ncN'.freeze
@@ -80,7 +81,7 @@ module Cassandra
80
81
  stream_id = (frame_header >> 8) & 0xff
81
82
  stream_id = (stream_id & 0x7f) - (stream_id & 0x80)
82
83
 
83
- @handler.complete_request(stream_id, ErrorResponse.new(0x000A, "Invalid or unsupported protocol version"))
84
+ @handler.complete_request(stream_id, ErrorResponse.new(nil, nil, 0x000A, "Invalid or unsupported protocol version"))
84
85
 
85
86
  return
86
87
  end
@@ -139,7 +140,7 @@ module Cassandra
139
140
  frame_header = buffer.read_int
140
141
  frame_code = buffer.read_byte
141
142
  frame_length = buffer.read_int
142
- buffer_length -= 8
143
+ buffer_length -= 9
143
144
  end
144
145
 
145
146
  @header = frame_header
@@ -194,13 +195,13 @@ module Cassandra
194
195
  message = buffer.read_string
195
196
 
196
197
  case code
197
- when 0x1000 then UnavailableErrorResponse.new(code, message, buffer.read_consistency, buffer.read_int, buffer.read_int)
198
- when 0x1100 then WriteTimeoutErrorResponse.new(code, message, buffer.read_consistency, buffer.read_int, buffer.read_int, buffer.read_string)
199
- when 0x1200 then ReadTimeoutErrorResponse.new(code, message, buffer.read_consistency, buffer.read_int, buffer.read_int, (buffer.read_byte != 0))
200
- when 0x2400 then AlreadyExistsErrorResponse.new(code, message, buffer.read_string, buffer.read_string)
201
- when 0x2500 then UnpreparedErrorResponse.new(code, message, buffer.read_short_bytes)
198
+ when 0x1000 then UnavailableErrorResponse.new(nil, nil, code, message, buffer.read_consistency, buffer.read_int, buffer.read_int)
199
+ when 0x1100 then WriteTimeoutErrorResponse.new(nil, nil, code, message, buffer.read_consistency, buffer.read_int, buffer.read_int, buffer.read_string)
200
+ when 0x1200 then ReadTimeoutErrorResponse.new(nil, nil, code, message, buffer.read_consistency, buffer.read_int, buffer.read_int, (buffer.read_byte != 0))
201
+ when 0x2400 then AlreadyExistsErrorResponse.new(nil, nil, code, message, buffer.read_string, buffer.read_string)
202
+ when 0x2500 then UnpreparedErrorResponse.new(nil, nil, code, message, buffer.read_short_bytes)
202
203
  else
203
- ErrorResponse.new(code, message)
204
+ ErrorResponse.new(nil, nil, code, message)
204
205
  end
205
206
  when 0x02 # READY
206
207
  READY
@@ -212,7 +213,7 @@ module Cassandra
212
213
  result_type = buffer.read_int
213
214
  case result_type
214
215
  when 0x0001 # Void
215
- VoidResultResponse.new(trace_id)
216
+ VoidResultResponse.new(nil, nil, trace_id)
216
217
  when 0x0002 # Rows
217
218
  original_buffer_length = buffer.length
218
219
  column_specs, paging_state = Coder.read_metadata_v3(buffer)
@@ -220,29 +221,31 @@ module Cassandra
220
221
  if column_specs.nil?
221
222
  consumed_bytes = original_buffer_length - buffer.length
222
223
  remaining_bytes = CqlByteBuffer.new(buffer.read(size - consumed_bytes - 4))
223
- RawRowsResultResponse.new(protocol_version, remaining_bytes, paging_state, trace_id)
224
+ RawRowsResultResponse.new(nil, nil, protocol_version, remaining_bytes, paging_state, trace_id)
224
225
  else
225
- RowsResultResponse.new(Coder.read_values_v3(buffer, column_specs), column_specs, paging_state, trace_id)
226
+ RowsResultResponse.new(nil, nil, Coder.read_values_v3(buffer, column_specs), column_specs, paging_state, trace_id)
226
227
  end
227
228
  when 0x0003 # SetKeyspace
228
- SetKeyspaceResultResponse.new(buffer.read_string, trace_id)
229
+ SetKeyspaceResultResponse.new(nil, nil, buffer.read_string, trace_id)
229
230
  when 0x0004 # Prepared
230
231
  id = buffer.read_short_bytes
231
232
  params_metadata = Coder.read_metadata_v3(buffer).first
232
233
  result_metadata = nil
233
234
  result_metadata = Coder.read_metadata_v3(buffer).first if protocol_version > 1
234
235
 
235
- PreparedResultResponse.new(id, params_metadata, result_metadata, trace_id)
236
+ PreparedResultResponse.new(nil, nil, id, params_metadata, result_metadata, nil, trace_id)
236
237
  when 0x0005 # SchemaChange
237
- change = buffer.read_string
238
- target = buffer.read_string
239
- keyspace = buffer.read_string
240
-
241
- if target == 'KEYSPACE'
242
- SchemaChangeResultResponse.new(change, keyspace, nil, trace_id, target)
243
- else
244
- SchemaChangeResultResponse.new(change, keyspace, buffer.read_string, trace_id, target)
238
+ change = buffer.read_string
239
+ target = buffer.read_string
240
+ keyspace = buffer.read_string
241
+ arguments = EMPTY_LIST
242
+ name = nil
243
+
244
+ if target == Constants::SCHEMA_CHANGE_TARGET_TABLE
245
+ name = buffer.read_string
245
246
  end
247
+
248
+ SchemaChangeResultResponse.new(nil, nil, change, keyspace, name, target, arguments, nil)
246
249
  else
247
250
  raise Errors::DecodingError, "Unsupported result type: #{result_type.inspect}"
248
251
  end
@@ -250,15 +253,17 @@ module Cassandra
250
253
  event_type = buffer.read_string
251
254
  case event_type
252
255
  when 'SCHEMA_CHANGE'
253
- change = buffer.read_string
254
- target = buffer.read_string
255
- keyspace = buffer.read_string
256
-
257
- if target == 'KEYSPACE'
258
- SchemaChangeEventResponse.new(change, keyspace, nil, target)
259
- else
260
- SchemaChangeEventResponse.new(change, keyspace, buffer.read_string, target)
256
+ change = buffer.read_string
257
+ target = buffer.read_string
258
+ keyspace = buffer.read_string
259
+ name = nil
260
+ arguments = EMPTY_LIST
261
+
262
+ if target == Constants::SCHEMA_CHANGE_TARGET_TABLE
263
+ name = buffer.read_string
261
264
  end
265
+
266
+ SchemaChangeEventResponse.new(change, keyspace, name, target, arguments)
262
267
  when 'STATUS_CHANGE'
263
268
  StatusChangeEventResponse.new(buffer.read_string, *buffer.read_inet)
264
269
  when 'TOPOLOGY_CHANGE'
@@ -0,0 +1,334 @@
1
+ # encoding: utf-8
2
+
3
+ #--
4
+ # Copyright 2013-2015 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
+
19
+ module Cassandra
20
+ module Protocol
21
+ # @private
22
+ module V4
23
+ class Encoder
24
+ HEADER_FORMAT = 'c2ncN'.freeze
25
+
26
+ def initialize(compressor = nil, protocol_version = 4)
27
+ @compressor = compressor
28
+ @protocol_version = protocol_version
29
+ end
30
+
31
+ def encode(buffer, request, stream_id)
32
+ flags = 0
33
+ flags |= 0x02 if request.trace?
34
+
35
+ body = CqlByteBuffer.new
36
+
37
+ if request.payload?
38
+ flags |= 0x04
39
+ body.append_bytes_map(request.payload)
40
+ end
41
+
42
+ request.write(body, @protocol_version, self)
43
+
44
+ if @compressor && request.compressable? && @compressor.compress?(body)
45
+ flags |= 1
46
+ body = @compressor.compress(body)
47
+ end
48
+
49
+ header = [@protocol_version, flags, stream_id, request.opcode, body.bytesize]
50
+ buffer << header.pack(HEADER_FORMAT)
51
+ buffer << body
52
+
53
+ buffer
54
+ end
55
+
56
+ def write_parameters(buffer, params, types, names = EMPTY_LIST)
57
+ Coder.write_values_v4(buffer, params, types, names)
58
+ end
59
+ end
60
+
61
+ class Decoder
62
+ def initialize(handler, compressor = nil)
63
+ @handler = handler
64
+ @compressor = compressor
65
+ @state = :initial
66
+ @header = nil
67
+ @version = nil
68
+ @code = nil
69
+ @length = nil
70
+ @buffer = CqlByteBuffer.new
71
+ end
72
+
73
+ def <<(data)
74
+ @buffer << data
75
+
76
+ __send__(:"decode_#{@state}", @buffer)
77
+ end
78
+
79
+ private
80
+
81
+ READY = ReadyResponse.new
82
+
83
+ def decode_initial(buffer)
84
+ return if buffer.length < 9
85
+
86
+ frame_header = buffer.read_int
87
+ protocol_version = (frame_header >> 24) & 0x7f
88
+
89
+ if protocol_version < 3
90
+ stream_id = (frame_header >> 8) & 0xff
91
+ stream_id = (stream_id & 0x7f) - (stream_id & 0x80)
92
+
93
+ @handler.complete_request(stream_id, ErrorResponse.new(nil, nil, 0x000A, "Invalid or unsupported protocol version"))
94
+
95
+ return
96
+ end
97
+
98
+ @header = frame_header
99
+ @code = buffer.read_byte
100
+ @length = buffer.read_int
101
+ @state = :body
102
+
103
+ decode_body(buffer)
104
+ end
105
+
106
+ def decode_header(buffer)
107
+ buffer_length = buffer.length
108
+
109
+ while buffer_length >= 9
110
+ frame_header = buffer.read_int
111
+ frame_code = buffer.read_byte
112
+ frame_length = buffer.read_int
113
+
114
+ if (buffer_length - 9) < frame_length
115
+ @header = frame_header
116
+ @code = frame_code
117
+ @length = frame_length
118
+ @state = :body
119
+
120
+ return
121
+ end
122
+
123
+ actual_decode(buffer, frame_header, frame_length, frame_code)
124
+ buffer_length = buffer.length
125
+ end
126
+
127
+ nil
128
+ end
129
+
130
+ def decode_body(buffer)
131
+ frame_header = @header
132
+ frame_code = @code
133
+ frame_length = @length
134
+ buffer_length = buffer.length
135
+
136
+ until buffer_length < frame_length
137
+ actual_decode(buffer, frame_header, frame_length, frame_code)
138
+ buffer_length = buffer.length
139
+
140
+ if buffer_length < 9
141
+ @header = nil
142
+ @code = nil
143
+ @length = nil
144
+ @state = :header
145
+
146
+ return
147
+ end
148
+
149
+ frame_header = buffer.read_int
150
+ frame_code = buffer.read_byte
151
+ frame_length = buffer.read_int
152
+ buffer_length -= 9
153
+ end
154
+
155
+ @header = frame_header
156
+ @code = frame_code
157
+ @length = frame_length
158
+
159
+ nil
160
+ end
161
+
162
+ def actual_decode(buffer, fields, size, code)
163
+ protocol_version = (fields >> 24) & 0x7f
164
+ compression = ((fields >> 16) & 0x01) == 0x01
165
+ tracing = ((fields >> 16) & 0x02) == 0x02
166
+ payload = ((fields >> 16) & 0x04) == 0x04
167
+ warning = ((fields >> 16) & 0x08) == 0x08
168
+ stream_id = fields & 0xffff
169
+ stream_id = (stream_id & 0x7fff) - (stream_id & 0x8000)
170
+ opcode = code & 0xff
171
+
172
+ if compression
173
+ if @compressor
174
+ buffer = CqlByteBuffer.new(@compressor.decompress(buffer.read(size)))
175
+ size = buffer.size
176
+ else
177
+ raise Errors::DecodingError, 'Compressed frame received, but no compressor configured'
178
+ end
179
+ end
180
+
181
+ if tracing
182
+ trace_id = buffer.read_uuid
183
+ size = buffer.size
184
+ else
185
+ trace_id = nil
186
+ end
187
+
188
+ if payload
189
+ custom_payload = buffer.read_bytes_map.freeze
190
+ size = buffer.size
191
+ else
192
+ custom_payload = nil
193
+ end
194
+
195
+ if warning
196
+ warnings = buffer.read_string_list
197
+ size = buffer.size
198
+ else
199
+ warnings = nil
200
+ end
201
+
202
+ extra_length = buffer.length - size
203
+ response = decode_response(opcode, protocol_version, buffer, size, trace_id, custom_payload, warnings)
204
+
205
+ if buffer.length > extra_length
206
+ buffer.discard(buffer.length - extra_length)
207
+ end
208
+
209
+ if stream_id == -1
210
+ @handler.notify_event_listeners(response)
211
+ else
212
+ @handler.complete_request(stream_id, response)
213
+ end
214
+ end
215
+
216
+ def decode_response(opcode, protocol_version, buffer, size, trace_id, custom_payload, warnings)
217
+ case opcode
218
+ when 0x00 # ERROR
219
+ code = buffer.read_int
220
+ message = buffer.read_string
221
+
222
+ case code
223
+ when 0x1000 then UnavailableErrorResponse.new(custom_payload, warnings, code, message, buffer.read_consistency, buffer.read_int, buffer.read_int)
224
+ when 0x1100 then WriteTimeoutErrorResponse.new(custom_payload, warnings, code, message, buffer.read_consistency, buffer.read_int, buffer.read_int, buffer.read_string)
225
+ when 0x1200 then ReadTimeoutErrorResponse.new(custom_payload, warnings, code, message, buffer.read_consistency, buffer.read_int, buffer.read_int, (buffer.read_byte != 0))
226
+ when 0x1300 then ReadFailureErrorResponse.new(custom_payload, warnings, code, message, buffer.read_consistency, buffer.read_int, buffer.read_int, buffer.read_int, (buffer.read_byte != 0))
227
+ when 0x1400 then FunctionFailureErrorResponse.new(custom_payload, warnings, code, message, buffer.read_string, buffer.read_string, buffer.read_string_list)
228
+ when 0x1500 then WriteFailureErrorResponse.new(custom_payload, warnings, code, message, buffer.read_consistency, buffer.read_int, buffer.read_int, buffer.read_int, buffer.read_string)
229
+ when 0x2400 then AlreadyExistsErrorResponse.new(custom_payload, warnings, code, message, buffer.read_string, buffer.read_string)
230
+ when 0x2500 then UnpreparedErrorResponse.new(custom_payload, warnings, code, message, buffer.read_short_bytes)
231
+ else
232
+ ErrorResponse.new(custom_payload, warnings, code, message)
233
+ end
234
+ when 0x02 # READY
235
+ READY
236
+ when 0x03 # AUTHENTICATE
237
+ AuthenticateResponse.new(buffer.read_string)
238
+ when 0x06 # SUPPORTED
239
+ SupportedResponse.new(buffer.read_string_multimap)
240
+ when 0x08 # RESULT
241
+ result_type = buffer.read_int
242
+ case result_type
243
+ when 0x0001 # Void
244
+ VoidResultResponse.new(custom_payload, warnings, trace_id)
245
+ when 0x0002 # Rows
246
+ original_buffer_length = buffer.length
247
+ column_specs, paging_state = Coder.read_metadata_v4(buffer)
248
+
249
+ if column_specs.nil?
250
+ consumed_bytes = original_buffer_length - buffer.length
251
+ remaining_bytes = CqlByteBuffer.new(buffer.read(size - consumed_bytes - 4))
252
+ RawRowsResultResponse.new(custom_payload, warnings, protocol_version, remaining_bytes, paging_state, trace_id)
253
+ else
254
+ RowsResultResponse.new(custom_payload, warnings, Coder.read_values_v4(buffer, column_specs), column_specs, paging_state, trace_id)
255
+ end
256
+ when 0x0003 # SetKeyspace
257
+ SetKeyspaceResultResponse.new(custom_payload, warnings, buffer.read_string, trace_id)
258
+ when 0x0004 # Prepared
259
+ id = buffer.read_short_bytes
260
+ pk_idx, params_metadata = Coder.read_prepared_metadata_v4(buffer)
261
+ result_metadata = Coder.read_metadata_v4(buffer).first
262
+
263
+ PreparedResultResponse.new(custom_payload, warnings, id, params_metadata, result_metadata, pk_idx, trace_id)
264
+ when 0x0005 # SchemaChange
265
+ change = buffer.read_string
266
+ target = buffer.read_string
267
+ keyspace = nil
268
+ name = nil
269
+ arguments = EMPTY_LIST
270
+
271
+ case target
272
+ when Protocol::Constants::SCHEMA_CHANGE_TARGET_KEYSPACE
273
+ keyspace = buffer.read_string
274
+ when Protocol::Constants::SCHEMA_CHANGE_TARGET_TABLE,
275
+ Protocol::Constants::SCHEMA_CHANGE_TARGET_UDT
276
+ keyspace = buffer.read_string
277
+ name = buffer.read_string
278
+ when Protocol::Constants::SCHEMA_CHANGE_TARGET_FUNCTION,
279
+ Protocol::Constants::SCHEMA_CHANGE_TARGET_AGGREGATE
280
+ keyspace = buffer.read_string
281
+ name = buffer.read_string
282
+ arguments = buffer.read_string_list
283
+ end
284
+
285
+ SchemaChangeResultResponse.new(custom_payload, warnings, change, keyspace, name, target, arguments, trace_id)
286
+ else
287
+ raise Errors::DecodingError, "Unsupported result type: #{result_type.inspect}"
288
+ end
289
+ when 0x0C # EVENT
290
+ event_type = buffer.read_string
291
+ case event_type
292
+ when 'SCHEMA_CHANGE'
293
+ change = buffer.read_string
294
+ target = buffer.read_string
295
+ keyspace = nil
296
+ arguments = EMPTY_LIST
297
+
298
+ case target
299
+ when Protocol::Constants::SCHEMA_CHANGE_TARGET_KEYSPACE
300
+ keyspace = buffer.read_string
301
+ name = nil
302
+ when Protocol::Constants::SCHEMA_CHANGE_TARGET_TABLE,
303
+ Protocol::Constants::SCHEMA_CHANGE_TARGET_UDT,
304
+ Protocol::Constants::SCHEMA_CHANGE_TARGET_FUNCTION,
305
+ Protocol::Constants::SCHEMA_CHANGE_TARGET_AGGREGATE
306
+ keyspace = buffer.read_string
307
+ name = buffer.read_string
308
+ end
309
+
310
+ if target == Protocol::Constants::SCHEMA_CHANGE_TARGET_FUNCTION \
311
+ || target == Protocol::Constants::SCHEMA_CHANGE_TARGET_AGGREGATE
312
+ arguments = buffer.read_string_list
313
+ end
314
+
315
+ SchemaChangeEventResponse.new(change, keyspace, name, target, arguments)
316
+ when 'STATUS_CHANGE'
317
+ StatusChangeEventResponse.new(buffer.read_string, *buffer.read_inet)
318
+ when 'TOPOLOGY_CHANGE'
319
+ TopologyChangeEventResponse.new(buffer.read_string, *buffer.read_inet)
320
+ else
321
+ raise Errors::DecodingError, "Unsupported event type: #{event_type.inspect}"
322
+ end
323
+ when 0x0E # AUTH_CHALLENGE
324
+ AuthChallengeResponse.new(buffer.read_bytes)
325
+ when 0x10 # AUTH_SUCCESS
326
+ AuthSuccessResponse.new(buffer.read_bytes)
327
+ else
328
+ raise Errors::DecodingError, "Unsupported response opcode: #{opcode.inspect}"
329
+ end
330
+ end
331
+ end
332
+ end
333
+ end
334
+ end