Class: Aerospike::Statement

Inherits:
Object
  • Object
show all
Defined in:
lib/aerospike/query/statement.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(namespace, set_name, bin_names = []) ⇒ Statement

Returns a new instance of Statement.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/aerospike/query/statement.rb', line 25

def initialize(namespace, set_name, bin_names=[])
  # Namespace determines query Namespace
  @namespace = namespace

  # SetName determines query Set name (Optional)
  @set_name = set_name

  # IndexName determines query index name (Optional)
  # If not set, the server will determine the index from the filter's bin name.
  @index_name = nil

  # BinNames detemines bin names (optional)
  @bin_names = bin_names

  # Filters determine query filters (Optional)
  # Currently, only one filter is allowed by the server on a secondary index lookup.
  # If multiple filters are necessary, see QueryFilter example for a workaround.
  # QueryFilter demonstrates how to add additional filters in an user-defined
  # aggregation function.
  @filters = []

  # Predicate expressions in postfix notation. If the expression is evaluated to false,
  # the record will be ommited in the results.
  #
  # This method is redundant because PredExp can now be set in the base Policy for
  # any transaction (including queries).
  #
  # NOTE : Policy.predexp takes precedence to this value. This value will be
  # deprecated in the future.
  @predexp = nil

  @package_name  = nil
  @function_name = nil
  @function_args = nil

  # TaskId determines query task id. (Optional)
  @task_id = rand(RAND_MAX)

  # determines if the query should return data
  @return_data = true
end

Instance Attribute Details

#bin_namesObject

Returns the value of attribute bin_names.



21
22
23
# File 'lib/aerospike/query/statement.rb', line 21

def bin_names
  @bin_names
end

#filtersObject

Returns the value of attribute filters.



22
23
24
# File 'lib/aerospike/query/statement.rb', line 22

def filters
  @filters
end

#function_argsObject

Returns the value of attribute function_args.



22
23
24
# File 'lib/aerospike/query/statement.rb', line 22

def function_args
  @function_args
end

#function_nameObject

Returns the value of attribute function_name.



22
23
24
# File 'lib/aerospike/query/statement.rb', line 22

def function_name
  @function_name
end

#index_nameObject

Returns the value of attribute index_name.



21
22
23
# File 'lib/aerospike/query/statement.rb', line 21

def index_name
  @index_name
end

#namespaceObject

Returns the value of attribute namespace.



21
22
23
# File 'lib/aerospike/query/statement.rb', line 21

def namespace
  @namespace
end

#package_nameObject

Returns the value of attribute package_name.



22
23
24
# File 'lib/aerospike/query/statement.rb', line 22

def package_name
  @package_name
end

#predexpObject

Returns the value of attribute predexp.



23
24
25
# File 'lib/aerospike/query/statement.rb', line 23

def predexp
  @predexp
end

#return_dataObject

Returns the value of attribute return_data.



23
24
25
# File 'lib/aerospike/query/statement.rb', line 23

def return_data
  @return_data
end

#set_nameObject

Returns the value of attribute set_name.



21
22
23
# File 'lib/aerospike/query/statement.rb', line 21

def set_name
  @set_name
end

#task_idObject

Returns the value of attribute task_id.



21
22
23
# File 'lib/aerospike/query/statement.rb', line 21

def task_id
  @task_id
end

Instance Method Details

#is_scan?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/aerospike/query/statement.rb', line 74

def is_scan?
  return (filters.nil? || (filters.empty?))
end

#reset_task_idObject



84
85
86
87
88
89
# File 'lib/aerospike/query/statement.rb', line 84

def reset_task_id
  @task_id = rand(RAND_MAX)
  while @task_id == 0
    @task_id = rand(RAND_MAX)
  end
end

#set_aggregate_function(package_name, function_name, function_args = [], return_data = true) ⇒ Object



67
68
69
70
71
72
# File 'lib/aerospike/query/statement.rb', line 67

def set_aggregate_function(package_name, function_name, function_args=[], return_data=true)
    @package_name  = package_name
    @function_name = function_name
    @function_args = function_args
    @return_data = return_data
end

#set_task_idObject



78
79
80
81
82
# File 'lib/aerospike/query/statement.rb', line 78

def set_task_id
  while @task_id == 0
    @task_id = rand(RAND_MAX)
  end
end