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.
@@ -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,9 +21,8 @@ module Cassandra
21
21
  # @private
22
22
  class Options
23
23
  attr_reader :credentials, :auth_provider, :compressor, :port,
24
- :connect_timeout, :ssl, :connections_per_local_node,
25
- :connections_per_remote_node, :heartbeat_interval,
26
- :idle_timeout, :schema_refresh_delay, :schema_refresh_timeout
24
+ :connect_timeout, :ssl, :heartbeat_interval, :idle_timeout,
25
+ :schema_refresh_delay, :schema_refresh_timeout
27
26
  attr_accessor :protocol_version
28
27
 
29
28
  def initialize(protocol_version, credentials, auth_provider, compressor, port, connect_timeout, ssl, connections_per_local_node, connections_per_remote_node, heartbeat_interval, idle_timeout, synchronize_schema, schema_refresh_delay, schema_refresh_timeout)
@@ -55,6 +54,18 @@ module Cassandra
55
54
  def create_authenticator(authentication_class)
56
55
  @auth_provider && @auth_provider.create_authenticator(authentication_class)
57
56
  end
57
+
58
+ # increased number of streams in native protocol v3 allow for one
59
+ # connections to be sufficient
60
+ def connections_per_local_node
61
+ (@protocol_version > 2) ? 1 : @connections_per_local_node
62
+ end
63
+
64
+ # increased number of streams in native protocol v3 allow for one
65
+ # connections to be sufficient
66
+ def connections_per_remote_node
67
+ (@protocol_version > 2) ? 1 : @connections_per_remote_node
68
+ end
58
69
  end
59
70
  end
60
71
  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.
@@ -51,7 +51,7 @@ module Cassandra
51
51
  self
52
52
  end
53
53
 
54
- def update_keyspaces(host, keyspaces, tables, columns)
54
+ def update_keyspaces(host, keyspaces, tables, columns, types)
55
55
  columns = columns.each_with_object(deephash { [] }) do |row, index|
56
56
  index[row['keyspace_name']] << row
57
57
  end
@@ -60,12 +60,16 @@ module Cassandra
60
60
  index[row['keyspace_name']] << row
61
61
  end
62
62
 
63
+ types = types.each_with_object(deephash { [] }) do |row, index|
64
+ index[row['keyspace_name']] << row
65
+ end
66
+
63
67
  current_keyspaces = ::Set.new
64
68
 
65
69
  keyspaces.each do |row|
66
70
  current_keyspaces << keyspace = row['keyspace_name']
67
71
 
68
- update_keyspace(host, row, tables[keyspace], columns[keyspace])
72
+ update_keyspace(host, row, tables[keyspace], columns[keyspace], types[keyspace])
69
73
  end
70
74
 
71
75
  @keyspaces.each do |name, keyspace|
@@ -75,7 +79,7 @@ module Cassandra
75
79
  self
76
80
  end
77
81
 
78
- def update_keyspace(host, keyspace, tables, columns)
82
+ def update_keyspace(host, keyspace, tables, columns, types)
79
83
  keyspace_name = keyspace['keyspace_name']
80
84
 
81
85
  columns = columns.each_with_object(deephash { ::Hash.new }) do |row, index|
@@ -87,8 +91,13 @@ module Cassandra
87
91
  index[name] = create_table(row, columns[name], host.release_version)
88
92
  end
89
93
 
94
+ types = types.each_with_object(Hash.new) do |row, index|
95
+ name = row['type_name']
96
+ index[name] = create_type(row, host.release_version)
97
+ end
98
+
90
99
  replication = Keyspace::Replication.new(keyspace['strategy_class'], ::JSON.load(keyspace['strategy_options']))
91
- keyspace = Keyspace.new(keyspace_name, keyspace['durable_writes'], replication, tables)
100
+ keyspace = Keyspace.new(keyspace_name, keyspace['durable_writes'], replication, tables, types)
92
101
 
93
102
  return self if keyspace == @keyspaces[keyspace_name]
94
103
 
@@ -165,6 +174,43 @@ module Cassandra
165
174
  self
166
175
  end
167
176
 
177
+ def udpate_type(host, keyspace_name, type)
178
+ keyspace = @keyspaces[keyspace_name]
179
+
180
+ return self unless keyspace
181
+
182
+ type = create_type(type, host.release_version)
183
+ keyspace = keyspace.update_type(type)
184
+
185
+ synchronize do
186
+ keyspaces = @keyspaces.dup
187
+ keyspaces[keyspace_name] = keyspace
188
+ @keyspaces = keyspaces
189
+ end
190
+
191
+ keyspace_changed(keyspace)
192
+
193
+ self
194
+ end
195
+
196
+ def delete_type(keyspace_name, type_name)
197
+ keyspace = @keyspaces[keyspace_name]
198
+
199
+ return self unless keyspace
200
+
201
+ keyspace = keyspace.delete_type(type_name)
202
+
203
+ synchronize do
204
+ keyspaces = @keyspaces.dup
205
+ keyspaces[keyspace_name] = keyspace
206
+ @keyspaces = keyspaces
207
+ end
208
+
209
+ keyspace_changed(keyspace)
210
+
211
+ self
212
+ end
213
+
168
214
  def has_keyspace?(name)
169
215
  @keyspaces.include?(name)
170
216
  end
@@ -185,6 +231,20 @@ module Cassandra
185
231
 
186
232
  private
187
233
 
234
+ def create_type(type, version)
235
+ keyspace = type['keyspace_name']
236
+ name = type['type_name']
237
+ fields = ::Array.new
238
+
239
+ type['field_names'].zip(type['field_types']) do |(field_name, field_type)|
240
+ field_type = @type_parser.parse(field_type).results.first.first
241
+
242
+ fields << [field_name, field_type]
243
+ end
244
+
245
+ Types.udt(keyspace, name, fields)
246
+ end
247
+
188
248
  def create_table(table, columns, version)
189
249
  keyspace = table['keyspace_name']
190
250
  name = table['columnfamily_name']
@@ -210,7 +270,7 @@ module Cassandra
210
270
  options = Table::Options.new(table, compaction_strategy, compression_parameters, is_compact, version)
211
271
  columns = create_columns(key_validator, comparator, column_aliases, is_dense, clustering_size, table, columns, version, partition_key, clustering_columns, clustering_order)
212
272
 
213
- Table.new(keyspace, name, partition_key, clustering_columns, columns, options, clustering_order)
273
+ Table.new(keyspace, name, partition_key, clustering_columns, columns, options, clustering_order, version)
214
274
  end
215
275
 
216
276
  def find_clustering_size(comparator, columns, aliases, cassandra_version)
@@ -247,33 +307,33 @@ module Cassandra
247
307
  if cassandra_version.start_with?('1')
248
308
  key_aliases = ::JSON.load(table['key_aliases'])
249
309
 
250
- key_validator.results.each_with_index do |(type, order), i|
310
+ key_validator.results.each_with_index do |(type, order, is_frozen), i|
251
311
  key_alias = key_aliases.fetch(i) { i.zero? ? "key" : "key#{i + 1}" }
252
312
 
253
- partition_key[i] = Column.new(key_alias, type, order)
313
+ partition_key[i] = Column.new(key_alias, type, order, nil, false, is_frozen)
254
314
  end
255
315
 
256
316
  if comparator.results.size > 1
257
317
  clustering_size.times do |i|
258
318
  column_alias = column_aliases.fetch(i) { "column#{i + 1}" }
259
- type, order = comparator.results.fetch(i)
319
+ type, order, is_frozen = comparator.results.fetch(i)
260
320
 
261
- clustering_columns[i] = Column.new(column_alias, type, order)
321
+ clustering_columns[i] = Column.new(column_alias, type, order, nil, false, is_frozen)
262
322
  clustering_order[i] = order
263
323
  end
264
324
  else
265
325
  column_alias = column_aliases.first || "column1"
266
- type, order = comparator.results.first
326
+ type, order, is_frozen = comparator.results.first
267
327
 
268
- clustering_columns[0] = Column.new(column_alias, type, order)
328
+ clustering_columns[0] = Column.new(column_alias, type, order, nil, false, is_frozen)
269
329
  clustering_order[0] = order
270
330
  end
271
331
 
272
332
  if is_dense
273
333
  value_alias = table['value_alias']
274
334
  value_alias = 'value' if value_alias.nil? || value_alias.empty?
275
- type, order = @type_parser.parse(table['default_validator']).results.first
276
- other_columns << Column.new(value_alias, type, order)
335
+ type, order, is_frozen = @type_parser.parse(table['default_validator']).results.first
336
+ other_columns << Column.new(value_alias, type, order, nil, false, is_frozen)
277
337
  end
278
338
 
279
339
  columns.each do |name, row|
@@ -316,7 +376,7 @@ module Cassandra
316
376
 
317
377
  def create_column(column)
318
378
  name = column['column_name']
319
- type, order = @type_parser.parse(column['validator']).results.first
379
+ type, order, is_frozen = @type_parser.parse(column['validator']).results.first
320
380
  is_static = (column['type'] == 'STATIC')
321
381
 
322
382
  if column['index_type'].nil?
@@ -328,7 +388,7 @@ module Cassandra
328
388
  index = Column::Index.new(column['index_name'], options['class_name'])
329
389
  end
330
390
 
331
- Column.new(name, type, order, index, is_static)
391
+ Column.new(name, type, order, index, is_static, is_frozen)
332
392
  end
333
393
 
334
394
  def deephash
@@ -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.
@@ -36,7 +36,7 @@ module Cassandra
36
36
  "org.apache.cassandra.db.marshal.FloatType" => :float,
37
37
  "org.apache.cassandra.db.marshal.InetAddressType" => :inet,
38
38
  "org.apache.cassandra.db.marshal.Int32Type" => :int,
39
- "org.apache.cassandra.db.marshal.UTF8Type" => :text,
39
+ "org.apache.cassandra.db.marshal.UTF8Type" => :varchar,
40
40
  "org.apache.cassandra.db.marshal.TimestampType" => :timestamp,
41
41
  "org.apache.cassandra.db.marshal.DateType" => :timestamp,
42
42
  "org.apache.cassandra.db.marshal.UUIDType" => :uuid,
@@ -44,7 +44,9 @@ module Cassandra
44
44
  "org.apache.cassandra.db.marshal.TimeUUIDType" => :timeuuid,
45
45
  "org.apache.cassandra.db.marshal.MapType" => :map,
46
46
  "org.apache.cassandra.db.marshal.SetType" => :set,
47
- "org.apache.cassandra.db.marshal.ListType" => :list
47
+ "org.apache.cassandra.db.marshal.ListType" => :list,
48
+ "org.apache.cassandra.db.marshal.UserType" => :udt,
49
+ "org.apache.cassandra.db.marshal.TupleType" => :tuple
48
50
  }.freeze
49
51
 
50
52
  def parse(string)
@@ -85,26 +87,51 @@ module Cassandra
85
87
  end
86
88
 
87
89
  def create_type(node)
88
- order = :asc
90
+ order = :asc
91
+ frozen = false
89
92
 
90
93
  if node.name == "org.apache.cassandra.db.marshal.ReversedType"
91
94
  order = :desc
92
95
  node = node.children.first
93
96
  end
94
97
 
95
- [lookup_type(node), order]
98
+ if node.name == "org.apache.cassandra.db.marshal.FrozenType"
99
+ frozen = true
100
+ node = node.children.first
101
+ end
102
+
103
+ [lookup_type(node), order, frozen]
96
104
  end
97
105
 
98
106
  def lookup_type(node)
107
+ if node.name == "org.apache.cassandra.db.marshal.FrozenType"
108
+ return lookup_type(node.children.first)
109
+ end
110
+
99
111
  type = @@types[node.name]
100
112
 
101
113
  case type
102
114
  when :set, :list
103
- [type, lookup_type(node.children.first)]
115
+ Cassandra::Types.send(type, lookup_type(node.children.first))
104
116
  when :map
105
- [type, *node.children.map {|child| lookup_type(child)}]
117
+ Cassandra::Types.map(*node.children.map(&method(:lookup_type)))
118
+ when :udt
119
+ keyspace = node.children.shift.name
120
+ name = [node.children.shift.name].pack('H*')
121
+ fields = node.children.map do |child|
122
+ field_name, child_name = child.name.split(":")
123
+
124
+ child.name = child_name
125
+ field_name = [field_name].pack('H*').force_encoding(::Encoding::UTF_8)
126
+
127
+ [field_name, lookup_type(child)]
128
+ end
129
+
130
+ Cassandra::Types.udt(keyspace, name, fields)
131
+ when :tuple
132
+ Cassandra::Types.tuple(*node.children.map(&method(:lookup_type)))
106
133
  else
107
- type
134
+ Cassandra::Types.send(type)
108
135
  end
109
136
  end
110
137
 
@@ -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.
@@ -37,25 +37,22 @@ module Cassandra
37
37
 
38
38
  # @return [String] column name
39
39
  attr_reader :name
40
- # @private
41
- # @return [Symbol, Array(Symbol, Symbol)] column type
40
+ # @return [Cassandra::Type] column type
42
41
  attr_reader :type
43
42
  # @return [Symbol] column order (`:asc` or `:desc`)
44
43
  attr_reader :order
45
44
  # @private
46
45
  # @return [Cassandra::Column::Index, nil] column index
47
46
  attr_reader :index
48
- # @private
49
- # @return [Boolean] whether the column is static
50
- attr_reader :static
51
47
 
52
48
  # @private
53
- def initialize(name, type, order, index = nil, is_static = false)
49
+ def initialize(name, type, order, index = nil, is_static = false, is_frozen = false)
54
50
  @name = name
55
51
  @type = type
56
52
  @order = order
57
53
  @index = index
58
54
  @static = is_static
55
+ @frozen = is_frozen
59
56
  end
60
57
 
61
58
  # @return [Boolean] whether the column is static
@@ -63,16 +60,14 @@ module Cassandra
63
60
  @static
64
61
  end
65
62
 
66
- # @return [String] a cql representation of this column
67
- def to_cql
68
- cql = "#{@name} #{Util.type_to_cql(@type)}"
69
- cql << ' static' if @static
70
- cql
63
+ # @return [Boolean] whether the column is frozen
64
+ def frozen?
65
+ @frozen
71
66
  end
72
67
 
73
68
  # @return [String] a CLI-friendly column representation
74
69
  def inspect
75
- "#<#{self.class.name}:0x#{self.object_id.to_s(16)} @name=#{@name}>"
70
+ "#<#{self.class.name}:0x#{self.object_id.to_s(16)} @name=#{@name} @type=#{@type}>"
76
71
  end
77
72
 
78
73
  # @return [Boolean] whether this column is equal to the other
@@ -82,7 +77,8 @@ module Cassandra
82
77
  @type == other.type &&
83
78
  @order == other.order &&
84
79
  @index == other.index &&
85
- @static == other.static?
80
+ @static == other.static? &&
81
+ @frozen == other.frozen?
86
82
  end
87
83
  alias :== :eql?
88
84
  end