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 +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/aerospike.rb +15 -1
- data/lib/aerospike/client.rb +1 -1
- data/lib/aerospike/command/batch_command_get.rb +2 -2
- data/lib/aerospike/command/command.rb +2 -2
- data/lib/aerospike/command/read_command.rb +2 -3
- data/lib/aerospike/command/read_header_command.rb +2 -2
- data/lib/aerospike/key.rb +30 -14
- data/lib/aerospike/policy/write_policy.rb +17 -9
- data/lib/aerospike/query/stream_command.rb +2 -2
- data/lib/aerospike/record.rb +23 -7
- data/lib/aerospike/value/value.rb +1 -1
- data/lib/aerospike/version.rb +1 -1
- metadata +2 -3
- data/lib/aerospike/utils/epoc.rb +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3b1cf8b0aa82d7b20abe743510e5093c22289cb
|
4
|
+
data.tar.gz: 0e6de6aa46848b62e9e2b0797de87f53c26aa22b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1213afa1c9f167ed59a722cc8e947cb3f05a98cc98615d65c1e739159be9f85c31bd9e0b9316e77528388f1a6ddaa6a13a81a11a54930fd88d7724565c19056
|
7
|
+
data.tar.gz: a19838f475d25015dc8959cbc9e90a2d0ab3a1cb94207da4b4ab02c2c442403f19aaf7c3318758fb8ce17e1c3af0c2b8d907936d1337b76e7e709ac68778a5f7
|
data/CHANGELOG.md
CHANGED
@@ -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
|
|
data/lib/aerospike.rb
CHANGED
@@ -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'
|
data/lib/aerospike/client.rb
CHANGED
@@ -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 =
|
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.
|
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 =
|
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 =
|
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
|
data/lib/aerospike/key.rb
CHANGED
@@ -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
|
-
@
|
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
|
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
|
-
|
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, :
|
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
|
53
|
+
# Record expiration; also known as time-to-live (TTL).
|
51
54
|
# Seconds record will live before being removed by the server.
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
|
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 =
|
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)
|
data/lib/aerospike/record.rb
CHANGED
@@ -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, :
|
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
|
-
@
|
31
|
+
@ttl = expiration_to_ttl(rec_exp)
|
30
32
|
@node = node
|
31
33
|
end
|
32
34
|
|
33
35
|
def to_s
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
data/lib/aerospike/version.rb
CHANGED
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.
|
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:
|
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
|
data/lib/aerospike/utils/epoc.rb
DELETED
@@ -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
|