cassandra 0.7.2 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ v0.7.4 Fix thrift_client dependency
2
+
3
+ v0.7.3 New Cassandra::Mock - a pure ruby mock of cassanra; bugfixes.
4
+
1
5
  v0.7.2 Switch to newly-extraced simple_uuid gem, minor bugfixes.
2
6
 
3
7
  v0.7.1 update thrift-generated code to 0.5
data/Manifest CHANGED
@@ -1,7 +1,7 @@
1
1
  CHANGELOG
2
2
  LICENSE
3
3
  Manifest
4
- README.mkd
4
+ README.rdoc
5
5
  Rakefile
6
6
  bin/cassandra_helper
7
7
  conf/cassandra.in.sh
@@ -1,20 +1,20 @@
1
- # cassandra
1
+ = cassandra
2
2
 
3
3
  A Ruby client for the Cassandra distributed database.
4
4
 
5
- ## License
5
+ == License
6
6
 
7
7
  Copyright 2009 Twitter, Inc. See included LICENSE file. Portions copyright 2004-2009 David Heinemeier Hansson, and used with permission.
8
8
 
9
- ## Features
9
+ == Features
10
10
 
11
11
  * clean encapsulation of the Thrift API
12
12
  * compatible UUID and Long classes, for GUID generation
13
13
  * Ruby 1.9 compatibility
14
14
 
15
- The Github source repository is [here](http://github.com/fauna/cassandra/). Patches and contributions are very welcome.
15
+ The Github source repository is {here}[http://github.com/fauna/cassandra/]. Patches and contributions are very welcome.
16
16
 
17
- ## Installation
17
+ == Installation
18
18
 
19
19
  You need Ruby 1.8 or 1.9. If you have those, just run:
20
20
 
@@ -28,7 +28,7 @@ A server will be installed in `$HOME/cassandra/server`, and started in debug mod
28
28
 
29
29
  WARNING: Don't use the test folder for your data, as it will get overwritten when you update the gem.
30
30
 
31
- ## Usage
31
+ == Usage
32
32
 
33
33
  Now, start IRb and require the library:
34
34
 
@@ -54,19 +54,18 @@ The returned result will always be a Cassandra::OrderedHash.
54
54
 
55
55
  See Cassandra for more methods.
56
56
 
57
- ## Configuration
57
+ == Configuration
58
58
 
59
59
  By default, cassandra is setup to listen on localhost. If you want to move your clients to another host, you're going to need to change which interface it binds to in the storage-conf.xml. You should also change the seed address.
60
60
 
61
- ## Node Auto-Discovery
61
+ == Node Auto-Discovery
62
62
 
63
63
  The list of hosts you pass to the client is only used to auto-discover all the nodes in your cluster. You don't need to give the client a list of all of your nodes.
64
64
 
65
- ## Further reading
65
+ == Further reading
66
66
 
67
- * [Up and Running With Cassandra](http://blog.evanweaver.com/articles/2009/07/06/up-and-running-with-cassandra)
67
+ * {Up and Running With Cassandra}[http://blog.evanweaver.com/articles/2009/07/06/up-and-running-with-cassandra]
68
68
 
69
- ## Reporting problems
70
-
71
- The Github issue tracker is [here](http://github.com/fauna/cassandra/issues). If you have problems with this library or Cassandra itself, please use the [cassandra-user mailing list](http://mail-archives.apache.org/mod_mbox/incubator-cassandra-user/).
69
+ == Reporting problems
72
70
 
71
+ The Github issue tracker is {here}[http://github.com/fauna/cassandra/issues]. If you have problems with this library or Cassandra itself, please use the {cassandra-user mailing list}[http://mail-archives.apache.org/mod_mbox/incubator-cassandra-user/].
data/Rakefile CHANGED
@@ -3,11 +3,11 @@ unless ENV['FROM_BIN_CASSANDRA_HELPER']
3
3
  require 'echoe'
4
4
 
5
5
  Echoe.new("cassandra") do |p|
6
- p.author = "Evan Weaver"
6
+ p.author = "Evan Weaver, Ryan King"
7
7
  p.project = "fauna"
8
8
  p.summary = "A Ruby client for the Cassandra distributed database."
9
9
  p.rubygems_version = ">= 0.8"
10
- p.dependencies = ['thrift_client', 'json', 'rake', ['simple_uuid', '>= 0.0.2']]
10
+ p.dependencies = ['thrift_client >= 0.4.0', 'json', 'rake', 'simple_uuid >= 0.1.0']
11
11
  p.ignore_pattern = /^(data|vendor\/cassandra|cassandra|vendor\/thrift)/
12
12
  p.rdoc_pattern = /^(lib|bin|tasks|ext)|^README|^CHANGELOG|^TODO|^LICENSE|^COPYING$/
13
13
  p.url = "http://blog.evanweaver.com/files/doc/fauna/cassandra/"
@@ -15,7 +15,7 @@ unless ENV['FROM_BIN_CASSANDRA_HELPER']
15
15
  end
16
16
  end
17
17
 
18
- REVISION = "450cfa10f0b82d9d5af9ffda182a5097afee402b"
18
+ REVISION = "298a0e66ba66c5d2a1e5d4a70f2f619ae3fbf72a"
19
19
 
20
20
  PATCHES = []
21
21
 
@@ -55,8 +55,8 @@ end
55
55
 
56
56
  desc "Check Git version"
57
57
  task :git do
58
- unless `git --version 2>&1` =~ /git version 1.6/
59
- puts "You need to install git 1.6."
58
+ unless `git --version 2>&1` =~ /git version 1.(6|7)/
59
+ puts "You need to install git 1.6 or 1.7"
60
60
  exit(1)
61
61
  end
62
62
  end
@@ -2,46 +2,46 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{cassandra}
5
- s.version = "0.7.2"
5
+ s.version = "0.7.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0.8") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Evan Weaver"]
8
+ s.authors = ["Evan Weaver, Ryan King"]
9
9
  s.cert_chain = ["/Users/ryan/.gemkeys/gem-public_cert.pem"]
10
- s.date = %q{2010-01-25}
10
+ s.date = %q{2010-02-19}
11
11
  s.default_executable = %q{cassandra_helper}
12
12
  s.description = %q{A Ruby client for the Cassandra distributed database.}
13
13
  s.email = %q{}
14
14
  s.executables = ["cassandra_helper"]
15
- s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README.mkd", "bin/cassandra_helper", "lib/cassandra.rb", "lib/cassandra/array.rb", "lib/cassandra/cassandra.rb", "lib/cassandra/columns.rb", "lib/cassandra/comparable.rb", "lib/cassandra/constants.rb", "lib/cassandra/debug.rb", "lib/cassandra/long.rb", "lib/cassandra/ordered_hash.rb", "lib/cassandra/protocol.rb", "lib/cassandra/time.rb"]
16
- s.files = ["CHANGELOG", "LICENSE", "Manifest", "README.mkd", "Rakefile", "bin/cassandra_helper", "conf/cassandra.in.sh", "conf/log4j.properties", "conf/storage-conf.xml", "lib/cassandra.rb", "lib/cassandra/array.rb", "lib/cassandra/cassandra.rb", "lib/cassandra/columns.rb", "lib/cassandra/comparable.rb", "lib/cassandra/constants.rb", "lib/cassandra/debug.rb", "lib/cassandra/long.rb", "lib/cassandra/ordered_hash.rb", "lib/cassandra/protocol.rb", "lib/cassandra/time.rb", "test/cassandra_test.rb", "test/comparable_types_test.rb", "test/ordered_hash_test.rb", "test/test_helper.rb", "vendor/gen-rb/cassandra.rb", "vendor/gen-rb/cassandra_constants.rb", "vendor/gen-rb/cassandra_types.rb", "cassandra.gemspec"]
15
+ s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README.rdoc", "bin/cassandra_helper", "lib/cassandra.rb", "lib/cassandra/array.rb", "lib/cassandra/cassandra.rb", "lib/cassandra/columns.rb", "lib/cassandra/comparable.rb", "lib/cassandra/constants.rb", "lib/cassandra/debug.rb", "lib/cassandra/long.rb", "lib/cassandra/ordered_hash.rb", "lib/cassandra/protocol.rb", "lib/cassandra/time.rb"]
16
+ s.files = ["CHANGELOG", "LICENSE", "Manifest", "README.rdoc", "Rakefile", "bin/cassandra_helper", "conf/cassandra.in.sh", "conf/log4j.properties", "conf/storage-conf.xml", "lib/cassandra.rb", "lib/cassandra/array.rb", "lib/cassandra/cassandra.rb", "lib/cassandra/columns.rb", "lib/cassandra/comparable.rb", "lib/cassandra/constants.rb", "lib/cassandra/debug.rb", "lib/cassandra/long.rb", "lib/cassandra/ordered_hash.rb", "lib/cassandra/protocol.rb", "lib/cassandra/time.rb", "test/cassandra_test.rb", "test/comparable_types_test.rb", "test/ordered_hash_test.rb", "test/test_helper.rb", "vendor/gen-rb/cassandra.rb", "vendor/gen-rb/cassandra_constants.rb", "vendor/gen-rb/cassandra_types.rb", "cassandra.gemspec", "test/cassandra_mock_test.rb"]
17
17
  s.homepage = %q{http://blog.evanweaver.com/files/doc/fauna/cassandra/}
18
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Cassandra", "--main", "README.mkd"]
18
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Cassandra", "--main", "README.rdoc"]
19
19
  s.require_paths = ["lib"]
20
20
  s.rubyforge_project = %q{fauna}
21
21
  s.rubygems_version = %q{1.3.5}
22
22
  s.signing_key = %q{/Users/ryan/.gemkeys/gem-private_key.pem}
23
23
  s.summary = %q{A Ruby client for the Cassandra distributed database.}
24
- s.test_files = ["test/cassandra_test.rb", "test/comparable_types_test.rb", "test/ordered_hash_test.rb", "test/test_helper.rb"]
24
+ s.test_files = ["test/cassandra_mock_test.rb", "test/cassandra_test.rb", "test/comparable_types_test.rb", "test/ordered_hash_test.rb", "test/test_helper.rb"]
25
25
 
26
26
  if s.respond_to? :specification_version then
27
27
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
28
28
  s.specification_version = 3
29
29
 
30
30
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
31
- s.add_runtime_dependency(%q<thrift_client>, [">= 0"])
31
+ s.add_runtime_dependency(%q<thrift_client>, [">= 0", "= 0.4.0"])
32
32
  s.add_runtime_dependency(%q<json>, [">= 0"])
33
33
  s.add_runtime_dependency(%q<rake>, [">= 0"])
34
- s.add_runtime_dependency(%q<simple_uuid>, [">= 0.0.2"])
34
+ s.add_runtime_dependency(%q<simple_uuid>, [">= 0", "= 0.1.0"])
35
35
  else
36
- s.add_dependency(%q<thrift_client>, [">= 0"])
36
+ s.add_dependency(%q<thrift_client>, [">= 0", "= 0.4.0"])
37
37
  s.add_dependency(%q<json>, [">= 0"])
38
38
  s.add_dependency(%q<rake>, [">= 0"])
39
- s.add_dependency(%q<simple_uuid>, [">= 0.0.2"])
39
+ s.add_dependency(%q<simple_uuid>, [">= 0", "= 0.1.0"])
40
40
  end
41
41
  else
42
- s.add_dependency(%q<thrift_client>, [">= 0"])
42
+ s.add_dependency(%q<thrift_client>, [">= 0", "= 0.4.0"])
43
43
  s.add_dependency(%q<json>, [">= 0"])
44
44
  s.add_dependency(%q<rake>, [">= 0"])
45
- s.add_dependency(%q<simple_uuid>, [">= 0.0.2"])
45
+ s.add_dependency(%q<simple_uuid>, [">= 0", "= 0.1.0"])
46
46
  end
47
47
  end
@@ -8,6 +8,8 @@ $LOAD_PATH << "#{here}/../vendor/gen-rb"
8
8
  require "#{here}/../vendor/gen-rb/cassandra"
9
9
 
10
10
  $LOAD_PATH << "#{here}"
11
+
12
+ require 'cassandra/helpers'
11
13
  require 'cassandra/array'
12
14
  require 'cassandra/time'
13
15
  require 'cassandra/comparable'
@@ -29,6 +29,7 @@ For write methods, valid option parameters are:
29
29
  class Cassandra
30
30
  include Columns
31
31
  include Protocol
32
+ include Helpers
32
33
 
33
34
  class AccessError < StandardError #:nodoc:
34
35
  end
@@ -52,7 +53,7 @@ class Cassandra
52
53
  }.freeze
53
54
 
54
55
  THRIFT_DEFAULTS = {
55
- :transport => Thrift::BufferedTransport
56
+ :transport_wrapper => Thrift::BufferedTransport
56
57
  }.freeze
57
58
 
58
59
  attr_reader :keyspace, :servers, :schema, :thrift_client_options
@@ -99,7 +100,7 @@ class Cassandra
99
100
  # a nested hash for a super column family. Supports the <tt>:consistency</tt>
100
101
  # and <tt>:timestamp</tt> options.
101
102
  def insert(column_family, key, hash, options = {})
102
- column_family, _, _, options = validate_params(column_family, key, [options], WRITE_DEFAULTS)
103
+ column_family, _, _, options = extract_and_validate_params(column_family, key, [options], WRITE_DEFAULTS)
103
104
 
104
105
  timestamp = options[:timestamp] || Time.stamp
105
106
  cfmap = hash_to_cfmap(column_family, hash, timestamp)
@@ -114,7 +115,7 @@ class Cassandra
114
115
  # path you request. Supports the <tt>:consistency</tt> and <tt>:timestamp</tt>
115
116
  # options.
116
117
  def remove(column_family, key, *columns_and_options)
117
- column_family, column, sub_column, options = validate_params(column_family, key, columns_and_options, WRITE_DEFAULTS)
118
+ column_family, column, sub_column, options = extract_and_validate_params(column_family, key, columns_and_options, WRITE_DEFAULTS)
118
119
 
119
120
  args = {:column_family => column_family}
120
121
  columns = is_super(column_family) ? {:super_column => column, :column => sub_column} : {:column => column}
@@ -149,7 +150,7 @@ class Cassandra
149
150
  # request. Supports the <tt>:consistency</tt> option.
150
151
  def count_columns(column_family, key, *columns_and_options)
151
152
  column_family, super_column, _, options =
152
- validate_params(column_family, key, columns_and_options, READ_DEFAULTS)
153
+ extract_and_validate_params(column_family, key, columns_and_options, READ_DEFAULTS)
153
154
  _count_columns(column_family, key, super_column, options[:consistency])
154
155
  end
155
156
 
@@ -165,7 +166,7 @@ class Cassandra
165
166
  # <tt>:consistency</tt> option.
166
167
  def get_columns(column_family, key, *columns_and_options)
167
168
  column_family, columns, sub_columns, options =
168
- validate_params(column_family, key, columns_and_options, READ_DEFAULTS)
169
+ extract_and_validate_params(column_family, key, columns_and_options, READ_DEFAULTS)
169
170
  _get_columns(column_family, key, columns, sub_columns, options[:consistency])
170
171
  end
171
172
 
@@ -188,7 +189,7 @@ class Cassandra
188
189
  # <tt>:start</tt>, <tt>:finish</tt>, <tt>:reversed</tt>, and <tt>:consistency</tt>.
189
190
  def multi_get(column_family, keys, *columns_and_options)
190
191
  column_family, column, sub_column, options =
191
- validate_params(column_family, keys, columns_and_options, READ_DEFAULTS)
192
+ extract_and_validate_params(column_family, keys, columns_and_options, READ_DEFAULTS)
192
193
 
193
194
  hash = _multiget(column_family, keys, column, sub_column, options[:count], options[:start], options[:finish], options[:reversed], options[:consistency])
194
195
  # Restore order
@@ -201,7 +202,7 @@ class Cassandra
201
202
  # request exists. Supports the <tt>:consistency</tt> option.
202
203
  def exists?(column_family, key, *columns_and_options)
203
204
  column_family, column, sub_column, options =
204
- validate_params(column_family, key, columns_and_options, READ_DEFAULTS)
205
+ extract_and_validate_params(column_family, key, columns_and_options, READ_DEFAULTS)
205
206
  _multiget(column_family, [key], column, sub_column, 1, nil, nil, nil, options[:consistency])[key]
206
207
  end
207
208
 
@@ -211,7 +212,7 @@ class Cassandra
211
212
  # options.
212
213
  def get_range(column_family, options = {})
213
214
  column_family, _, _, options =
214
- validate_params(column_family, "", [options], READ_DEFAULTS)
215
+ extract_and_validate_params(column_family, "", [options], READ_DEFAULTS)
215
216
  _get_range(column_family, options[:start].to_s, options[:finish].to_s, options[:count], options[:consistency])
216
217
  end
217
218
 
@@ -221,7 +222,7 @@ class Cassandra
221
222
  def count_range(column_family, options = {})
222
223
  count = 0
223
224
  l = []
224
- start_key = ''
225
+ start_key = options[:start]
225
226
  while (l = get_range(column_family, options.merge(:count => 1000, :start => start_key))).size > 0
226
227
  count += l.size
227
228
  start_key = l.last.succ
@@ -235,7 +236,7 @@ class Cassandra
235
236
  # the individual commands.
236
237
  def batch(options = {})
237
238
  _, _, _, options =
238
- validate_params(schema.keys.first, "", [options], WRITE_DEFAULTS)
239
+ extract_and_validate_params(schema.keys.first, "", [options], WRITE_DEFAULTS)
239
240
 
240
241
  @batch = []
241
242
  yield
@@ -255,47 +256,10 @@ class Cassandra
255
256
 
256
257
  private
257
258
 
258
- # Extract and validate options.
259
- # FIXME Should be done as a decorator
260
- def validate_params(column_family, keys, args, options)
261
- options = options.dup
262
- column_family = column_family.to_s
263
- # Keys
264
- [keys].flatten.each do |key|
265
- raise ArgumentError, "Key #{key.inspect} must be a String for #{calling_method}" unless key.is_a?(String)
266
- end
267
-
268
- # Options
269
- if args.last.is_a?(Hash)
270
- extras = args.last.keys - options.keys
271
- raise ArgumentError, "Invalid options #{extras.inspect[1..-2]} for #{calling_method}" if extras.any?
272
- options.merge!(args.pop)
273
- end
274
-
275
- # Ranges
276
- column, sub_column = args[0], args[1]
277
- klass, sub_klass = column_name_class(column_family), sub_column_name_class(column_family)
278
- range_class = column ? sub_klass : klass
279
- options[:start] = options[:start] ? range_class.new(options[:start]).to_s : ""
280
- options[:finish] = options[:finish] ? range_class.new(options[:finish]).to_s : ""
281
-
282
- [column_family, s_map(column, klass), s_map(sub_column, sub_klass), options]
283
- end
284
-
285
259
  def calling_method
286
260
  "#{self.class}##{caller[0].split('`').last[0..-3]}"
287
261
  end
288
262
 
289
- # Convert stuff to strings.
290
- def s_map(el, klass)
291
- case el
292
- when Array then el.map { |i| s_map(i, klass) }
293
- when NilClass then nil
294
- else
295
- klass.new(el).to_s
296
- end
297
- end
298
-
299
263
  # Roll up queued mutations, to improve atomicity.
300
264
  def compact_mutations!
301
265
  #TODO re-do this rollup
@@ -28,9 +28,10 @@ class Cassandra
28
28
  end
29
29
 
30
30
  def column_family_property(column_family, key)
31
+ unless schema[column_family]
32
+ raise AccessError, "Invalid column family \"#{column_family}\""
33
+ end
31
34
  schema[column_family][key]
32
- rescue NoMethodError
33
- raise AccessError, "Invalid column family \"#{column_family}\""
34
35
  end
35
36
 
36
37
  def multi_column_to_hash!(hash)
@@ -2,7 +2,7 @@
2
2
  class Cassandra
3
3
  # A temporally-ordered Long class for use in Cassandra column names
4
4
  class Long < Comparable
5
-
5
+
6
6
  # FIXME Should unify with or subclass Cassandra::UUID
7
7
  def initialize(bytes = nil)
8
8
  case bytes
@@ -15,7 +15,7 @@ class Cassandra
15
15
  when 18 # Human-readable UUID-like representation; inverse of #to_guid
16
16
  elements = bytes.split("-")
17
17
  raise TypeError, "Expected #{bytes.inspect} to cast to a #{self.class} (malformed UUID-like representation)" if elements.size != 3
18
- @bytes = elements.join.to_a.pack('H32')
18
+ @bytes = [elements.join].pack('H32')
19
19
  else
20
20
  raise TypeError, "Expected #{bytes.inspect} to cast to a #{self.class} (invalid bytecount)"
21
21
  end
@@ -38,14 +38,14 @@ class Cassandra
38
38
  ints[1]
39
39
  end
40
40
  end
41
-
41
+
42
42
  def to_guid
43
43
  "%08x-%04x-%04x" % @bytes.unpack("Nnn")
44
44
  end
45
45
 
46
46
  def inspect
47
47
  "<Cassandra::Long##{object_id} time: #{
48
- Time.at((to_i >> 12) / 1_000_000).inspect
48
+ Time.at((to_i >> 12) / 1_000_000).utc.inspect
49
49
  }, usecs: #{
50
50
  (to_i >> 12) % 1_000_000
51
51
  }, jitter: #{
@@ -0,0 +1,61 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/test_helper')
2
+ require 'cassandra_test'
3
+ require 'cassandra/mock'
4
+
5
+ class CassandraMockTest < CassandraTest
6
+ include Cassandra::Constants
7
+
8
+ def setup
9
+ storage_xml_path = File.expand_path(File.join(File.dirname(File.dirname(__FILE__)), 'conf', 'storage-conf.xml'))
10
+ @twitter = Cassandra::Mock.new('Twitter', nil, :storage_xml => storage_xml_path)
11
+ @twitter.clear_keyspace!
12
+
13
+ @blogs = Cassandra::Mock.new('Multiblog', nil, :storage_xml => storage_xml_path)
14
+ @blogs.clear_keyspace!
15
+
16
+ @blogs_long = Cassandra::Mock.new('MultiblogLong', nil, :storage_xml => storage_xml_path)
17
+ @blogs_long.clear_keyspace!
18
+
19
+ @uuids = (0..6).map {|i| UUID.new(Time.at(2**(24+i))) }
20
+ @longs = (0..6).map {|i| Long.new(Time.at(2**(24+i))) }
21
+ end
22
+
23
+ def test_setup
24
+ assert @twitter
25
+ assert @blogs
26
+ assert @blogs_long
27
+ end
28
+
29
+ def test_schema_for_keyspace
30
+ data = {
31
+ "StatusRelationships"=>{
32
+ "CompareSubcolumnsWith"=>"org.apache.cassandra.db.marshal.TimeUUIDType",
33
+ "CompareWith"=>"org.apache.cassandra.db.marshal.UTF8Type",
34
+ "Type"=>"Super"},
35
+ "StatusAudits"=>{
36
+ "CompareWith"=>"org.apache.cassandra.db.marshal.UTF8Type",
37
+ "Type"=>"Standard"},
38
+ "Statuses"=>{
39
+ "CompareWith"=>"org.apache.cassandra.db.marshal.UTF8Type",
40
+ "Type"=>"Standard"},
41
+ "UserRelationships"=>{
42
+ "CompareSubcolumnsWith"=>"org.apache.cassandra.db.marshal.TimeUUIDType",
43
+ "CompareWith"=>"org.apache.cassandra.db.marshal.UTF8Type",
44
+ "Type"=>"Super"},
45
+ "UserAudits"=>{
46
+ "CompareWith"=>"org.apache.cassandra.db.marshal.UTF8Type",
47
+ "Type"=>"Standard"},
48
+ "Users"=>{"CompareWith"=>"org.apache.cassandra.db.marshal.UTF8Type", "Type"=>"Standard"}
49
+ }
50
+ stuff = @twitter.send(:schema_for_keyspace, 'Twitter')
51
+ data.keys.each do |k|
52
+ assert_equal data[k], stuff[k], k
53
+ end
54
+ end
55
+
56
+ def test_sorting_row_keys
57
+ @twitter.insert(:Statuses, 'b', {:text => 'foo'})
58
+ @twitter.insert(:Statuses, 'a', {:text => 'foo'})
59
+ assert_equal ['a'], @twitter.get_range(:Statuses, :count => 1)
60
+ end
61
+ end
@@ -57,19 +57,19 @@ class CassandraTest < Test::Unit::TestCase
57
57
  def test_get_first_long_column
58
58
  @blogs_long.insert(:Blogs, key,
59
59
  {@longs[0] => 'I like this cat', @longs[1] => 'Buttons is cuter', @longs[2] => 'I disagree'})
60
-
60
+
61
61
  assert_equal({@longs[0] => 'I like this cat'}, @blogs_long.get(:Blogs, key, :count => 1))
62
62
  assert_equal({@longs[2] => 'I disagree'}, @blogs_long.get(:Blogs, key, :count => 1, :reversed => true))
63
63
  assert_equal({}, @blogs_long.get(:Blogs, 'bogus'))
64
64
  end
65
-
65
+
66
66
  def test_long_remove_bug
67
67
  @blogs_long.insert(:Blogs, key, {@longs[0] => 'I like this cat'})
68
68
  @blogs_long.remove(:Blogs, key)
69
69
  assert_equal({}, @blogs_long.get(:Blogs, key, :count => 1))
70
70
 
71
- @blogs_long.insert(:Blogs, key, {@longs[0] => 'I like this cat'})
72
- assert_equal({@longs[0] => 'I like this cat'}, @blogs_long.get(:Blogs, key, :count => 1))
71
+ @blogs_long.insert(:Blogs, key, {@longs[0] => 'I really like this cat'})
72
+ assert_equal({@longs[0] => 'I really like this cat'}, @blogs_long.get(:Blogs, key, :count => 1))
73
73
  end
74
74
 
75
75
  def test_get_with_count
@@ -84,7 +84,7 @@ class CassandraTest < Test::Unit::TestCase
84
84
  assert_nil @twitter.get(:Statuses, 'bogus', 'body')
85
85
 
86
86
  assert @twitter.exists?(:Statuses, key, 'body')
87
- assert_nil @twitter.exists?(:Statuses, 'bogus', 'body')
87
+ assert !@twitter.exists?(:Statuses, 'bogus', 'body')
88
88
  end
89
89
 
90
90
  def test_get_super_key
@@ -157,7 +157,7 @@ class CassandraTest < Test::Unit::TestCase
157
157
  def test_multi_get
158
158
  @twitter.insert(:Users, key + '1', {'body' => 'v1', 'user' => 'v1'})
159
159
  @twitter.insert(:Users, key + '2', {'body' => 'v2', 'user' => 'v2'})
160
-
160
+
161
161
  expected = OrderedHash[key + '1', {'body' => 'v1', 'user' => 'v1'}, key + '2', {'body' => 'v2', 'user' => 'v2'}, 'bogus', {}]
162
162
  result = @twitter.multi_get(:Users, [key + '1', key + '2', 'bogus'])
163
163
  assert_equal expected, result
@@ -35,7 +35,11 @@ class ComparableTypesTest < Test::Unit::TestCase
35
35
 
36
36
  def test_long_inspect
37
37
  obj = Long.new("\000\000\000\000\000\000\000\000")
38
- assert_equal "<Cassandra::Long##{obj.object_id} time: Wed Dec 31 16:00:00 -0800 1969, usecs: 0, jitter: 0, guid: 00000000-0000-0000>", obj.inspect
38
+ if RUBY_VERSION < '1.9'
39
+ assert_equal "<Cassandra::Long##{obj.object_id} time: Thu Jan 01 00:00:00 UTC 1970, usecs: 0, jitter: 0, guid: 00000000-0000-0000>", obj.inspect
40
+ else
41
+ assert_equal "<Cassandra::Long##{obj.object_id} time: 1970-01-01 00:00:00 UTC, usecs: 0, jitter: 0, guid: 00000000-0000-0000>", obj.inspect
42
+ end
39
43
  end
40
44
 
41
45
  end
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cassandra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
- - Evan Weaver
7
+ - Evan Weaver, Ryan King
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
@@ -30,7 +30,7 @@ cert_chain:
30
30
  zyKMYVRO0z/58g==
31
31
  -----END CERTIFICATE-----
32
32
 
33
- date: 2010-01-25 00:00:00 -08:00
33
+ date: 2010-02-19 00:00:00 -08:00
34
34
  default_executable:
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
@@ -42,6 +42,9 @@ dependencies:
42
42
  - - ">="
43
43
  - !ruby/object:Gem::Version
44
44
  version: "0"
45
+ - - "="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.4.0
45
48
  version:
46
49
  - !ruby/object:Gem::Dependency
47
50
  name: json
@@ -71,7 +74,10 @@ dependencies:
71
74
  requirements:
72
75
  - - ">="
73
76
  - !ruby/object:Gem::Version
74
- version: 0.0.2
77
+ version: "0"
78
+ - - "="
79
+ - !ruby/object:Gem::Version
80
+ version: 0.1.0
75
81
  version:
76
82
  description: A Ruby client for the Cassandra distributed database.
77
83
  email: ""
@@ -82,7 +88,7 @@ extensions: []
82
88
  extra_rdoc_files:
83
89
  - CHANGELOG
84
90
  - LICENSE
85
- - README.mkd
91
+ - README.rdoc
86
92
  - bin/cassandra_helper
87
93
  - lib/cassandra.rb
88
94
  - lib/cassandra/array.rb
@@ -99,7 +105,7 @@ files:
99
105
  - CHANGELOG
100
106
  - LICENSE
101
107
  - Manifest
102
- - README.mkd
108
+ - README.rdoc
103
109
  - Rakefile
104
110
  - bin/cassandra_helper
105
111
  - conf/cassandra.in.sh
@@ -135,7 +141,7 @@ rdoc_options:
135
141
  - --title
136
142
  - Cassandra
137
143
  - --main
138
- - README.mkd
144
+ - README.rdoc
139
145
  require_paths:
140
146
  - lib
141
147
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -158,6 +164,7 @@ signing_key:
158
164
  specification_version: 3
159
165
  summary: A Ruby client for the Cassandra distributed database.
160
166
  test_files:
167
+ - test/cassandra_mock_test.rb
161
168
  - test/cassandra_test.rb
162
169
  - test/comparable_types_test.rb
163
170
  - test/ordered_hash_test.rb
metadata.gz.sig CHANGED
Binary file