aerospike 2.2.1 → 2.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 326faeb8584bc6c84a0bb1f4e7c7427ec321cefb
4
- data.tar.gz: acf465f44ff7d7fab289b6bc2935edfc67fe8740
3
+ metadata.gz: d3b1cf8b0aa82d7b20abe743510e5093c22289cb
4
+ data.tar.gz: 0e6de6aa46848b62e9e2b0797de87f53c26aa22b
5
5
  SHA512:
6
- metadata.gz: c1a033227dd57f6df5b9bb289c5bce1a306eabf1c6e565b63c1afb59cfa41d8a0d2dc5c19c571e0158788c03774c8fdb6cc2920f28ca1e871863eae306c7ac7e
7
- data.tar.gz: 1e3955fb7b008fc51aaff9f33edfba63f4102d2fbe2293b06fca813a89f7ccdf089905718dfa23be5f003225e01bcc20994e441cde887134d37133de12944260
6
+ metadata.gz: e1213afa1c9f167ed59a722cc8e947cb3f05a98cc98615d65c1e739159be9f85c31bd9e0b9316e77528388f1a6ddaa6a13a81a11a54930fd88d7724565c19056
7
+ data.tar.gz: a19838f475d25015dc8959cbc9e90a2d0ab3a1cb94207da4b4ab02c2c442403f19aaf7c3318758fb8ce17e1c3af0c2b8d907936d1337b76e7e709ac68778a5f7
@@ -1,3 +1,12 @@
1
+ v2.3.0 / 2017-01-04
2
+ ===================
3
+
4
+ * **Bug Fixes**
5
+ * Fix BytesValue used as record key. [#42](https://github.com/aerospike/aerospike-client-ruby/issues/42)
6
+
7
+ * **Changes**
8
+ * Deprecate unsupport key types - only integer, string and byte keys are supported. [#43](https://github.com/aerospike/aerospike-client-ruby/issues/43)
9
+
1
10
  v2.2.1 / 2016-11-14
2
11
  ===================
3
12
 
@@ -1,4 +1,19 @@
1
1
  # encoding: utf-8
2
+ # Copyright 2014-2016 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
+
2
17
  require "logger"
3
18
  require "stringio"
4
19
  require "monitor"
@@ -13,7 +28,6 @@ require 'aerospike/client'
13
28
  require 'aerospike/utils/pool'
14
29
  require 'aerospike/utils/packer'
15
30
  require 'aerospike/utils/unpacker'
16
- require 'aerospike/utils/epoc'
17
31
  require 'aerospike/utils/buffer'
18
32
  require 'aerospike/host'
19
33
  require 'aerospike/loggable'
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # Copyright 2014 Aerospike, Inc.
2
+ # Copyright 2014-2016 Aerospike, Inc.
3
3
  #
4
4
  # Portions may be licensed to Aerospike, Inc. under one or more contributor
5
5
  # license agreements.
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # Copyright 2014 Aerospike, Inc.
2
+ # Copyright 2014-2016 Aerospike, Inc.
3
3
  #
4
4
  # Portions may be licensed to Aerospike, Inc. under one or more contributor
5
5
  # license agreements.
@@ -59,7 +59,7 @@ module Aerospike
59
59
  return false if (info3 & INFO3_LAST) == INFO3_LAST
60
60
 
61
61
  generation = @data_buffer.read_int32(6)
62
- expiration = Aerospike.TTL(@data_buffer.read_int32(10))
62
+ expiration = @data_buffer.read_int32(10)
63
63
  field_count = @data_buffer.read_int16(18)
64
64
  op_count = @data_buffer.read_int16(20)
65
65
  key = parse_key(field_count)
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # Copyright 2014 Aerospike, Inc.
2
+ # Copyright 2014-2016 Aerospike, Inc.
3
3
  #
4
4
  # Portions may be licensed to Aerospike, Inc. under one or more contributor
5
5
  # license agreements.
@@ -610,7 +610,7 @@ module Aerospike
610
610
  @data_buffer.write_byte(0, 12) # unused
611
611
  @data_buffer.write_byte(0, 13) # clear the result code
612
612
  @data_buffer.write_uint32(generation, 14)
613
- @data_buffer.write_uint32(policy.expiration, 18)
613
+ @data_buffer.write_uint32(policy.ttl, 18)
614
614
 
615
615
  # Initialize timeout. It will be written later.
616
616
  @data_buffer.write_byte(0, 22)
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # Copyright 2014 Aerospike, Inc.
2
+ # Copyright 2014-2016 Aerospike, Inc.
3
3
  #
4
4
  # Portions may be licensed to Aerospike, Inc. under one or more contributor
5
5
  # license agreements.
@@ -18,7 +18,6 @@ require 'aerospike/record'
18
18
 
19
19
  require 'aerospike/command/single_command'
20
20
  require 'aerospike/policy/operate_policy'
21
- require 'aerospike/utils/epoc'
22
21
  require 'aerospike/value/value'
23
22
 
24
23
  module Aerospike
@@ -57,7 +56,7 @@ module Aerospike
57
56
  header_length = @data_buffer.read(8).ord
58
57
  result_code = @data_buffer.read(13).ord & 0xFF
59
58
  generation = @data_buffer.read_int32(14)
60
- expiration = Aerospike.TTL(@data_buffer.read_int32(18))
59
+ expiration = @data_buffer.read_int32(18)
61
60
  field_count = @data_buffer.read_int16(26) # almost certainly 0
62
61
  op_count = @data_buffer.read_int16(28)
63
62
  receive_size = (sz & 0xFFFFFFFFFFFF) - header_length
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # Copyright 2014 Aerospike, Inc.
2
+ # Copyright 2014-2016 Aerospike, Inc.
3
3
  #
4
4
  # Portions may be licensed to Aerospike, Inc. under one or more contributor
5
5
  # license agreements.
@@ -45,7 +45,7 @@ module Aerospike
45
45
 
46
46
  if result_code == 0
47
47
  generation = @data_buffer.read_int32(14)
48
- expiration = Aerospike.TTL(@data_buffer.read_int32(18))
48
+ expiration = @data_buffer.read_int32(18)
49
49
  @record = Record.new(@node, @key, nil, generation, expiration)
50
50
  else
51
51
  if result_code == Aerospike::ResultCode::KEY_NOT_FOUND_ERROR
@@ -41,23 +41,24 @@ module Aerospike
41
41
  @v1_compatibility
42
42
  end
43
43
 
44
+ # Keys other than integers, strings and bytes are unsupported and will trigger a warning if used.
45
+ # Starting with v3 the client will raise an error instead of a warning.
46
+ # ref. https://github.com/aerospike/aerospike-client-ruby/issues/43
47
+ def self.disable_unsupported_key_warning!(enable_warning = false)
48
+ @unsupported_key_warning = enable_warning
49
+ end
50
+ def self.warn_unsupported_key?
51
+ @unsupported_key_warning
52
+ end
53
+
44
54
  attr_reader :namespace, :set_name, :digest
45
- attr_reader :v1_compatible
46
- alias_method :v1_compatible?, :v1_compatible
47
55
 
48
56
  def initialize(ns, set, val, digest=nil, v1_compatible: self.class.v1_compatible?)
49
57
  @namespace = ns
50
58
  @set_name = set
51
59
  @user_key = Value.of(val)
52
- @v1_compatible = v1_compatible
53
-
54
- unless digest
55
- compute_digest
56
- else
57
- @digest = digest
58
- end
59
-
60
- self
60
+ check_key!(@namespace, @set_name, @user_key, !digest.nil?)
61
+ @digest = digest || compute_digest(v1_compatible)
61
62
  end
62
63
 
63
64
 
@@ -86,7 +87,20 @@ module Aerospike
86
87
 
87
88
  private
88
89
 
89
- def compute_digest
90
+ def valid_key?(value, has_digest)
91
+ value.is_a?(IntegerValue) ||
92
+ value.is_a?(StringValue) ||
93
+ value.is_a?(BytesValue) ||
94
+ (has_digest && value.is_a?(NullValue))
95
+ end
96
+
97
+ def check_key!(ns, set, value, has_digest)
98
+ if self.class.warn_unsupported_key? && !valid_key?(value, has_digest)
99
+ warn("Unsupported key type: #{value.class.name} - only Integer, String and Bytes are supported")
100
+ end
101
+ end
102
+
103
+ def compute_digest(v1_compatible = false)
90
104
  key_type = @user_key.type
91
105
  key_bytes = @user_key.to_bytes
92
106
 
@@ -95,7 +109,7 @@ module Aerospike
95
109
  end
96
110
 
97
111
  # v1.0.12 and prior computed integer key digest using little endian byte order
98
- if key_type == Aerospike::ParticleType::INTEGER && v1_compatible?
112
+ if key_type == Aerospike::ParticleType::INTEGER && v1_compatible
99
113
  key_bytes.reverse!
100
114
  end
101
115
 
@@ -107,10 +121,12 @@ module Aerospike
107
121
  h.update(@set_name)
108
122
  h.update(key_type.chr)
109
123
  h.update(key_bytes)
110
- @digest = h.digest
124
+ digest = h.digest
111
125
 
112
126
  # put the hash object back to the pool
113
127
  @@digest_pool.offer(h)
128
+
129
+ digest
114
130
  end
115
131
 
116
132
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # Copyright 2014 Aerospike, Inc.
2
+ # Copyright 2014-2016 Aerospike, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -24,9 +24,12 @@ module Aerospike
24
24
  class WritePolicy < Policy
25
25
 
26
26
  attr_accessor :record_exists_action, :generation_policy,
27
- :generation, :expiration, :send_key, :commit_level,
27
+ :generation, :ttl, :send_key, :commit_level,
28
28
  :durable_delete
29
29
 
30
+ alias expiration ttl
31
+ alias expiration= ttl=
32
+
30
33
  def initialize(opt={})
31
34
  super(opt)
32
35
 
@@ -47,14 +50,19 @@ module Aerospike
47
50
  # the expected generation would be 0
48
51
  @generation = opt[:generation] || 0
49
52
 
50
- # Record expiration. Also known as ttl (time to live).
53
+ # Record expiration; also known as time-to-live (TTL).
51
54
  # Seconds record will live before being removed by the server.
52
- # Expiration values:
53
- # -1: Never expire for Aerospike 2 server versions >= 2.7.2 and Aerospike 3 server
54
- # versions >= 3.1.4. Do not use -1 for older servers.
55
- # 0: Default to namespace configuration variable "default-ttl" on the server.
56
- # > 0: Actual expiration in seconds.
57
- @expiration = opt[:expiration] || opt[:ttl] || 0
55
+ #
56
+ # Supported values:
57
+ # - `Aerospike::TTL::NEVER_EXPIRE`: Never expire record; requires Aerospike 2
58
+ # server versions >= 2.7.2 or Aerospike 3 server versions >= 3.1.4. Do
59
+ # not use for older servers.
60
+ # - `Aerospike::TTL::NAMESPACE_DEFAULT`: Default to namespace configuration
61
+ # variable "default-ttl" on the server.
62
+ # - `Aerospike::TTL::DONT_UPDATE`: Do not change a record's expiration date
63
+ # when updating the record. Requires Aerospike server v3.10.1 or later.
64
+ # - Any value > 0: Actual time-to-live in seconds.
65
+ @ttl = opt[:ttl] || opt[:expiration] || 0
58
66
 
59
67
  # Send user defined key in addition to hash digest on a record put.
60
68
  # The default is to send the user defined key.
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # Copyright 2014 Aerospike, Inc.
2
+ # Copyright 2014-2016 Aerospike, Inc.
3
3
  #
4
4
  # Portions may be licensed to Aerospike, Inc. under one or more contributor
5
5
  # license agreements.
@@ -53,7 +53,7 @@ module Aerospike
53
53
  return false if (info3 & INFO3_LAST) == INFO3_LAST
54
54
 
55
55
  generation = @data_buffer.read_int32(6)
56
- expiration = Aerospike.TTL(@data_buffer.read_int32(10))
56
+ expiration = @data_buffer.read_int32(10)
57
57
  field_count = @data_buffer.read_int16(18)
58
58
  op_count = @data_buffer.read_int16(20)
59
59
  key = parse_key(field_count)
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # Copyright 2014 Aerospike, Inc.
2
+ # Copyright 2014-2016 Aerospike, Inc.
3
3
  #
4
4
  # Portions may be licensed to Aerospike, Inc. under one or more contributor
5
5
  # license agreements.
@@ -20,21 +20,37 @@ module Aerospike
20
20
 
21
21
  class Record
22
22
 
23
- attr_reader :key, :bins, :generation, :expiration, :node
23
+ attr_reader :key, :bins, :generation, :ttl, :node
24
+
25
+ alias expiration ttl # for backwards compatibility
24
26
 
25
27
  def initialize(node, rec_key, rec_bins, rec_gen, rec_exp)
26
28
  @key = rec_key
27
29
  @bins = rec_bins
28
30
  @generation = rec_gen
29
- @expiration = rec_exp
31
+ @ttl = expiration_to_ttl(rec_exp)
30
32
  @node = node
31
33
  end
32
34
 
33
35
  def to_s
34
- 'key: `' + key.to_s + '` ' +
35
- 'bins: `' + bins.to_s + '` ' +
36
- 'generation: `' + generation.to_s + '` ' +
37
- 'expiration: `' + expiration.to_s + '` '
36
+ "key: `#{key}` bins: `#{bins}` generation: `#{generation}`, ttl: `#{ttl}`"
37
+ end
38
+
39
+ private
40
+
41
+ CITRUSLEAF_EPOCH = 1262304000
42
+
43
+ # Converts an absolute expiration time (in seconds from citrusleaf epoch)
44
+ # to relative time-to-live (TTL) in seconds
45
+ def expiration_to_ttl(secs_from_epoc)
46
+ if secs_from_epoc == 0
47
+ Aerospike::TTL::NEVER_EXPIRE
48
+ else
49
+ now = Time.now.to_i - CITRUSLEAF_EPOCH
50
+ # Record was not expired at server but if it looks expired at client
51
+ # because of delay or clock differences, present it as not-expired.
52
+ secs_from_epoc > now ? secs_from_epoc - now : 1
53
+ end
38
54
  end
39
55
 
40
56
  end
@@ -120,7 +120,7 @@ module Aerospike
120
120
  end
121
121
 
122
122
  def to_bytes
123
- @bytes.bytes
123
+ @bytes
124
124
  end
125
125
 
126
126
  def estimate_size
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Aerospike
3
- VERSION = "2.2.1"
3
+ VERSION = "2.3.0"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aerospike
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Khosrow Afroozeh
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-11-14 00:00:00.000000000 Z
12
+ date: 2017-01-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: msgpack
@@ -131,7 +131,6 @@ files:
131
131
  - lib/aerospike/udf.rb
132
132
  - lib/aerospike/user_role.rb
133
133
  - lib/aerospike/utils/buffer.rb
134
- - lib/aerospike/utils/epoc.rb
135
134
  - lib/aerospike/utils/packer.rb
136
135
  - lib/aerospike/utils/pool.rb
137
136
  - lib/aerospike/utils/unpacker.rb
@@ -1,37 +0,0 @@
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 'time'
18
-
19
- module Aerospike
20
-
21
- private
22
-
23
- CITRUSLEAF_EPOCH = 1262304000
24
-
25
- # Converts an Expiration time to TTL in seconds
26
- def self.TTL(secs_from_citrus_leaf_epoc) #:nodoc:
27
- if secs_from_citrus_leaf_epoc == 0
28
- 0xFFFFFFFF
29
- else
30
- now = Time.now.to_i - CITRUSLEAF_EPOCH
31
- # Record was not expired at server but if it looks expired at client
32
- # because of delay or clock differences, present it as not-expired.
33
- secs_from_citrus_leaf_epoc > now ? secs_from_citrus_leaf_epoc - now : 1
34
- end
35
- end
36
-
37
- end # module