Class: Aerospike::LargeStack

Inherits:
Large
  • Object
show all
Defined in:
lib/aerospike/ldt/large_stack.rb

Instance Method Summary collapse

Methods inherited from Large

#capacity, #capacity=, #config, #destroy, #scan, #size

Constructor Details

#initialize(client, policy, key, bin_name, user_module = nil) ⇒ LargeStack

Returns a new instance of LargeStack.



25
26
27
28
29
30
31
# File 'lib/aerospike/ldt/large_stack.rb', line 25

def initialize(client, policy, key, bin_name, user_module=nil)
  @PACKAGE_NAME = 'lstack'

  super(client, policy, key, bin_name, user_module)

  self
end

Instance Method Details

#filter(peek_count, filter_name, *filter_args) ⇒ Object

Select items from top of stack.

peek_count number of items to select. filter_name Lua function name which applies filter to returned list filter_args arguments to Lua function name returns list of items selected



66
67
68
# File 'lib/aerospike/ldt/large_stack.rb', line 66

def filter(peek_count, filter_name, *filter_args)
  @client.execute_udf(@key, @PACKAGE_NAME, 'filter', [@bin_name, peek_count, @user_module, filter_name, filter_args], @policy)
end

#peek(peek_count) ⇒ Object

Select items from top of stack.

peek_count number of items to select. returns list of items selected



48
49
50
# File 'lib/aerospike/ldt/large_stack.rb', line 48

def peek(peek_count)
  @client.execute_udf(@key, @PACKAGE_NAME, 'peek', [@bin_name, peek_count], @policy)
end

#pop(count) ⇒ Object

Select items from top of stack.

peek_count number of items to select. returns list of items selected



56
57
58
# File 'lib/aerospike/ldt/large_stack.rb', line 56

def pop(count)
  @client.execute_udf(@key, @PACKAGE_NAME, 'pop', [@bin_name, count], @policy)
end

#push(*values) ⇒ Object

Push values onto stack. If the stack does not exist, create it using specified user_module configuration.

values values to push



36
37
38
39
40
41
42
# File 'lib/aerospike/ldt/large_stack.rb', line 36

def push(*values)
  if values.length == 1
    @client.execute_udf(@key, @PACKAGE_NAME, 'push', [@bin_name, values[0], @user_module], @policy)
  else
    @client.execute_udf(@key, @PACKAGE_NAME, 'push_all', [@bin_name, values, @user_module], @policy)
  end
end