nzkoz / cassandra_object Goto Github PK
View Code? Open in Web Editor NEWA library for persisting your objects into cassandra.
License: ISC License
A library for persisting your objects into cassandra.
License: ISC License
Seems like cassandra gem has no Cassandra::UUID
class. I replaced it with SimpleUUID::UUID
and I could require cassandra and cassandra_object without errors. But then when I created class inherited from CassandraObject::Base
and tried to create new user instance with some parameters: User.new(:first_name => "name")
, I got error:
irb(main):020:0> User.new(:first_name => "name")
NoMethodError: undefined method 'encode' for nil:NilClass
from /home/ras/Programming/NoSQL/cassandra_object/lib/cassandra_object/attributes.rb:14:in `check_value!'
from /home/ras/Programming/NoSQL/cassandra_object/lib/cassandra_object/attributes.rb:62:in `write_attribute'
from /home/ras/Programming/NoSQL/cassandra_object/lib/cassandra_object/dirty.rb:23:in `write_attribute'
from /home/ras/Programming/NoSQL/cassandra_object/lib/cassandra_object/attributes.rb:89:in `attribute='
from /usr/local/lib/ruby/gems/1.9.1/gems/activemodel-3.0.0.beta3/lib/active_model/attribute_methods.rb:273:in `first_name='
from /home/ras/Programming/NoSQL/cassandra_object/lib/cassandra_object/attributes.rb:74:in `block in attributes='
from /home/ras/Programming/NoSQL/cassandra_object/lib/cassandra_object/attributes.rb:73:in `each'
from /home/ras/Programming/NoSQL/cassandra_object/lib/cassandra_object/attributes.rb:73:in `attributes='
from /home/ras/Programming/NoSQL/cassandra_object/lib/cassandra_object/base.rb:98:in `initialize'
from (irb):20:in `new'
from (irb):20
from /usr/local/bin/irb:12:in '<main>'
although :first_name
attribute was set in User class.
I was using ruby 1.9.1, rails3 beta3, cassandra 0.8.2 gem, cassandra 0.6.
Currently, accessing an association (such as customer.invoices) throws an exception if the association is empty. Here's a patch to stop that happening:
http://github.com/tomafro/cassandra_object/commit/d2bb3fa1b19a9cabf01ce1606d6f1fcb67817127
Given the following association:
class Zoo < CassandraObject
association :animals, :unique=>false
end
Reading this association would fail, with an error from the cassandra gem stating 'Required field reversed is unset!'. This is because the reversed option is passed as nil, not false.
Patch: http://github.com/tomafro/cassandra_object/commit/b2b504469c7720eced76aeb24d353a94cc83353c
I'm trying to get the latest version integrated into our app (plus another changeset on my branch) and I'm getting this:
CassandraStatus
NameError: uninitialized constant ActiveSupport::Callbacks
from /Users/ryan/code/twitter/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:263:inload_missing_constant' from /Users/ryan/code/twitter/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:453:in
const_missing_not_from_s3_library'
from /Users/ryan/code/twitter/vendor/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:inconst_missing' from /Users/ryan/code/twitter/vendor/gems/cassandra_object/lib/cassandra_object/legacy_callbacks.rb:4 from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require'
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire' from /Users/ryan/code/twitter/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in
require'
from /Users/ryan/code/twitter/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:innew_constants_in' from /Users/ryan/code/twitter/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in
require'
from /Users/ryan/code/twitter/vendor/gems/cassandra_object/lib/cassandra_object/base.rb:8
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:ingem_original_require' from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
require'
from /Users/ryan/code/twitter/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:inrequire' from /Users/ryan/code/twitter/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in
new_constants_in'
from /Users/ryan/code/twitter/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:inrequire' from /Users/ryan/code/twitter/vendor/gems/cassandra_object/lib/cassandra_object.rb:28 from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require'
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire' from /Users/ryan/code/twitter/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in
require'
from /Users/ryan/code/twitter/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:innew_constants_in' from /Users/ryan/code/twitter/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in
require'
from /Users/ryan/code/twitter/app/models/cassandra_status.rb:1
from /Users/ryan/code/twitter/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:203:inload_without_new_constant_marking' from /Users/ryan/code/twitter/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:203:in
load_file'
from /Users/ryan/code/twitter/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:innew_constants_in' from /Users/ryan/code/twitter/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:202:in
load_file'
from /Users/ryan/code/twitter/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:94:inrequire_or_load' from /Users/ryan/code/twitter/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:248:in
load_missing_constant'
from /Users/ryan/code/twitter/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:453:inconst_missing_not_from_s3_library' from /Users/ryan/code/twitter/vendor/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in
const_missing'
from /Users/ryan/code/twitter/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:465:in `const_missing'
from (irb):2>>
I was wondering why attributes can't be of type :boolean. I was looking in 'lib/types.rb' and found a BooleanType but it wasn't registered in 'lib/type_registration.rb'. Was this intentional?
Thanks!
Is there some ability to use full text search with Cassandra object?
Have found that cassandra_object is compatible with cassandra 0.7.6 gem. I have used cassandra_object and cassandra 0.7.6 gem, rails3 beta 3, ruby 1.9.1. At the moment I just get
NameError: uninitialized constant CassandraObject::Base error
although this gems are written in Gemfile.
(CassandraObject
class is visible, but CassandraObject::Base
is not)
after_create is never being called because the run_callbacks :create .... block always returns false. Patch and crappy test:
http://github.com/tomafro/cassandra_object/commit/467acc99d95b7b37247b39f527dd4bba611e7812
Running the newest Cassandra Beta (0.6 Beta 3) in combination with the HEAD of the Cassandra Ruby Library, querying for "all" objects returns "nil" objects.
Currently, the get_range() function returns on ore more columns wrapped into "CassandraThrift::KeySlice" objects. The current implementation expects the columns keys as return values.
The added patch fixes this problem by "getting" the key from the retrieved object. For compatibility with older versions, maybe check the version of the libraries and act appropriately (as type checking is too costly)?
With Gemfile:
gem "rails", '3.0.0.beta'
gem "cassandra_object", :git => "git://github.com/NZKoz/cassandra_object.git"
This works:
IRB> User.new(:nick => 'Tuxie')
#<User:0x4b271f0 @changed_attributes={"nick"=>nil}, @key=nil, @new_record=true, @attributes={"nick"=>"Tuxie"}, @schema_version=0>
But with Gemfile:
gem "rails", :git => "git://github.com/rails/rails.git"
gem "cassandra_object", :git => "git://github.com/NZKoz/cassandra_object.git"
This happens:
IRB> User.new(:nick => 'Tuxie')
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.include?
from /home/tuxie/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activemodel/lib/active_model/dirty.rb:125:in attribute_changed?' from /home/tuxie/.bundle/ruby/1.8/bundler/gems/cassandra_object-13c3c2c8949e63e16c17dc38b03522e12e5a8476-master/lib/cassandra_object/dirty.rb:19:in
write_attribute'
from /home/tuxie/.bundle/ruby/1.8/bundler/gems/cassandra_object-13c3c2c8949e63e16c17dc38b03522e12e5a8476-master/lib/cassandra_object/attributes.rb:89:in attribute=' from /home/tuxie/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activemodel/lib/active_model/attribute_methods.rb:262:in
send'
from /home/tuxie/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activemodel/lib/active_model/attribute_methods.rb:262:in nick=' from /home/tuxie/.bundle/ruby/1.8/bundler/gems/cassandra_object-13c3c2c8949e63e16c17dc38b03522e12e5a8476-master/lib/cassandra_object/attributes.rb:74:in
send'
from /home/tuxie/.bundle/ruby/1.8/bundler/gems/cassandra_object-13c3c2c8949e63e16c17dc38b03522e12e5a8476-master/lib/cassandra_object/attributes.rb:74:in attributes=' from /home/tuxie/.bundle/ruby/1.8/bundler/gems/cassandra_object-13c3c2c8949e63e16c17dc38b03522e12e5a8476-master/lib/cassandra_object/attributes.rb:73:in
each'
from /home/tuxie/.bundle/ruby/1.8/bundler/gems/cassandra_object-13c3c2c8949e63e16c17dc38b03522e12e5a8476-master/lib/cassandra_object/attributes.rb:73:in attributes=' from /home/tuxie/.bundle/ruby/1.8/bundler/gems/cassandra_object-13c3c2c8949e63e16c17dc38b03522e12e5a8476-master/lib/cassandra_object/base.rb:98:in
initialize'
from (irb):1:in `new'
from (irb):1
Because there is not get_key_range method at there.
In the first example there is index :date_of_birth
string. How will this influence Cassandra database? What additional queries will I be able to make?
uninitialized constant Cassandra::UUID error, on Cassandra Gem >= 0.7.6.
This patch use SimpleUUID::UUID instead of Cassandra::UUID:
http://github.com/jusnavigandi/cassandra_object/commit/d6e898ce243de8ff5bb52871089d6efc70651342
The readme installation is a bit out of date. Could this be updated?
If I am planning to use Cassandra, but in my application I have different kinds of filters - by status, by project, by user and so on. As I know - cassandra_object (as well as Cassandra itself) has no support of :conditions
statement. The only way to avoid this problem is to write indexes of all this information just as you put some new values. Can anybody suggest some best practices about storing such information?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.