Class: Aerospike::Statement
- Inherits:
-
Object
- Object
- Aerospike::Statement
- Defined in:
- lib/aerospike/query/statement.rb
Overview
The Aerospike::Statement class represents a query or scan statement to be executed on the database. It provides a set of properties that define the query or scan, including namespace, set name, bin names, index name, filters, and operations.
Instance Attribute Summary collapse
-
#bin_names ⇒ Object
Returns the value of attribute bin_names.
-
#filters ⇒ Object
Returns the value of attribute filters.
-
#function_args ⇒ Object
Returns the value of attribute function_args.
-
#function_name ⇒ Object
Returns the value of attribute function_name.
-
#index_name ⇒ Object
Returns the value of attribute index_name.
-
#namespace ⇒ Object
Returns the value of attribute namespace.
-
#operations ⇒ Object
Returns the value of attribute operations.
-
#package_name ⇒ Object
Returns the value of attribute package_name.
-
#records_per_second ⇒ Object
Returns the value of attribute records_per_second.
-
#return_data ⇒ Object
Returns the value of attribute return_data.
-
#set_name ⇒ Object
Returns the value of attribute set_name.
-
#task_id ⇒ Object
Returns the value of attribute task_id.
Instance Method Summary collapse
-
#initialize(namespace, set_name, bin_names = []) ⇒ Statement
constructor
A new instance of Statement.
- #is_scan? ⇒ Boolean
- #reset_task_id ⇒ Object
- #set_aggregate_function(package_name, function_name, function_args = [], return_data = true) ⇒ Object
- #set_task_id ⇒ Object
Constructor Details
#initialize(namespace, set_name, bin_names = []) ⇒ Statement
Returns a new instance of Statement.
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 |
# File 'lib/aerospike/query/statement.rb', line 26 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 = [] @package_name = nil @function_name = nil @function_args = nil @operations = nil # Limit returned records per second (rps) rate for each server. # Will not apply rps limit if records_per_second is zero. # Currently only applicable to a query without a defined filter (scan). # Default is 0 @records_per_second = 0 # 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_names ⇒ Object
Returns the value of attribute bin_names.
24 25 26 |
# File 'lib/aerospike/query/statement.rb', line 24 def bin_names @bin_names end |
#filters ⇒ Object
Returns the value of attribute filters.
24 25 26 |
# File 'lib/aerospike/query/statement.rb', line 24 def filters @filters end |
#function_args ⇒ Object
Returns the value of attribute function_args.
24 25 26 |
# File 'lib/aerospike/query/statement.rb', line 24 def function_args @function_args end |
#function_name ⇒ Object
Returns the value of attribute function_name.
24 25 26 |
# File 'lib/aerospike/query/statement.rb', line 24 def function_name @function_name end |
#index_name ⇒ Object
Returns the value of attribute index_name.
24 25 26 |
# File 'lib/aerospike/query/statement.rb', line 24 def index_name @index_name end |
#namespace ⇒ Object
Returns the value of attribute namespace.
24 25 26 |
# File 'lib/aerospike/query/statement.rb', line 24 def namespace @namespace end |
#operations ⇒ Object
Returns the value of attribute operations.
24 25 26 |
# File 'lib/aerospike/query/statement.rb', line 24 def operations @operations end |
#package_name ⇒ Object
Returns the value of attribute package_name.
24 25 26 |
# File 'lib/aerospike/query/statement.rb', line 24 def package_name @package_name end |
#records_per_second ⇒ Object
Returns the value of attribute records_per_second.
24 25 26 |
# File 'lib/aerospike/query/statement.rb', line 24 def records_per_second @records_per_second end |
#return_data ⇒ Object
Returns the value of attribute return_data.
24 25 26 |
# File 'lib/aerospike/query/statement.rb', line 24 def return_data @return_data end |
#set_name ⇒ Object
Returns the value of attribute set_name.
24 25 26 |
# File 'lib/aerospike/query/statement.rb', line 24 def set_name @set_name end |
#task_id ⇒ Object
Returns the value of attribute task_id.
24 25 26 |
# File 'lib/aerospike/query/statement.rb', line 24 def task_id @task_id end |
Instance Method Details
#is_scan? ⇒ Boolean
73 74 75 |
# File 'lib/aerospike/query/statement.rb', line 73 def is_scan? filters.nil? || filters.empty? end |
#reset_task_id ⇒ Object
81 82 83 84 |
# File 'lib/aerospike/query/statement.rb', line 81 def reset_task_id @task_id = rand(RAND_MAX) @task_id = rand(RAND_MAX) while @task_id == 0 end |
#set_aggregate_function(package_name, function_name, function_args = [], return_data = true) ⇒ Object
66 67 68 69 70 71 |
# File 'lib/aerospike/query/statement.rb', line 66 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_id ⇒ Object
77 78 79 |
# File 'lib/aerospike/query/statement.rb', line 77 def set_task_id @task_id = rand(RAND_MAX) while @task_id == 0 end |