aerospike 2.23.0 → 2.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -693,44 +693,44 @@ module Aerospike
693
693
  # Query functions (Supported by Aerospike 3 servers only)
694
694
  #--------------------------------------------------------
695
695
 
696
- # Query executes a query and returns a recordset.
697
- # The query executor puts records on a channel from separate goroutines.
698
- # The caller can concurrently pops records off the channel through the
699
- # record channel.
696
+ # Executes a query for specified partitions and returns a recordset.
697
+ # The query executor puts records on the queue from separate threads.
698
+ # The caller can concurrently pop records off the queue through the
699
+ # recordset.records API.
700
700
  #
701
- # This method is only supported by Aerospike 3 servers.
702
- # If the policy is nil, a default policy will be generated.
703
- def query(statement, options = nil)
701
+ # This method is only supported by Aerospike 4.9+ servers.
702
+ # If the policy is nil, the default relevant policy will be used.
703
+ def query_partitions(partition_filter, statement, options = nil)
704
704
  policy = create_policy(options, QueryPolicy, default_query_policy)
705
705
  new_policy = policy.clone
706
706
 
707
707
  nodes = @cluster.nodes
708
708
  if nodes.empty?
709
- raise Aerospike::Exceptions::Aerospike.new(Aerospike::ResultCode::SERVER_NOT_AVAILABLE, "Scan failed because cluster is empty.")
709
+ raise Aerospike::Exceptions::Aerospike.new(Aerospike::ResultCode::SERVER_NOT_AVAILABLE, "Query failed because cluster is empty.")
710
710
  end
711
711
 
712
- recordset = Recordset.new(policy.record_queue_size, nodes.length, :query)
713
-
714
- # Use a thread per node
715
- nodes.each do |node|
716
- partitions = node.cluster.node_partitions(node, statement.namespace)
717
- Thread.new do
718
- Thread.current.abort_on_exception = true
719
- command = QueryCommand.new(node, new_policy, statement, recordset, partitions)
720
- begin
721
- execute_command(command)
722
- rescue => e
723
- Aerospike.logger.error(e.backtrace.join("\n")) unless e == QUERY_TERMINATED_EXCEPTION
724
- recordset.cancel(e)
725
- ensure
726
- recordset.thread_finished
727
- end
728
- end
712
+ # result recordset
713
+ recordset = Recordset.new(policy.record_queue_size, 1, :query)
714
+ tracker = PartitionTracker.new(policy, nodes, partition_filter)
715
+ Thread.new do
716
+ Thread.current.abort_on_exception = true
717
+ QueryExecutor.query_partitions(@cluster, policy, tracker, statement, recordset)
729
718
  end
730
719
 
731
720
  recordset
732
721
  end
733
722
 
723
+ # Query executes a query and returns a recordset.
724
+ # The query executor puts records on a channel from separate threads.
725
+ # The caller can concurrently pops records off the channel through the
726
+ # record channel.
727
+ #
728
+ # This method is only supported by Aerospike 3 servers.
729
+ # If the policy is nil, a default policy will be generated.
730
+ def query(statement, options = nil)
731
+ query_partitions(Aerospike::PartitionFilter.all, statement, options)
732
+ end
733
+
734
734
  #-------------------------------------------------------
735
735
  # User administration
736
736
  #-------------------------------------------------------
@@ -34,6 +34,8 @@ module Aerospike
34
34
  INFO1_READ = Integer(1 << 0)
35
35
  # Get all bins.
36
36
  INFO1_GET_ALL = Integer(1 << 1)
37
+ # Short query
38
+ INFO1_SHORT_QUERY = Integer(1 << 2)
37
39
 
38
40
 
39
41
  INFO1_BATCH = Integer(1 << 3)
@@ -454,7 +456,7 @@ module Aerospike
454
456
  # @data_buffer.write_byte(policy.scan_percent.to_i.ord, @data_offset)
455
457
  # @data_offset += 1
456
458
 
457
- write_field_header(4, Aerospike::FieldType::SCAN_TIMEOUT)
459
+ write_field_header(4, Aerospike::FieldType::SOCKET_TIMEOUT)
458
460
  @data_buffer.write_uint32(policy.socket_timeout.to_i, @data_offset)
459
461
  @data_offset += 4
460
462
 
@@ -21,34 +21,31 @@ module Aerospike
21
21
 
22
22
  module FieldType
23
23
 
24
- NAMESPACE = 0
25
- TABLE = 1
26
- KEY = 2
27
- #BIN = 3
28
- DIGEST_RIPE = 4
29
- #GU_TID = 5
30
- DIGEST_RIPE_ARRAY = 6
31
- TRAN_ID = 7 # user supplied transaction id, which is simply passed back
32
- SCAN_OPTIONS = 8
33
- SCAN_TIMEOUT = 9
34
- RECORDS_PER_SECOND = 10
35
- PID_ARRAY = 11
36
- DIGEST_ARRAY = 12
37
- MAX_RECORDS = 13
38
- BVAL_ARRAY = 15
39
- INDEX_NAME = 21
40
- INDEX_RANGE = 22
41
- INDEX_FILTER = 23
42
- INDEX_LIMIT = 24
43
- INDEX_ORDER_BY = 25
44
- INDEX_TYPE = 26
45
- UDF_PACKAGE_NAME = 30
46
- UDF_FUNCTION = 31
47
- UDF_ARGLIST = 32
48
- UDF_OP = 33
49
- QUERY_BINLIST = 40
50
- BATCH_INDEX = 41
51
- PREDEXP = 43
24
+ NAMESPACE = 0
25
+ TABLE = 1
26
+ KEY = 2
27
+ DIGEST_RIPE = 4
28
+ DIGEST_RIPE_ARRAY = 6
29
+ TRAN_ID = 7 # user supplied transaction id, which is simply passed back
30
+ SCAN_OPTIONS = 8
31
+ SOCKET_TIMEOUT = 9
32
+ RECORDS_PER_SECOND = 10
33
+ PID_ARRAY = 11
34
+ DIGEST_ARRAY = 12
35
+ MAX_RECORDS = 13
36
+ BVAL_ARRAY = 15
37
+ INDEX_NAME = 21
38
+ INDEX_RANGE = 22
39
+ INDEX_CONTEXT = 23
40
+ INDEX_TYPE = 26
41
+ UDF_PACKAGE_NAME = 30
42
+ UDF_FUNCTION = 31
43
+ UDF_ARGLIST = 32
44
+ UDF_OP = 33
45
+ QUERY_BINLIST = 40
46
+ BATCH_INDEX = 41
47
+ BATCH_INDEX_WITH_SET = 42
48
+ FILTER_EXP = 43
52
49
 
53
50
  end # module
54
51