Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pbc client doesn't work with indexes #17

Closed
graphex opened this issue Feb 19, 2012 · 1 comment
Closed

pbc client doesn't work with indexes #17

graphex opened this issue Feb 19, 2012 · 1 comment

Comments

@graphex
Copy link

graphex commented Feb 19, 2012

Whenever I try to assign an index to a RObject, it fails on store if I specify an index when the protocol is 'pbc'

        it "pbc client should work" do
            #the test works with :protocol => 'http'
            riak_client = Riak::Client.new(:protocol => 'pbc', :host => '127.0.0.1', :pb_port => 8081, :http_port => 8091)
            testval = SecureRandom.hex(64)
            riak_bucket = riak_client.bucket("test")
            riak_object = riak_bucket.get_or_new("test_key")
            puts riak_object.inspect
            riak_object.data = {:value => testval}

            #the test works without this line:
            riak_object.indexes = {"test_bin" => ["myindex"]}

            riak_object.store
            riak_object.reload
            puts riak_object.data
            newval = riak_object.data["value"]
            newval.should == testval
        end

error is

Fast Debugger (ruby-debug-ide 0.4.17.beta8, ruby-debug-base 0.11.30.pre10) listens on 127.0.0.1:58246
#<Riak::RObject {test,test_key} [application/json]:{"value"=>"ffe90958dcd76989bbdc86384db3ce717d720f2f3c1cad737f925b37be4ff1a362f16c85e520801df5aea162d808f2bee627bde1756c107222f794f4db20e581"}>

NoMethodError: undefinedod `<<' for nil:NilClass
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client/beefcake/object_methods.rb:93:in `decode_index'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client/beefcake/object_methods.rb:61:in `block in load_content'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client/beefcake/object_methods.rb:61:in `each'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client/beefcake/object_methods.rb:61:in `load_content'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client/beefcake/object_methods.rb:44:in `load_object'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client/beefcake_protobuffs_backend.rb:159:in `decode_response'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client/beefcake_protobuffs_backend.rb:59:in `store_object'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client.rb:508:in `block in store_object'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client.rb:428:in `block in recover_from'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client/pool.rb:126:in `take'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client.rb:426:in `recover_from'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client.rb:374:in `protobuffs'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client.rb:128:in `backend'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client.rb:507:in `store_object'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/robject.rb:179:in `store'
myproj/spec/models/riak_spec.rb:71:in `block (3 levels) in <top (required)>'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/example.rb:80:in `instance_eval'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/example.rb:80:in `block in run'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/example.rb:173:in `with_around_hooks'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/example.rb:77:in `run'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:355:in `block in run_examples'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:351:in `map'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:351:in `run_examples'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:337:in `run'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:338:in `block in run'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:338:in `map'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:338:in `run'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:28:in `map'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:28:in `block in run'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/reporter.rb:34:in `report'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:25:in `run'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:80:in `run_in_process'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:69:in `run'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:10:in `block in autorun'
.rvm/gems/ruby-1.9.3-p0@boat/gems/ruby-debug-ide-0.4.17.beta8/lib/ruby-debug-ide.rb:127:in `debug_load'
.rvm/gems/ruby-1.9.3-p0@boat/gems/ruby-debug-ide-0.4.17.beta8/lib/ruby-debug-ide.rb:127:in `debug_program'
.rvm/gems/ruby-1.9.3-p0@boat/gems/ruby-debug-ide-0.4.17.beta8/bin/rdebug-ide:95:in `<top (required)>'
-e:1:in `load'
-e:1:in `<main>'

My storage backend is eLevelDB and the HTTP client protocol works flawlessly.

@seancribbs
Copy link
Contributor

@graphex This is because you are overriding the entire indexes. The RObject comes prepopulated with its own Hash for indexes whose default value for new keys is a Set. Instead of replacing the whole thing, just append the values you want to the specified index like so:

riak_object.indexes['test_bin'] << 'myindex'

That said, I will see what I can do about making the index structure immune to blind overwrites.

seancribbs pushed a commit that referenced this issue Apr 4, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants