Class: Aerospike::BatchUDF

Inherits:
BatchRecord show all
Defined in:
lib/aerospike/batch_udf.rb

Overview

Batch user defined functions.

Constant Summary collapse

DEFAULT_BATCH_UDF_POLICY =
BatchUDFPolicy.new

Instance Attribute Summary collapse

Attributes inherited from BatchRecord

#has_write, #in_doubt, #key, #record, #result_code

Instance Method Summary collapse

Methods inherited from BatchRecord

create_policy, #prepare, #set_error

Constructor Details

#initialize(key, package_name, function_name, function_args, opt = {}) ⇒ BatchUDF

Constructor using default policy.



41
42
43
44
45
46
47
48
# File 'lib/aerospike/batch_udf.rb', line 41

def initialize(key, package_name, function_name, function_args, opt = {})
  super(key, has_write: true)
  @policy = BatchRecord.create_policy(opt, BatchUDFPolicy, DEFAULT_BATCH_UDF_POLICY)
  @package_name = package_name
  @function_name = function_name
  @function_args = ListValue.new(function_args)
  # Do not set arg_bytes here because may not be necessary if batch repeat flag is used.
end

Instance Attribute Details

#arg_bytesObject (readonly)

Wire protocol bytes for function args. For internal use only.



38
39
40
# File 'lib/aerospike/batch_udf.rb', line 38

def arg_bytes
  @arg_bytes
end

#function_argsObject

Optional arguments to lua function.



35
36
37
# File 'lib/aerospike/batch_udf.rb', line 35

def function_args
  @function_args
end

#function_nameObject

Lua function name.



32
33
34
# File 'lib/aerospike/batch_udf.rb', line 32

def function_name
  @function_name
end

#package_nameObject

Package or lua module name.



29
30
31
# File 'lib/aerospike/batch_udf.rb', line 29

def package_name
  @package_name
end

#policyObject

Optional UDF policy.



26
27
28
# File 'lib/aerospike/batch_udf.rb', line 26

def policy
  @policy
end

Instance Method Details

#==(other) ⇒ Object

Optimized reference equality check to determine batch wire protocol repeat flag. For internal use only.



52
53
54
55
56
# File 'lib/aerospike/batch_udf.rb', line 52

def ==(other) # :nodoc:
    other && other.instance_of?(self.class) &&
      @function_name == other.function_name && @function_args == other.function_args &&
      @package_name == other.package_name && @policy == other.policy
end

#sizeObject

Return wire protocol size. For internal use only.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/aerospike/batch_udf.rb', line 61

def size # :nodoc:
 size = 6 # gen(2) + exp(4) = 6

 size += @policy&.filter_exp&.size if @policy&.filter_exp

 if @policy&.send_key
   size += @key.user_key.estimate_size + Aerospike::FIELD_HEADER_SIZE + 1
 end
 size += @package_name.bytesize + Aerospike::FIELD_HEADER_SIZE
 size += @function_name.bytesize + Aerospike::FIELD_HEADER_SIZE
 @arg_bytes = @function_args.to_bytes
 size += @arg_bytes.bytesize + Aerospike::FIELD_HEADER_SIZE
 size
end