cassandra-driver 2.0.1-java → 2.1.0-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 (117) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +18 -9
  3. data/lib/cassandra.rb +5 -1
  4. data/lib/cassandra/address_resolution.rb +1 -1
  5. data/lib/cassandra/address_resolution/policies/ec2_multi_region.rb +1 -1
  6. data/lib/cassandra/address_resolution/policies/none.rb +1 -1
  7. data/lib/cassandra/auth.rb +1 -1
  8. data/lib/cassandra/auth/providers.rb +1 -1
  9. data/lib/cassandra/auth/providers/password.rb +1 -1
  10. data/lib/cassandra/cluster.rb +1 -1
  11. data/lib/cassandra/cluster/client.rb +33 -13
  12. data/lib/cassandra/cluster/connection_pool.rb +1 -1
  13. data/lib/cassandra/cluster/connector.rb +1 -36
  14. data/lib/cassandra/cluster/control_connection.rb +85 -9
  15. data/lib/cassandra/cluster/failed_connection.rb +1 -1
  16. data/lib/cassandra/cluster/metadata.rb +1 -1
  17. data/lib/cassandra/cluster/options.rb +15 -4
  18. data/lib/cassandra/cluster/registry.rb +1 -1
  19. data/lib/cassandra/cluster/schema.rb +76 -16
  20. data/lib/cassandra/cluster/schema/partitioners.rb +1 -1
  21. data/lib/cassandra/cluster/schema/partitioners/murmur3.rb +1 -1
  22. data/lib/cassandra/cluster/schema/partitioners/ordered.rb +1 -1
  23. data/lib/cassandra/cluster/schema/partitioners/random.rb +1 -1
  24. data/lib/cassandra/cluster/schema/replication_strategies.rb +1 -1
  25. data/lib/cassandra/cluster/schema/replication_strategies/network_topology.rb +1 -1
  26. data/lib/cassandra/cluster/schema/replication_strategies/none.rb +1 -1
  27. data/lib/cassandra/cluster/schema/replication_strategies/simple.rb +1 -1
  28. data/lib/cassandra/cluster/schema/type_parser.rb +35 -8
  29. data/lib/cassandra/column.rb +10 -14
  30. data/lib/cassandra/compression.rb +1 -1
  31. data/lib/cassandra/compression/compressors/lz4.rb +1 -1
  32. data/lib/cassandra/compression/compressors/snappy.rb +1 -1
  33. data/lib/cassandra/driver.rb +2 -2
  34. data/lib/cassandra/errors.rb +1 -1
  35. data/lib/cassandra/execution/info.rb +1 -1
  36. data/lib/cassandra/execution/options.rb +3 -2
  37. data/lib/cassandra/execution/trace.rb +1 -1
  38. data/lib/cassandra/executors.rb +1 -1
  39. data/lib/cassandra/future.rb +1 -1
  40. data/lib/cassandra/host.rb +1 -1
  41. data/lib/cassandra/keyspace.rb +55 -5
  42. data/lib/cassandra/listener.rb +1 -1
  43. data/lib/cassandra/load_balancing.rb +1 -1
  44. data/lib/cassandra/load_balancing/policies.rb +1 -1
  45. data/lib/cassandra/load_balancing/policies/dc_aware_round_robin.rb +1 -1
  46. data/lib/cassandra/load_balancing/policies/round_robin.rb +1 -1
  47. data/lib/cassandra/load_balancing/policies/token_aware.rb +1 -1
  48. data/lib/cassandra/load_balancing/policies/white_list.rb +1 -1
  49. data/lib/cassandra/null_logger.rb +1 -1
  50. data/lib/cassandra/protocol.rb +6 -1
  51. data/lib/cassandra/protocol/coder.rb +319 -84
  52. data/lib/cassandra/protocol/cql_byte_buffer.rb +1 -1
  53. data/lib/cassandra/protocol/cql_protocol_handler.rb +24 -10
  54. data/lib/cassandra/protocol/request.rb +1 -1
  55. data/lib/cassandra/protocol/requests/auth_response_request.rb +1 -1
  56. data/lib/cassandra/protocol/requests/batch_request.rb +1 -1
  57. data/lib/cassandra/protocol/requests/credentials_request.rb +1 -1
  58. data/lib/cassandra/protocol/requests/execute_request.rb +1 -1
  59. data/lib/cassandra/protocol/requests/options_request.rb +1 -1
  60. data/lib/cassandra/protocol/requests/prepare_request.rb +1 -1
  61. data/lib/cassandra/protocol/requests/query_request.rb +5 -3
  62. data/lib/cassandra/protocol/requests/register_request.rb +1 -1
  63. data/lib/cassandra/protocol/requests/startup_request.rb +1 -1
  64. data/lib/cassandra/protocol/requests/void_query_request.rb +1 -1
  65. data/lib/cassandra/protocol/response.rb +1 -1
  66. data/lib/cassandra/protocol/responses/already_exists_error_response.rb +1 -1
  67. data/lib/cassandra/protocol/responses/auth_challenge_response.rb +1 -1
  68. data/lib/cassandra/protocol/responses/auth_success_response.rb +1 -1
  69. data/lib/cassandra/protocol/responses/authenticate_response.rb +1 -1
  70. data/lib/cassandra/protocol/responses/error_response.rb +1 -1
  71. data/lib/cassandra/protocol/responses/event_response.rb +1 -1
  72. data/lib/cassandra/protocol/responses/prepared_result_response.rb +1 -1
  73. data/lib/cassandra/protocol/responses/raw_rows_result_response.rb +9 -2
  74. data/lib/cassandra/protocol/responses/read_timeout_error_response.rb +1 -1
  75. data/lib/cassandra/protocol/responses/ready_response.rb +1 -1
  76. data/lib/cassandra/protocol/responses/result_response.rb +1 -1
  77. data/lib/cassandra/protocol/responses/rows_result_response.rb +1 -1
  78. data/lib/cassandra/protocol/responses/schema_change_event_response.rb +21 -6
  79. data/lib/cassandra/protocol/responses/schema_change_result_response.rb +18 -8
  80. data/lib/cassandra/protocol/responses/set_keyspace_result_response.rb +1 -1
  81. data/lib/cassandra/protocol/responses/status_change_event_response.rb +1 -1
  82. data/lib/cassandra/protocol/responses/supported_response.rb +1 -1
  83. data/lib/cassandra/protocol/responses/topology_change_event_response.rb +1 -1
  84. data/lib/cassandra/protocol/responses/unavailable_error_response.rb +1 -1
  85. data/lib/cassandra/protocol/responses/unprepared_error_response.rb +1 -1
  86. data/lib/cassandra/protocol/responses/void_result_response.rb +1 -1
  87. data/lib/cassandra/protocol/responses/write_timeout_error_response.rb +1 -1
  88. data/lib/cassandra/protocol/v1.rb +4 -2
  89. data/lib/cassandra/protocol/v3.rb +280 -0
  90. data/lib/cassandra/reconnection.rb +1 -1
  91. data/lib/cassandra/reconnection/policies.rb +1 -1
  92. data/lib/cassandra/reconnection/policies/constant.rb +1 -1
  93. data/lib/cassandra/reconnection/policies/exponential.rb +1 -1
  94. data/lib/cassandra/result.rb +1 -1
  95. data/lib/cassandra/retry.rb +1 -1
  96. data/lib/cassandra/retry/policies.rb +1 -1
  97. data/lib/cassandra/retry/policies/default.rb +1 -1
  98. data/lib/cassandra/retry/policies/downgrading_consistency.rb +1 -1
  99. data/lib/cassandra/retry/policies/fallthrough.rb +1 -1
  100. data/lib/cassandra/session.rb +14 -80
  101. data/lib/cassandra/statement.rb +1 -1
  102. data/lib/cassandra/statements.rb +1 -1
  103. data/lib/cassandra/statements/batch.rb +10 -25
  104. data/lib/cassandra/statements/bound.rb +1 -1
  105. data/lib/cassandra/statements/prepared.rb +24 -31
  106. data/lib/cassandra/statements/simple.rb +22 -66
  107. data/lib/cassandra/statements/void.rb +1 -1
  108. data/lib/cassandra/table.rb +36 -5
  109. data/lib/cassandra/time_uuid.rb +1 -1
  110. data/lib/cassandra/tuple.rb +124 -0
  111. data/lib/cassandra/types.rb +1406 -0
  112. data/lib/cassandra/udt.rb +420 -0
  113. data/lib/cassandra/util.rb +42 -64
  114. data/lib/cassandra/uuid.rb +1 -1
  115. data/lib/cassandra/uuid/generator.rb +1 -1
  116. data/lib/cassandra/version.rb +2 -2
  117. metadata +38 -34
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2014 DataStax, Inc.
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.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2014 DataStax, Inc.
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
- @promises = Array.new(128) { nil }
44
- @frame_encoder = V1::Encoder.new(@compressor, protocol_version)
45
- @frame_decoder = V1::Decoder.new(self, @compressor)
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[id]
215
- @promises[id] = nil
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.table.empty?
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.compact
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.fill(nil)
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 = @promises.index(nil))
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-2014 DataStax, Inc.
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.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2014 DataStax, Inc.
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.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2014 DataStax, Inc.
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.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2014 DataStax, Inc.
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.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2014 DataStax, Inc.
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.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2014 DataStax, Inc.
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.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2014 DataStax, Inc.
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.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2014 DataStax, Inc.
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-2014 DataStax, Inc.
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.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2014 DataStax, Inc.
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.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2014 DataStax, Inc.
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.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2014 DataStax, Inc.
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.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2014 DataStax, Inc.
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.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2014 DataStax, Inc.
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.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2014 DataStax, Inc.
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.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2014 DataStax, Inc.
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.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2014 DataStax, Inc.
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.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2014 DataStax, Inc.
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.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2014 DataStax, Inc.
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.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2014 DataStax, Inc.
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
- @rows = Coder.read_values_v1(@raw_rows, @metadata)
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-2014 DataStax, Inc.
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.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2014 DataStax, Inc.
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.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2014 DataStax, Inc.
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.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2014 DataStax, Inc.
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.
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  #--
4
- # Copyright 2013-2014 DataStax, Inc.
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 :type, :change, :keyspace, :table
24
+ attr_reader :change, :keyspace, :table, :type, :target
25
25
 
26
- def initialize(*args)
27
- @change, @keyspace, @table = args
28
- @type = TYPE
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 #@type #@change "#@keyspace" "#@table")
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-2014 DataStax, Inc.
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, table, trace_id)
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
- def self.decode(protocol_version, buffer, length, trace_id=nil)
30
- new(buffer.read_string, buffer.read_string, buffer.read_string, trace_id)
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