cassandra 0.21.0 → 0.22.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e09d9ef5ec124d616ed409e7b58f318a648b27c
4
- data.tar.gz: 9b02d2de7fb9665de9da5a669182afd59dd86b68
3
+ metadata.gz: 5daf0bcf89a1be06c7a378c60ee41c037e2a5c23
4
+ data.tar.gz: f054a9ea46806ebaae4cf3d24602eb3a1462e942
5
5
  SHA512:
6
- metadata.gz: a5b30fed29b2e3f77f9ffa3d9ff732c1b7518547beca98d5475098dbc108ed0d354613ae73c77c24b32bc1884df8c1d8dc4e80de16ff973fee7297fb66b46512
7
- data.tar.gz: f4dd071c59d3d8cbafcfa27a0cb7316fedbb98f71a0883a891a1cdae5959bad823c025b00f274fd323073d883ee47feb263c4b79538f484faf9ce35c557cca19
6
+ metadata.gz: ac367f6fe75340bae0019c46c59415bb541d1df7cef5d45bc49bde9b4beed9c6d759f49077c761ed0eedced549104bab13ac8239cd85d2087c618c6468d37cb7
7
+ data.tar.gz: 62b7dfa25c51cafdd5426e4c4e1b156ee5d107ee3c86e54e8cbd770cbb1651d85fe41d035e223c7337c293c657f6826bf918d53aba5800fcd36f39a9e3ce36aa
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ v0.22.0
2
+ - Add new composite API to resolve ambiguity between unpacking a composite and packing a composite with one element (issue #196, courtesy @kevinkehl)
3
+ - Breaking change: schema change methods no longer catch exceptions internally. They work the same as everything else.
4
+
1
5
  v0.21.0
2
6
  - Add 1.2 libs to gem
3
7
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "cassandra"
5
- s.version = "0.21.0"
5
+ s.version = "0.22.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0.8") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Evan Weaver, Ryan King"]
@@ -269,13 +269,8 @@ class Cassandra
269
269
  def add_column_family(cf_def)
270
270
  return false if Cassandra.VERSION.to_f < 0.7
271
271
 
272
- begin
273
- res = client.system_add_column_family(cf_def)
274
- rescue CassandraThrift::TimedOutException => te
275
- puts "Timed out: #{te.inspect}"
276
- end
277
272
  @schema = nil
278
- res
273
+ return client.system_add_column_family(cf_def)
279
274
  end
280
275
 
281
276
  ##
@@ -286,13 +281,8 @@ class Cassandra
286
281
  def drop_column_family(column_family)
287
282
  return false if Cassandra.VERSION.to_f < 0.7
288
283
 
289
- begin
290
- res = client.system_drop_column_family(column_family)
291
- rescue CassandraThrift::TimedOutException => te
292
- puts "Timed out: #{te.inspect}"
293
- end
294
284
  @schema = nil
295
- res
285
+ return client.system_drop_column_family(column_family)
296
286
  end
297
287
 
298
288
  ##
@@ -304,13 +294,8 @@ class Cassandra
304
294
  def rename_column_family(old_name, new_name)
305
295
  return false if Cassandra.VERSION.to_f != 0.7
306
296
 
307
- begin
308
- res = client.system_rename_column_family(old_name, new_name)
309
- rescue CassandraThrift::TimedOutException => te
310
- puts "Timed out: #{te.inspect}"
311
- end
312
297
  @schema = nil
313
- res
298
+ return client.system_rename_column_family(old_name, new_name)
314
299
  end
315
300
 
316
301
  ##
@@ -319,13 +304,8 @@ class Cassandra
319
304
  def update_column_family(cf_def)
320
305
  return false if Cassandra.VERSION.to_f < 0.7
321
306
 
322
- begin
323
- res = client.system_update_column_family(cf_def)
324
- rescue CassandraThrift::TimedOutException => te
325
- puts "Timed out: #{te.inspect}"
326
- end
327
307
  @schema = nil
328
- res
308
+ return client.system_update_column_family(cf_def)
329
309
  end
330
310
 
331
311
  ##
@@ -336,15 +316,8 @@ class Cassandra
336
316
  def add_keyspace(ks_def)
337
317
  return false if Cassandra.VERSION.to_f < 0.7
338
318
 
339
- begin
340
- res = client.system_add_keyspace(ks_def)
341
- rescue CassandraThrift::TimedOutException => toe
342
- puts "Timed out: #{toe.inspect}"
343
- rescue Thrift::TransportException => te
344
- puts "Timed out: #{te.inspect}"
345
- end
346
319
  @keyspaces = nil
347
- res
320
+ return client.system_add_keyspace(ks_def)
348
321
  end
349
322
 
350
323
  ##
@@ -355,16 +328,10 @@ class Cassandra
355
328
  def drop_keyspace(keyspace=@keyspace)
356
329
  return false if Cassandra.VERSION.to_f < 0.7
357
330
 
358
- begin
359
- res = client.system_drop_keyspace(keyspace)
360
- rescue CassandraThrift::TimedOutException => toe
361
- puts "Timed out: #{toe.inspect}"
362
- rescue Thrift::TransportException => te
363
- puts "Timed out: #{te.inspect}"
364
- end
365
- keyspace = "system" if keyspace.eql?(@keyspace)
366
331
  @keyspaces = nil
367
- res
332
+ ret = client.system_drop_keyspace(keyspace)
333
+ keyspace = "system" if keyspace.eql?(@keyspace)
334
+ return ret
368
335
  end
369
336
 
370
337
  ##
@@ -377,16 +344,10 @@ class Cassandra
377
344
  def rename_keyspace(old_name, new_name)
378
345
  return false if Cassandra.VERSION.to_f < 0.7
379
346
 
380
- begin
381
- res = client.system_rename_keyspace(old_name, new_name)
382
- rescue CassandraThrift::TimedOutException => toe
383
- puts "Timed out: #{toe.inspect}"
384
- rescue Thrift::TransportException => te
385
- puts "Timed out: #{te.inspect}"
386
- end
387
- keyspace = new_name if old_name.eql?(@keyspace)
388
347
  @keyspaces = nil
389
- res
348
+ ret = client.system_rename_keyspace(old_name, new_name)
349
+ keyspace = new_name if old_name.eql?(@keyspace)
350
+ return ret
390
351
  end
391
352
 
392
353
  ##
@@ -395,15 +356,8 @@ class Cassandra
395
356
  def update_keyspace(ks_def)
396
357
  return false if Cassandra.VERSION.to_f < 0.7
397
358
 
398
- begin
399
- res = client.system_update_keyspace(ks_def)
400
- rescue CassandraThrift::TimedOutException => toe
401
- puts "Timed out: #{toe.inspect}"
402
- rescue Thrift::TransportException => te
403
- puts "Timed out: #{te.inspect}"
404
- end
405
359
  @keyspaces = nil
406
- res
360
+ return client.system_update_keyspace(ks_def)
407
361
  end
408
362
  ##
409
363
  # The initial default consistency is set to ONE, but you can use this method
@@ -11,16 +11,13 @@ class Cassandra
11
11
  if parts.last.is_a?(Hash)
12
12
  options = parts.pop
13
13
  end
14
- @column_slice = options[:slice]
15
- raise ArgumentError if @column_slice != nil && ![:before, :after].include?(@column_slice)
16
14
 
17
15
  if parts.length == 1 && parts[0].instance_of?(self.class)
18
- @column_slice = parts[0].column_slice
19
- @parts = parts[0].parts
16
+ make_from_parts(parts[0].parts, :slice => parts[0].column_slice)
20
17
  elsif parts.length == 1 && parts[0].instance_of?(String) && @column_slice.nil? && try_packed_composite(parts[0])
21
18
  @hash = parts[0].hash
22
19
  else
23
- @parts = parts
20
+ make_from_parts(parts, options)
24
21
  end
25
22
  end
26
23
 
@@ -30,6 +27,13 @@ class Cassandra
30
27
  return obj
31
28
  end
32
29
 
30
+ def self.new_from_parts(parts, args={})
31
+ obj = new
32
+ obj.make_from_parts(parts, args)
33
+
34
+ return obj
35
+ end
36
+
33
37
  def [](*args)
34
38
  return @parts[*args]
35
39
  end
@@ -102,6 +106,12 @@ class Cassandra
102
106
  @column_slice = :before if end_of_component == "\xFF"
103
107
  end
104
108
 
109
+ def make_from_parts(parts, args)
110
+ @parts = parts
111
+ @column_slice = args[:slice]
112
+ raise ArgumentError if @column_slice != nil && ![:before, :after].include?(@column_slice)
113
+ end
114
+
105
115
  private
106
116
  def try_packed_composite(packed_string)
107
117
  parts = []
@@ -1244,6 +1244,9 @@ class CassandraTest < Test::Unit::TestCase
1244
1244
 
1245
1245
  def test_composite_column_type_conversion
1246
1246
  columns = {}
1247
+ @composites.push(
1248
+ Cassandra::Composite.new_from_parts([[20].pack('N'), "meerkat"])
1249
+ )
1247
1250
  @composites.each_with_index do |c, index|
1248
1251
  columns[c] = "value-#{index}"
1249
1252
  end
@@ -1253,12 +1256,13 @@ class CassandraTest < Test::Unit::TestCase
1253
1256
  Cassandra::Composite.new([5].pack('N'), "aardvark"),
1254
1257
  Cassandra::Composite.new([5].pack('N'), "zebra"),
1255
1258
  Cassandra::Composite.new([10].pack('N'), "kangaroo"),
1259
+ Cassandra::Composite.new([20].pack('N'), "meerkat"),
1256
1260
  ]
1257
1261
  assert_equal(columns_in_order, @type_conversions.get(:CompositeColumnConversion, key).keys)
1258
1262
 
1259
1263
  column_slice = @type_conversions.get(:CompositeColumnConversion, key,
1260
1264
  :start => Cassandra::Composite.new([1].pack('N')),
1261
- :finish => Cassandra::Composite.new([10].pack('N'))
1265
+ :finish => Cassandra::Composite.new([20].pack('N'))
1262
1266
  ).keys
1263
1267
  assert_equal(columns_in_order[0..-2], column_slice)
1264
1268
 
@@ -1271,12 +1275,12 @@ class CassandraTest < Test::Unit::TestCase
1271
1275
  column_slice = @type_conversions.get(:CompositeColumnConversion, key,
1272
1276
  :start => Cassandra::Composite.new([5].pack('N'), :slice => :after).to_s
1273
1277
  ).keys
1274
- assert_equal([columns_in_order[-1]], column_slice)
1278
+ assert_equal(columns_in_order[-2..-1], column_slice)
1275
1279
 
1276
1280
  column_slice = @type_conversions.get(:CompositeColumnConversion, key,
1277
1281
  :finish => Cassandra::Composite.new([10].pack('N'), :slice => :before).to_s
1278
1282
  ).keys
1279
- assert_equal(columns_in_order[0..-2], column_slice)
1283
+ assert_equal(columns_in_order[0..-3], column_slice)
1280
1284
 
1281
1285
  assert_equal('value-2', @type_conversions.get(:CompositeColumnConversion, key, columns_in_order.first))
1282
1286
  end
@@ -24,6 +24,11 @@ class CompositeTypesTest < Test::Unit::TestCase
24
24
  assert_equal(@col_parts[i], @dycol[i])
25
25
  assert_equal(@col_parts[i], @dycol_alias[i])
26
26
  end
27
+
28
+ col2 = Cassandra::Composite.new_from_parts(@col_parts)
29
+ (0..2).each do |i|
30
+ assert_equal(@col_parts[i], col2[i].to_s)
31
+ end
27
32
  end
28
33
 
29
34
  def test_packing_and_unpacking
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cassandra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.0
4
+ version: 0.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Weaver, Ryan King
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-06 00:00:00.000000000 Z
11
+ date: 2013-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thrift_client