aerospike 0.1.3 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,42 @@
1
+ # encoding: utf-8
2
+ # Copyright 2014 Aerospike, Inc.
3
+ #
4
+ # Portions may be licensed to Aerospike, Inc. under one or more contributor
5
+ # license agreements.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may not
8
+ # use this file except in compliance with the License. You may obtain a copy of
9
+ # the License at http:#www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ # License for the specific language governing permissions and limitations under
15
+ # the License.
16
+
17
+ require 'aerospike/query/stream_command'
18
+ require 'aerospike/query/recordset'
19
+
20
+ module Aerospike
21
+
22
+ private
23
+
24
+ class ScanCommand < StreamCommand
25
+
26
+ def initialize(node, policy, namespace, set_name, bin_names, recordset)
27
+ super(node)
28
+
29
+ @policy = policy
30
+ @namespace = namespace
31
+ @set_name = set_name
32
+ @bin_names = bin_names
33
+ @recordset = recordset
34
+ end
35
+
36
+ def write_buffer
37
+ set_scan(@policy, @namespace, @set_name, @bin_names)
38
+ end
39
+
40
+ end # class
41
+
42
+ end # module
@@ -0,0 +1,70 @@
1
+ # encoding: utf-8
2
+ # Copyright 2014 Aerospike, Inc.
3
+ #
4
+ # Portions may be licensed to Aerospike, Inc. under one or more contributor
5
+ # license agreements.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may not
8
+ # use this file except in compliance with the License. You may obtain a copy of
9
+ # the License at http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ # License for the specific language governing permissions and limitations under
15
+ # the License.
16
+
17
+ module Aerospike
18
+
19
+ class Statement
20
+
21
+ attr_accessor :namespace, :set_name, :index_name, :bin_names, :task_id
22
+ attr_accessor :filters, :package_name, :function_name, :function_args
23
+ attr_accessor :return_data
24
+
25
+ def initialize(namespace, set_name, bin_names=[])
26
+ # Namespace determines query Namespace
27
+ @namespace = namespace
28
+
29
+ # SetName determines query Set name (Optional)
30
+ @set_name = set_name
31
+
32
+ # IndexName determines query index name (Optional)
33
+ # If not set, the server will determine the index from the filter's bin name.
34
+ @index_name = nil
35
+
36
+ # BinNames detemines bin names (optional)
37
+ @bin_names = bin_names
38
+
39
+ # Filters determine query filters (Optional)
40
+ # Currently, only one filter is allowed by the server on a secondary index lookup.
41
+ # If multiple filters are necessary, see QueryFilter example for a workaround.
42
+ # QueryFilter demonstrates how to add additional filters in an user-defined
43
+ # aggregation function.
44
+ @filters = []
45
+
46
+ @package_name = nil
47
+ @function_name = nil
48
+ @function_args = nil
49
+
50
+ # TaskId determines query task id. (Optional)
51
+ @task_id = 0
52
+
53
+ # determines if the query should return data
54
+ @return_data = true
55
+ end
56
+
57
+ def set_aggregate_function(package_name, function_name, function_args=[], return_data=true)
58
+ @package_name = package_name
59
+ @function_name = function_name
60
+ @function_args = function_args
61
+ @return_data = return_data
62
+ end
63
+
64
+ def is_scan?
65
+ return (filters.nil? || (filters.empty?))
66
+ end
67
+
68
+ end # class
69
+
70
+ end
@@ -0,0 +1,68 @@
1
+ # encoding: utf-8
2
+ # Copyright 2014 Aerospike, Inc.
3
+ #
4
+ # Portions may be licensed to Aerospike, Inc. under one or more contributor
5
+ # license agreements.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may not
8
+ # use this file except in compliance with the License. You may obtain a copy of
9
+ # the License at http:#www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ # License for the specific language governing permissions and limitations under
15
+ # the License.
16
+
17
+ require 'thread'
18
+
19
+ require 'aerospike/record'
20
+
21
+ require 'aerospike/command/command'
22
+
23
+ module Aerospike
24
+
25
+ private
26
+
27
+ class StreamCommand < BatchCommand
28
+
29
+ def parse_record_results(receive_size)
30
+ @data_offset = 0
31
+
32
+ while @data_offset < receive_size
33
+ read_bytes(MSG_REMAINING_HEADER_SIZE)
34
+ result_code = @data_buffer.read(5).ord & 0xFF
35
+
36
+ # The only valid server return codes are "ok" and "not found".
37
+ # If other return codes are received, then abort the batch.
38
+ if result_code != 0
39
+ raise Aerospike::Exceptions::Aerospike.new(result_code)
40
+ end
41
+
42
+ info3 = @data_buffer.read(3).ord
43
+
44
+ # If cmd is the end marker of the response, do not proceed further
45
+ return false if (info3 & INFO3_LAST) == INFO3_LAST
46
+
47
+ generation = @data_buffer.read_int32(6)
48
+ expiration = @data_buffer.read_int32(10)
49
+ field_count = @data_buffer.read_int16(18)
50
+ op_count = @data_buffer.read_int16(20)
51
+ key = parse_key(field_count)
52
+
53
+ if result_code == 0
54
+ if @recordset.active?
55
+ @recordset.records.enq(parse_record(key, op_count, generation, expiration))
56
+ else
57
+ expn = @recordset.is_scan? ? SCAN_TERMINATED_EXCEPTION : QUERY_TERMINATED_EXCEPTION
58
+ raise expn
59
+ end
60
+ end
61
+ end # while
62
+
63
+ true
64
+ end
65
+
66
+ end # class
67
+
68
+ end # module
@@ -16,7 +16,7 @@
16
16
 
17
17
  require 'thread'
18
18
  require 'time'
19
- require 'atomic'
19
+ require 'aerospike/atomic/atomic'
20
20
 
21
21
  module Aerospike
22
22
 
@@ -45,6 +45,7 @@ module Aerospike
45
45
  break if completed?
46
46
  sleep(poll_interval.to_f)
47
47
  rescue => e
48
+ Aerospike.logger.error(e)
48
49
  break if failures > allowed_failures
49
50
  failures += 1
50
51
  end
@@ -22,7 +22,14 @@ module Aerospike
22
22
 
23
23
  # Converts an Expiration time to TTL in seconds
24
24
  def self.TTL(secs_from_citrus_leaf_epoc)
25
- CITRUSLEAF_EPOCH+secs_from_citrus_leaf_epoc - Time.now.to_i
25
+ if secs_from_citrus_leaf_epoc == 0
26
+ 0xFFFFFFFF
27
+ else
28
+ now = Time.now.to_i - CITRUSLEAF_EPOCH
29
+ # Record was not expired at server but if it looks expired at client
30
+ # because of delay or clock differences, present it as not-expired.
31
+ secs_from_citrus_leaf_epoc > now ? secs_from_citrus_leaf_epoc - now : 1
32
+ end
26
33
  end
27
34
 
28
35
  end # module
@@ -138,7 +138,7 @@ module Aerospike
138
138
  end
139
139
 
140
140
  def write(buffer, offset)
141
- buffer.write_binary(bytes, offset)
141
+ buffer.write_binary(@bytes, offset)
142
142
  buffer.length
143
143
  end
144
144
 
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Aerospike
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.5"
4
4
  end
metadata CHANGED
@@ -1,46 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aerospike
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
5
- prerelease:
4
+ version: 0.1.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Khosrow Afroozeh
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-10-26 00:00:00.000000000 Z
11
+ date: 2014-12-08 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: atomic
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.1'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.1'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: msgpack
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0.5'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0.5'
46
41
  description: Official Aerospike Client for ruby. Access your Aerospike cluster with
@@ -51,7 +46,12 @@ executables: []
51
46
  extensions: []
52
47
  extra_rdoc_files: []
53
48
  files:
49
+ - CHANGELOG.md
50
+ - LICENSE
51
+ - README.md
52
+ - lib/aerospike.rb
54
53
  - lib/aerospike/aerospike_exception.rb
54
+ - lib/aerospike/atomic/atomic.rb
55
55
  - lib/aerospike/bin.rb
56
56
  - lib/aerospike/client.rb
57
57
  - lib/aerospike/cluster/cluster.rb
@@ -88,12 +88,21 @@ files:
88
88
  - lib/aerospike/ldt/large_stack.rb
89
89
  - lib/aerospike/loggable.rb
90
90
  - lib/aerospike/operation.rb
91
+ - lib/aerospike/policy/batch_policy.rb
91
92
  - lib/aerospike/policy/client_policy.rb
92
93
  - lib/aerospike/policy/generation_policy.rb
93
94
  - lib/aerospike/policy/policy.rb
94
95
  - lib/aerospike/policy/priority.rb
96
+ - lib/aerospike/policy/query_policy.rb
95
97
  - lib/aerospike/policy/record_exists_action.rb
98
+ - lib/aerospike/policy/scan_policy.rb
96
99
  - lib/aerospike/policy/write_policy.rb
100
+ - lib/aerospike/query/filter.rb
101
+ - lib/aerospike/query/query_command.rb
102
+ - lib/aerospike/query/recordset.rb
103
+ - lib/aerospike/query/scan_command.rb
104
+ - lib/aerospike/query/statement.rb
105
+ - lib/aerospike/query/stream_command.rb
97
106
  - lib/aerospike/record.rb
98
107
  - lib/aerospike/result_code.rb
99
108
  - lib/aerospike/task/index_task.rb
@@ -107,35 +116,30 @@ files:
107
116
  - lib/aerospike/value/particle_type.rb
108
117
  - lib/aerospike/value/value.rb
109
118
  - lib/aerospike/version.rb
110
- - lib/aerospike.rb
111
- - CHANGELOG.md
112
- - LICENSE
113
- - README.md
114
119
  homepage: http://www.github.com/aerospike/aerospike-client-ruby
115
120
  licenses:
116
121
  - Apache2.0
117
- post_install_message: ! 'Thank you for using Aerospike!
118
-
119
- You can report issues on github.com/aerospike/aerospike-client-ruby'
122
+ metadata: {}
123
+ post_install_message: |-
124
+ Thank you for using Aerospike!
125
+ You can report issues on github.com/aerospike/aerospike-client-ruby
120
126
  rdoc_options: []
121
127
  require_paths:
122
128
  - lib
123
129
  required_ruby_version: !ruby/object:Gem::Requirement
124
- none: false
125
130
  requirements:
126
- - - ! '>='
131
+ - - ">="
127
132
  - !ruby/object:Gem::Version
128
133
  version: 1.9.3
129
134
  required_rubygems_version: !ruby/object:Gem::Requirement
130
- none: false
131
135
  requirements:
132
- - - ! '>='
136
+ - - ">="
133
137
  - !ruby/object:Gem::Version
134
138
  version: '0'
135
139
  requirements: []
136
140
  rubyforge_project:
137
- rubygems_version: 1.8.23.2
141
+ rubygems_version: 2.2.2
138
142
  signing_key:
139
- specification_version: 3
143
+ specification_version: 4
140
144
  summary: An Aerospike driver for Ruby.
141
145
  test_files: []