aerospike 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,12 @@
1
+ ## Oct 25 2014 (0.1.1)
2
+
3
+ Minor fixes.
4
+
5
+ * **Changes**:
6
+
7
+ * Fixed String packing header in Hash and Array.
8
+ * #find on LDTs returns `nil` instad of raising an exception if the item is not found.
9
+
10
+ ## Oct 14 2014 (0.1.0)
11
+
12
+ * Initial Release.
data/README.md CHANGED
@@ -2,9 +2,7 @@
2
2
 
3
3
  An Aerospike library for Ruby.
4
4
 
5
- This library is compatible with Ruby 1.9.3+ and supports Linux, Mac OS X and various other BSDs.
6
-
7
- Rubinius is supported, but not JRuby yet.
5
+ This library is compatible with Ruby 1.9.3+ and supports Linux, Mac OS X and various other BSDs. Rubinius is supported, but not JRuby - yet. For the moment, query and scan operations are also not supported.
8
6
 
9
7
 
10
8
  - [Usage](#Usage)
@@ -30,7 +28,7 @@ include Aerospike
30
28
 
31
29
  client = Client.new("127.0.0.1", 3000)
32
30
 
33
- key = Key.new('test', 'test', 'key value')
31
+ key = Key.new('test', 'set name', 'key value')
34
32
  bins = {
35
33
  'bin1' => 'value1',
36
34
  'bin2' => 2,
@@ -72,7 +70,11 @@ Supported operating systems:
72
70
  - other BSDs (untested)
73
71
 
74
72
  <a name="Installation"></a>
75
- ## Installation:
73
+ ## Installation from Ruby gems:
74
+
75
+ 1. gem install aerospike
76
+
77
+ ## Installation from source:
76
78
 
77
79
  1. Install Ruby 1.9.3+
78
80
  2. Install RubyGems
@@ -75,8 +75,8 @@ module Aerospike
75
75
  end
76
76
 
77
77
  if result_code != 0
78
- return if result_code == Aerospike::ResultCode::KEY_NOT_FOUND_ERROR
79
-
78
+ return nil if result_code == Aerospike::ResultCode::KEY_NOT_FOUND_ERROR
79
+ return nil if result_code == Aerospike::ResultCode::LARGE_ITEM_NOT_FOUND
80
80
  if result_code == Aerospike::ResultCode::UDF_BAD_RESPONSE
81
81
  begin
82
82
  @record = parse_record(op_count, field_count, generation, expiration)
@@ -20,6 +20,9 @@ module Aerospike
20
20
 
21
21
  attr_reader :code
22
22
 
23
+ # Value type not supported by Aerospike server
24
+ TYPE_NOT_SUPPORTED = -7
25
+
23
26
  # Asynchronous max concurrent database commands have been exceeded and therefore rejected.
24
27
  COMMAND_REJECTED = -6
25
28
 
@@ -148,6 +151,9 @@ module Aerospike
148
151
  # A user defined function returned an error code.
149
152
  UDF_BAD_RESPONSE = 100
150
153
 
154
+ # The requested item in a large collection was not found.
155
+ LARGE_ITEM_NOT_FOUND = 125
156
+
151
157
  # Secondary index already exists.
152
158
  INDEX_FOUND = 200
153
159
 
@@ -309,6 +315,9 @@ module Aerospike
309
315
  when UDF_BAD_RESPONSE
310
316
  "UDF d error"
311
317
 
318
+ when LARGE_ITEM_NOT_FOUND
319
+ "Large collection item not found"
320
+
312
321
  when INDEX_FOUND
313
322
  "Index already exists"
314
323
 
@@ -49,7 +49,7 @@ module Aerospike
49
49
  res = IntegerValue.new(value)
50
50
  else
51
51
  # big nums > 2**63 are not supported
52
- raise Aerospike::Exceptions::Aerospike.new(TYPE_NOT_SUPPORTED, "Value type #{value.class} not supported.")
52
+ raise Aerospike::Exceptions::Aerospike.new(Aerospike::ResultCode::TYPE_NOT_SUPPORTED, "Value type #{value.class} not supported.")
53
53
  end
54
54
  when String
55
55
  res = StringValue.new(value)
@@ -61,7 +61,7 @@ module Aerospike
61
61
  res = ListValue.new(value)
62
62
  else
63
63
  # throw an exception for anything that is not supported.
64
- raise Aerospike::Exceptions::Aerospike.new(TYPE_NOT_SUPPORTED, "Value type #{value.class} not supported.")
64
+ raise Aerospike::Exceptions::Aerospike.new(Aerospike::ResultCode::TYPE_NOT_SUPPORTED, "Value type #{value.class} not supported.")
65
65
  end
66
66
 
67
67
  res
@@ -143,7 +143,7 @@ module Aerospike
143
143
  end
144
144
 
145
145
  def pack(packer)
146
- packer.write(@bytes.bytes)
146
+ packer.write(Aerospike::ParticleType::BLOB.chr + @bytes)
147
147
  end
148
148
 
149
149
  end # BytesValue
@@ -167,7 +167,7 @@ module Aerospike
167
167
  end
168
168
 
169
169
  def pack(packer)
170
- packer.write(@value)
170
+ packer.write(Aerospike::ParticleType::STRING.chr + @value)
171
171
  end
172
172
 
173
173
  def type
@@ -254,7 +254,6 @@ module Aerospike
254
254
 
255
255
  def pack(packer)
256
256
  packer.write_array_header(@list.length)
257
- # @list.each do |val|
258
257
  for val in @list
259
258
  Value.of(val).pack(packer)
260
259
  end
@@ -335,25 +334,46 @@ module Aerospike
335
334
 
336
335
  protected
337
336
 
338
- def self.bytes_to_particle(type, buf , offset, length)
337
+ def self.normalize_elem(elem)
338
+ case elem
339
+ when String
340
+ elem[1..-1]
341
+ when Array
342
+ normalize_strings_in_array(elem)
343
+ when Hash
344
+ normalize_strings_in_map(elem)
345
+ else
346
+ elem
347
+ end
348
+ end
349
+
350
+ def self.normalize_strings_in_array(arr)
351
+ arr.map! { |elem| normalize_elem(elem) }
352
+ end
353
+
354
+ def self.normalize_strings_in_map(hash)
355
+ hash.inject({}) do |h, (k,v)|
356
+ h.update({ normalize_elem(k) => normalize_elem(v) })
357
+ end
358
+ end
359
+
360
+ def self.bytes_to_particle(type, buf, offset, length)
339
361
 
340
362
  case type
341
363
  when Aerospike::ParticleType::STRING
342
- # StringValue.new(buf.read(offset, length))
343
364
  buf.read(offset, length)
344
365
 
345
366
  when Aerospike::ParticleType::INTEGER
346
- # IntegerValue.new(buf.read_int64(offset))
347
367
  buf.read_int64(offset)
348
368
 
349
369
  when Aerospike::ParticleType::BLOB
350
- buf.read(offse,length)
370
+ buf.read(offset,length)
351
371
 
352
372
  when Aerospike::ParticleType::LIST
353
- MessagePack.unpack(buf.read(offset, length))
373
+ normalize_strings_in_array(MessagePack.unpack(buf.read(offset, length)))
354
374
 
355
375
  when Aerospike::ParticleType::MAP
356
- MessagePack.unpack(buf.read(offset, length))
376
+ normalize_strings_in_map(MessagePack.unpack(buf.read(offset, length)))
357
377
 
358
378
  else
359
379
  nil
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Aerospike
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
metadata CHANGED
@@ -1,54 +1,56 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aerospike
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Khosrow Afroozeh
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-10-14 00:00:00.000000000 Z
12
+ date: 2014-10-25 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: atomic
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - "~>"
19
+ - - ~>
18
20
  - !ruby/object:Gem::Version
19
21
  version: '1.1'
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - "~>"
27
+ - - ~>
25
28
  - !ruby/object:Gem::Version
26
29
  version: '1.1'
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: msgpack
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - "~>"
35
+ - - ~>
32
36
  - !ruby/object:Gem::Version
33
37
  version: '0.5'
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - "~>"
43
+ - - ~>
39
44
  - !ruby/object:Gem::Version
40
45
  version: '0.5'
41
- description: Access your Aerospike cluster with ease of ruby.
46
+ description: Official Aerospike Client for ruby. Access your Aerospike cluster with
47
+ ease of Ruby.
42
48
  email:
43
49
  - khosrow@aerospike.com
44
50
  executables: []
45
51
  extensions: []
46
52
  extra_rdoc_files: []
47
53
  files:
48
- - CHANGELOG.md
49
- - LICENSE
50
- - README.md
51
- - lib/aerospike.rb
52
54
  - lib/aerospike/aerospike_exception.rb
53
55
  - lib/aerospike/bin.rb
54
56
  - lib/aerospike/client.rb
@@ -105,28 +107,35 @@ files:
105
107
  - lib/aerospike/value/particle_type.rb
106
108
  - lib/aerospike/value/value.rb
107
109
  - lib/aerospike/version.rb
108
- homepage: http://www.aerospike.com
110
+ - lib/aerospike.rb
111
+ - CHANGELOG.md
112
+ - LICENSE
113
+ - README.md
114
+ homepage: http://www.github.com/aerospike/aerospike-client-ruby
109
115
  licenses:
110
116
  - Apache2.0
111
- metadata: {}
112
- post_install_message:
117
+ post_install_message: ! 'Thank you for using Aerospike!
118
+
119
+ You can report issues on github.com/aerospike/aerospike-client-ruby'
113
120
  rdoc_options: []
114
121
  require_paths:
115
122
  - lib
116
123
  required_ruby_version: !ruby/object:Gem::Requirement
124
+ none: false
117
125
  requirements:
118
- - - ">="
126
+ - - ! '>='
119
127
  - !ruby/object:Gem::Version
120
- version: '0'
128
+ version: 1.9.3
121
129
  required_rubygems_version: !ruby/object:Gem::Requirement
130
+ none: false
122
131
  requirements:
123
- - - ">="
132
+ - - ! '>='
124
133
  - !ruby/object:Gem::Version
125
134
  version: '0'
126
135
  requirements: []
127
136
  rubyforge_project:
128
- rubygems_version: 2.2.2
137
+ rubygems_version: 1.8.23.2
129
138
  signing_key:
130
- specification_version: 4
139
+ specification_version: 3
131
140
  summary: An Aerospike driver for Ruby.
132
141
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 43af459a6c42c1b95a305424d69c716683a53107
4
- data.tar.gz: ef2921a205b537a29793a2b741b28837f47b3930
5
- SHA512:
6
- metadata.gz: 4d1a1f019763267a48744ba89f5db2d4a182f478ff522246279c3fa5df511c82c3284c1e31ce068374dd58c92a22b9e4b468782339c8adf7c733b5bff88e1969
7
- data.tar.gz: 25700a8862f434d1ba8394f5bd51cc4f79ed0f38d6ae9e881c320f61f8ac886ca875bd0cbfe392a81089f91b41d8bbd71417de4d2e1d02870c636c5b31f777d4