cassandra 0.18.0 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f0a23f0b09b8e2fa2d98f2d5f1574f1014089a04
4
+ data.tar.gz: 4bd4c264e1b03836219ae41b06ad5bf4ff275f73
5
+ SHA512:
6
+ metadata.gz: 3dfe8d4d0adfbc7b99c2154bf3abb7997fa492169e77ffa9b629f65630acfaecbbe86f2a6d89ad45717dc1e2d28dbf8a1042b526b6d9df4428d0cb8f7213f897
7
+ data.tar.gz: 9db54828890bda117a3db3c094b8238fa092c6f894f226ef76b1788fb8ca47836fb3f9a1dca8f67c2865e5c705b1d916b68d4e6c16e15cd7b503369d8d01bcab
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ v0.19.0
2
+ - Fixed windows build by disabling native extensions (issue #188, courtesy @jacek99)
3
+ - Speed improvement to native composite column extension (issue #186, courtesy @muirmanders)
4
+ - Fix OrderedHash iterator return values (issue #185, courtesy @fester)
5
+ - Native support for dynamic composite decoding (issue #184, courtesy @muirmanders)
6
+
1
7
  v0.18.0
2
8
  - Cassandra 1.2 support (issue #175, courtesy @brainopia)
3
9
  - drop_keyspace defaults to current keyspace (issue #176, courtesy @brianopia)
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "cassandra"
5
- s.version = "0.18.0"
5
+ s.version = "0.19.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"]
@@ -1,10 +1,9 @@
1
1
  #include <ruby.h>
2
2
  #include <arpa/inet.h>
3
3
 
4
- VALUE parts_ivar_id;
4
+ VALUE parts_ivar_id, types_ivar_id, hash_ivar_id;
5
5
 
6
6
  VALUE rb_cassandra_composite_fast_unpack(VALUE self, VALUE packed_string_value) {
7
- int i = 0;
8
7
  int index = 0;
9
8
  int message_length = RSTRING_LEN(packed_string_value);
10
9
  char *packed_string = (char *)RSTRING_PTR(packed_string_value);
@@ -12,15 +11,46 @@ VALUE rb_cassandra_composite_fast_unpack(VALUE self, VALUE packed_string_value)
12
11
  VALUE parts = rb_ary_new();
13
12
  while (index < message_length) {
14
13
  uint16_t length = ntohs(((uint16_t *)(packed_string+index))[0]);
15
- VALUE part = rb_str_new("", length);
16
- for (i = 0; i < length; i++) {
17
- ((char *)RSTRING_PTR(part))[i] = packed_string[index+2+i];
14
+ VALUE part = rb_str_new(packed_string+index+2, length);
15
+ rb_ary_push(parts, part);
16
+ index += length + 3;
17
+ }
18
+
19
+ rb_ivar_set(self, parts_ivar_id, parts);
20
+ rb_ivar_set(self, hash_ivar_id, rb_funcall(packed_string_value, rb_intern("hash"), 0));
21
+
22
+ return Qnil;
23
+ }
24
+
25
+ VALUE rb_cassandra_dynamic_composite_fast_unpack(VALUE self, VALUE packed_string_value) {
26
+ int index = 0;
27
+ int message_length = RSTRING_LEN(packed_string_value);
28
+ char *packed_string = (char *)RSTRING_PTR(packed_string_value);
29
+ uint16_t length;
30
+
31
+ VALUE parts = rb_ary_new();
32
+ VALUE types = rb_ary_new();
33
+ while (index < message_length) {
34
+ if (packed_string[index] & 0x80) {
35
+ VALUE type = rb_str_new(packed_string + index + 1, 1);
36
+ rb_ary_push(types, type);
37
+ index += 2;
38
+ } else {
39
+ length = ntohs(((uint16_t *)(packed_string+index))[0]);
40
+ VALUE type = rb_str_new(packed_string + index + 2, length);
41
+ rb_ary_push(types, type);
42
+ index += 2 + length;
18
43
  }
44
+
45
+ length = ntohs(((uint16_t *)(packed_string+index))[0]);
46
+ VALUE part = rb_str_new(packed_string + index + 2, length);
19
47
  rb_ary_push(parts, part);
20
48
  index += length + 3;
21
49
  }
22
50
 
23
51
  rb_ivar_set(self, parts_ivar_id, parts);
52
+ rb_ivar_set(self, types_ivar_id, types);
53
+ rb_ivar_set(self, hash_ivar_id, rb_funcall(packed_string_value, rb_intern("hash"), 0));
24
54
 
25
55
  return Qnil;
26
56
  }
@@ -30,5 +60,10 @@ void Init_cassandra_native(void) {
30
60
  VALUE cassandra_composite_class = rb_define_class_under(cassandra_module, "Composite", rb_cObject);
31
61
  rb_define_method(cassandra_composite_class, "fast_unpack", rb_cassandra_composite_fast_unpack, 1);
32
62
 
63
+ VALUE dynamic_composite = rb_const_get(cassandra_module, rb_intern("DynamicComposite"));
64
+ rb_define_method(dynamic_composite, "fast_unpack", rb_cassandra_dynamic_composite_fast_unpack, 1);
65
+
33
66
  parts_ivar_id = rb_intern("@parts");
67
+ types_ivar_id = rb_intern("@types");
68
+ hash_ivar_id = rb_intern("@hash");
34
69
  }
@@ -1,4 +1,4 @@
1
- if defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/
1
+ if (defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/) or ENV['OS'] == "Windows_NT"
2
2
  File.open('Makefile', 'w'){|f| f.puts "all:\n\ninstall:\n" }
3
3
  else
4
4
  require 'mkmf'
@@ -39,3 +39,9 @@ unless Cassandra.VERSION.eql?("0.6")
39
39
  end
40
40
  require 'cassandra/constants'
41
41
  require 'cassandra/debug' if ENV['DEBUG']
42
+
43
+ begin
44
+ require "cassandra_native"
45
+ rescue LoadError
46
+ puts "Unable to load cassandra_native extension. Defaulting to pure Ruby libraries."
47
+ end
@@ -20,7 +20,7 @@ class Cassandra
20
20
  @column_name_maker[column_family] ||=
21
21
  begin
22
22
  klass = column_name_class(column_family)
23
- if klass == Composite
23
+ if klass == Composite || klass == DynamicComposite
24
24
  lambda {|name| klass.new_from_packed(name) }
25
25
  else
26
26
  lambda {|name| klass.new(name) }
@@ -32,7 +32,7 @@ class Cassandra
32
32
  @sub_column_name_maker[column_family] ||=
33
33
  begin
34
34
  klass = sub_column_name_class(column_family)
35
- if klass == Composite
35
+ if klass == Composite || klass == DynamicComposite
36
36
  lambda {|name| klass.new_from_packed(name) }
37
37
  else
38
38
  lambda {|name| klass.new(name) }
@@ -132,9 +132,3 @@ class Cassandra
132
132
  end
133
133
  end
134
134
  end
135
-
136
- begin
137
- require "cassandra_native"
138
- rescue LoadError
139
- puts "Unable to load cassandra_native extension. Defaulting to pure Ruby libraries."
140
- end
@@ -45,9 +45,31 @@ class Cassandra
45
45
  end
46
46
 
47
47
  def fast_unpack(packed_string)
48
- result = try_packed_composite(packed_string)
49
- raise ArgumentError.new("Invalid DynamicComposite column") if !result
50
48
  @hash = packed_string.hash
49
+
50
+ @types = []
51
+ @parts = []
52
+
53
+ offset = 0
54
+ length = nil
55
+ while offset < packed_string.length
56
+ if packed_string[offset].ord & 0x80 != 0
57
+ @types << packed_string[offset+1]
58
+ offset += 2
59
+ else
60
+ length = packed_string.slice(offset, 2).unpack('n')[0]
61
+ offset += 2
62
+ @types << packed_string.slice(offset, length)
63
+ offset += length
64
+ end
65
+ length = packed_string.slice(offset, 2).unpack('n')[0]
66
+ offset += 2
67
+ @parts << packed_string.slice(offset, length)
68
+ offset += length + 1
69
+ end
70
+
71
+ @column_slice = :after if packed_string[-1] == "\x01"
72
+ @column_slice = :before if packed_string[-1] == "\xFF"
51
73
  end
52
74
 
53
75
  private
@@ -83,14 +83,17 @@ class Cassandra
83
83
 
84
84
  def each_key
85
85
  @keys.each { |key| yield key }
86
+ self
86
87
  end
87
88
 
88
89
  def each_value
89
90
  @keys.each { |key| yield self[key]}
91
+ self
90
92
  end
91
93
 
92
94
  def each
93
95
  @keys.each {|key| yield [key, self[key]]}
96
+ self
94
97
  end
95
98
 
96
99
  alias_method :each_pair, :each
@@ -93,6 +93,13 @@ class CassandraTest < Test::Unit::TestCase
93
93
  assert_not_equal(hash.keys, @twitter.get(:Users, key).keys)
94
94
  end
95
95
 
96
+ def test_ordered_hash_iteration_functions_return_values
97
+ hash = OrderedHash['a', '', 'b', '', 'c', '', 'd', '',]
98
+ assert_instance_of OrderedHash, hash.each{|_| true}
99
+ assert_instance_of OrderedHash, hash.each_value{|_| true}
100
+ assert_instance_of OrderedHash, hash.each_key{|_| true}
101
+ end
102
+
96
103
  def test_get_first_time_uuid_column
97
104
  @blogs.insert(:Blogs, key,
98
105
  {@uuids[0] => 'I like this cat', @uuids[1] => 'Buttons is cuter', @uuids[2] => 'I disagree'})
@@ -29,6 +29,14 @@ class CompositeTypesTest < Test::Unit::TestCase
29
29
  def test_packing_and_unpacking
30
30
  assert_equal(@part0_length + @part1_length + @part2_length, @col.pack.length)
31
31
 
32
+ col2 = Cassandra::Composite.new_from_packed(@col.pack)
33
+ assert_equal(@col_parts[0], col2[0])
34
+ assert_equal(@col_parts[1], col2[1])
35
+ assert_equal(@col_parts[2], col2[2])
36
+ assert_equal(@col, col2)
37
+ # make sure we set this while we have the packed string handy
38
+ assert_equal(@col.pack.hash, col2.instance_variable_get(:@hash))
39
+
32
40
  col2 = Cassandra::Composite.new(@col.pack)
33
41
  assert_equal(@col_parts[0], col2[0])
34
42
  assert_equal(@col_parts[1], col2[1])
@@ -42,6 +50,14 @@ class CompositeTypesTest < Test::Unit::TestCase
42
50
  part2_length = @part2_length + 2 + @types[2].length
43
51
  assert_equal(part0_length + part1_length + part2_length, @dycol.pack.length)
44
52
 
53
+ col2 = Cassandra::DynamicComposite.new_from_packed(@dycol.pack)
54
+ assert_equal(@col_parts[0], col2[0])
55
+ assert_equal(@col_parts[1], col2[1])
56
+ assert_equal(@col_parts[2], col2[2])
57
+ assert_equal(@dycol, col2)
58
+ # make sure we set this while we have the packed string handy
59
+ assert_equal(@dycol.pack.hash, col2.instance_variable_get(:@hash))
60
+
45
61
  col2 = Cassandra::DynamicComposite.new(@dycol.pack)
46
62
  assert_equal(@col_parts[0], col2[0])
47
63
  assert_equal(@col_parts[1], col2[1])
@@ -55,6 +71,12 @@ class CompositeTypesTest < Test::Unit::TestCase
55
71
  part2_length = @part2_length + 2
56
72
  assert_equal(part0_length + part1_length + part2_length, @dycol_alias.pack.length)
57
73
 
74
+ col2 = Cassandra::DynamicComposite.new_from_packed(@dycol_alias.pack)
75
+ assert_equal(@col_parts[0], col2[0])
76
+ assert_equal(@col_parts[1], col2[1])
77
+ assert_equal(@col_parts[2], col2[2])
78
+ assert_equal(@dycol_alias, col2)
79
+
58
80
  col2 = Cassandra::DynamicComposite.new(@dycol_alias.pack)
59
81
  assert_equal(@col_parts[0], col2[0])
60
82
  assert_equal(@col_parts[1], col2[1])
metadata CHANGED
@@ -1,99 +1,98 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: cassandra
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 18
8
- - 0
9
- version: 0.18.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.19.0
10
5
  platform: ruby
11
- authors:
6
+ authors:
12
7
  - Evan Weaver, Ryan King
13
8
  autorequire:
14
9
  bindir: bin
15
10
  cert_chain: []
16
-
17
- date: 2012-09-26 00:00:00 -07:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
11
+ date: 2012-09-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
21
14
  name: thrift_client
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
25
17
  - - <
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
- - 9
30
- version: "0.9"
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- segments:
34
- - 0
35
- - 7
36
- - 0
18
+ - !ruby/object:Gem::Version
19
+ version: '0.9'
20
+ - - '>='
21
+ - !ruby/object:Gem::Version
37
22
  version: 0.7.0
38
23
  type: :runtime
39
- version_requirements: *id001
40
- - !ruby/object:Gem::Dependency
41
- name: json
42
24
  prerelease: false
43
- requirement: &id002 !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- segments:
48
- - 0
49
- version: "0"
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - <
28
+ - !ruby/object:Gem::Version
29
+ version: '0.9'
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 0.7.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: json
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
50
40
  type: :runtime
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- name: rake
54
41
  prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- segments:
60
- - 0
61
- version: "0"
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
62
54
  type: :runtime
63
- version_requirements: *id003
64
- - !ruby/object:Gem::Dependency
65
- name: simple_uuid
66
55
  prerelease: false
67
- requirement: &id004 !ruby/object:Gem::Requirement
68
- requirements:
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: simple_uuid
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
69
65
  - - ~>
70
- - !ruby/object:Gem::Version
71
- segments:
72
- - 0
73
- - 2
74
- - 0
66
+ - !ruby/object:Gem::Version
75
67
  version: 0.2.0
76
68
  type: :runtime
77
- version_requirements: *id004
78
- - !ruby/object:Gem::Dependency
79
- name: echoe
80
69
  prerelease: false
81
- requirement: &id005 !ruby/object:Gem::Requirement
82
- requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- segments:
86
- - 0
87
- version: "0"
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ~>
73
+ - !ruby/object:Gem::Version
74
+ version: 0.2.0
75
+ - !ruby/object:Gem::Dependency
76
+ name: echoe
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
88
82
  type: :development
89
- version_requirements: *id005
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
90
89
  description: A Ruby client for the Cassandra distributed database.
91
- email: ""
92
- executables:
90
+ email: ''
91
+ executables:
93
92
  - cassandra_helper
94
- extensions:
93
+ extensions:
95
94
  - ext/extconf.rb
96
- extra_rdoc_files:
95
+ extra_rdoc_files:
97
96
  - CHANGELOG
98
97
  - LICENSE
99
98
  - README.md
@@ -138,7 +137,7 @@ extra_rdoc_files:
138
137
  - lib/cassandra/ordered_hash.rb
139
138
  - lib/cassandra/protocol.rb
140
139
  - lib/cassandra/time.rb
141
- files:
140
+ files:
142
141
  - CHANGELOG
143
142
  - Gemfile
144
143
  - LICENSE
@@ -234,44 +233,37 @@ files:
234
233
  - vendor/1.1/gen-rb/cassandra_constants.rb
235
234
  - vendor/1.1/gen-rb/cassandra_types.rb
236
235
  - cassandra.gemspec
237
- has_rdoc: true
238
236
  homepage: http://github.com/twitter/cassandra
239
237
  licenses: []
240
-
238
+ metadata: {}
241
239
  post_install_message:
242
- rdoc_options:
240
+ rdoc_options:
243
241
  - --line-numbers
244
242
  - --inline-source
245
243
  - --title
246
244
  - Cassandra
247
245
  - --main
248
246
  - README.md
249
- require_paths:
247
+ require_paths:
250
248
  - lib
251
249
  - ext
252
- required_ruby_version: !ruby/object:Gem::Requirement
253
- requirements:
254
- - - ">="
255
- - !ruby/object:Gem::Version
256
- segments:
257
- - 0
258
- version: "0"
259
- required_rubygems_version: !ruby/object:Gem::Requirement
260
- requirements:
261
- - - ">="
262
- - !ruby/object:Gem::Version
263
- segments:
264
- - 0
265
- - 8
266
- version: "0.8"
250
+ required_ruby_version: !ruby/object:Gem::Requirement
251
+ requirements:
252
+ - - '>='
253
+ - !ruby/object:Gem::Version
254
+ version: '0'
255
+ required_rubygems_version: !ruby/object:Gem::Requirement
256
+ requirements:
257
+ - - '>='
258
+ - !ruby/object:Gem::Version
259
+ version: '0.8'
267
260
  requirements: []
268
-
269
261
  rubyforge_project: cassandra
270
- rubygems_version: 1.3.6
262
+ rubygems_version: 2.0.3
271
263
  signing_key:
272
264
  specification_version: 3
273
265
  summary: A Ruby client for the Cassandra distributed database.
274
- test_files:
266
+ test_files:
275
267
  - test/cassandra_client_test.rb
276
268
  - test/cassandra_mock_test.rb
277
269
  - test/cassandra_test.rb