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

fix: BatchRead with operations #132

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

opti
Copy link

@opti opti commented Sep 30, 2024

This pull request:

  • fixes invalid local variable reference in BatchOperateCommand

    /aerospike-client-ruby/lib/aerospike/command/batch_operate_command.rb:95:in `block in write_buffer': undefined local variable or method `br' for an instance of Aerospike::BatchOperateCommand (NameError)
    
                attr.adjust_read(br.ops)
                                 ^^
          from /aerospike-client-ruby/lib/aerospike/command/batch_operate_command.rb:81:in `each'
          from /aerospike-client-ruby/lib/aerospike/command/batch_operate_command.rb:81:in `each_with_index'
          from /aerospike-client-ruby/lib/aerospike/command/batch_operate_command.rb:81:in `write_buffer'
          from /aerospike-client-ruby/lib/aerospike/command/command.rb:718:in `execute'
          from /aerospike-client-ruby/lib/aerospike/client.rb:973:in `execute_command'
          from /aerospike-client-ruby/lib/aerospike/client.rb:1005:in `block (2 levels) in execute_batch_operate_commands'
  • fixes attribute reference in size calculation for the BatchRead

    /aerospike-client-ruby/lib/aerospike/batch_read.rb:91:in `block in size': undefined method `value' for an instance of Aerospike::Operation (NoMethodError)
    
          size += op.value.estimate_size
                    ^^^^^^
          from /aerospike-client-ruby/lib/aerospike/batch_read.rb:86:in `each'
          from /aerospike-client-ruby/lib/aerospike/batch_read.rb:86:in `size'
          from /aerospike-client-ruby/lib/aerospike/command/batch_operate_command.rb:63:in `block in write_buffer'
          from /aerospike-client-ruby/lib/aerospike/command/batch_operate_command.rb:53:in `each'
          from /aerospike-client-ruby/lib/aerospike/command/batch_operate_command.rb:53:in `write_buffer'
          from /aerospike-client-ruby/lib/aerospike/command/command.rb:718:in `execute'
          from /aerospike-client-ruby/lib/aerospike/client.rb:973:in `execute_command'
          from /aerospike-client-ruby/lib/aerospike/client.rb:1005:in `block (2 levels) in execute_batch_operate_commands'
  • fixes BatchRead with multiple records using operations (2 issues)

    /aerospike-client-ruby/lib/aerospike/batch_read.rb:71:in `==': undefined method `sort' for nil (NoMethodError)
    
          @bin_names.sort == other.bin_names.sort && @ops.sort == other.ops.sort &&
                    ^^^^^
          from /aerospike-client-ruby/lib/aerospike/command/batch_operate_command.rb:57:in `block in write_buffer'
          from /aerospike-client-ruby/lib/aerospike/command/batch_operate_command.rb:53:in `each'
          from /aerospike-client-ruby/lib/aerospike/command/batch_operate_command.rb:53:in `write_buffer'
          from /aerospike-client-ruby/lib/aerospike/command/command.rb:718:in `execute'
          from /aerospike-client-ruby/lib/aerospike/client.rb:973:in `execute_command'
          from /aerospike-client-ruby/lib/aerospike/client.rb:1005:in `block (2 levels) in execute_batch_operate_commands'
    /aerospike-client-ruby/lib/aerospike/batch_read.rb:71:in `sort': comparison of Aerospike::Operation with Aerospike::Operation failed (ArgumentError)
          from /aerospike-client-ruby/lib/aerospike/batch_read.rb:71:in `=='
          from /aerospike-client-ruby/lib/aerospike/command/batch_operate_command.rb:57:in `block in write_buffer'
          from /aerospike-client-ruby/lib/aerospike/command/batch_operate_command.rb:53:in `each'
          from /aerospike-client-ruby/lib/aerospike/command/batch_operate_command.rb:53:in `write_buffer'
          from /aerospike-client-ruby/lib/aerospike/command/command.rb:718:in `execute'
          from /aerospike-client-ruby/lib/aerospike/client.rb:973:in `execute_command'
          from /aerospike-client-ruby/lib/aerospike/client.rb:1005:in `block (2 levels) in execute_batch_operate_commands'

@@ -68,7 +68,7 @@ def self.ops(key, ops, opt = {})
# For internal use only.
def ==(other) # :nodoc:
other && other.instance_of?(self.class) &&
@bin_names.sort == other.bin_names.sort && @ops.sort == other.ops.sort &&
@bin_names&.sort == other.bin_names&.sort && @ops == other.ops &&
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Since bins and ops are mutually exclusive, bin_names could be nil.
  • There is no implementation of ==(other) on Aerospike::Operation for @ops.sort to work and I noticed that BatchWrite does not use sort on ops comparison:
    # Optimized reference equality check to determine batch wire protocol repeat flag.
    # For internal use only.
    def ==(other) # :nodoc:
    other && other.instance_of?(self.class) &&
    @ops == other.ops && @policy == other.policy && (@policy.nil? || !@policy.send_key)
    end

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

Successfully merging this pull request may close these issues.

1 participant