Class: Aerospike::BatchRead
- Inherits:
-
BatchRecord
- Object
- BatchRecord
- Aerospike::BatchRead
- Defined in:
- lib/aerospike/batch_read.rb
Constant Summary collapse
- DEFAULT_BATCH_READ_POLICY =
BatchReadPolicy.new
Instance Attribute Summary collapse
-
#bin_names ⇒ Object
Bins to retrieve for this key.
-
#ops ⇒ Object
Optional operations for this key.
-
#policy ⇒ Object
Optional read policy.
-
#read_all_bins ⇒ Object
If true, ignore bin_names and read all bins.
Attributes inherited from BatchRecord
#has_write, #in_doubt, #key, #record, #result_code
Class Method Summary collapse
-
.ops(key, ops, opt = {}) ⇒ Object
Initialize batch key and read operations.
-
.read_all_bins(key, opt = {}) ⇒ Object
Initialize batch key and read_all_bins indicator.
-
.read_bins(key, bin_names, opt = {}) ⇒ Object
Initialize batch key and bins to retrieve.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Optimized reference equality check to determine batch wire protocol repeat flag.
-
#size ⇒ Object
Return wire protocol size.
Methods inherited from BatchRecord
create_policy, #initialize, #prepare, #set_error
Constructor Details
This class inherits a constructor from Aerospike::BatchRecord
Instance Attribute Details
#bin_names ⇒ Object
Bins to retrieve for this key. bin_names are mutually exclusive with #ops.
29 30 31 |
# File 'lib/aerospike/batch_read.rb', line 29 def bin_names @bin_names end |
#ops ⇒ Object
Optional operations for this key. ops are mutually exclusive with #bin_names. A bin_name can be emulated with Operation#get(bin_name)
34 35 36 |
# File 'lib/aerospike/batch_read.rb', line 34 def ops @ops end |
#policy ⇒ Object
Optional read policy.
25 26 27 |
# File 'lib/aerospike/batch_read.rb', line 25 def policy @policy end |
#read_all_bins ⇒ Object
If true, ignore bin_names and read all bins. If false and bin_names are set, read specified bin_names. If false and bin_names are not set, read record header (generation, expiration) only.
39 40 41 |
# File 'lib/aerospike/batch_read.rb', line 39 def read_all_bins @read_all_bins end |
Class Method Details
.ops(key, ops, opt = {}) ⇒ Object
Initialize batch key and read operations.
59 60 61 62 63 64 65 |
# File 'lib/aerospike/batch_read.rb', line 59 def self.ops(key, ops, opt = {}) br = BatchRead.new(key) br.policy = create_policy(opt, BatchReadPolicy, DEFAULT_BATCH_READ_POLICY) br.ops = ops br.read_all_bins = false br end |
.read_all_bins(key, opt = {}) ⇒ Object
Initialize batch key and read_all_bins indicator.
51 52 53 54 55 56 |
# File 'lib/aerospike/batch_read.rb', line 51 def self.read_all_bins(key, opt = {}) br = BatchRead.new(key) br.policy = create_policy(opt, BatchReadPolicy, DEFAULT_BATCH_READ_POLICY) br.read_all_bins = true br end |
.read_bins(key, bin_names, opt = {}) ⇒ Object
Initialize batch key and bins to retrieve.
42 43 44 45 46 47 48 |
# File 'lib/aerospike/batch_read.rb', line 42 def self.read_bins(key, bin_names, opt = {}) br = BatchRead.new(key) br.policy = BatchRecord.create_policy(opt, BatchReadPolicy, DEFAULT_BATCH_READ_POLICY) br.bin_names = bin_names br.read_all_bins = false br end |
Instance Method Details
#==(other) ⇒ Object
Optimized reference equality check to determine batch wire protocol repeat flag. For internal use only.
69 70 71 72 73 |
# File 'lib/aerospike/batch_read.rb', line 69 def ==(other) # :nodoc: other && other.instance_of?(self.class) && @bin_names&.sort == other.bin_names&.sort && @ops == other.ops && @policy == other.policy && @read_all_bins == other.read_all_bins end |
#size ⇒ Object
Return wire protocol size. For internal use only.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/aerospike/batch_read.rb', line 78 def size # :nodoc: size = 0 size += @policy&.filter_exp&.size if @policy&.filter_exp @bin_names&.each do |bin_name| size += bin_name.bytesize + Aerospike::OPERATION_HEADER_SIZE end @ops&.each do |op| if op.is_write? raise AerospikeException.new(ResultCode::PARAMETER_ERROR, "Write operations not allowed in batch read") end size += op.bin_name.bytesize + Aerospike::OPERATION_HEADER_SIZE size += op.bin_value.estimate_size end size end |