slatedb 0.3.2.beta.3-x86_64-linux
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 +7 -0
- data/LICENSE +176 -0
- data/README.md +632 -0
- data/lib/slatedb/3.3/slatedb.so +0 -0
- data/lib/slatedb/3.4/slatedb.so +0 -0
- data/lib/slatedb/4.0/slatedb.so +0 -0
- data/lib/slatedb/admin.rb +122 -0
- data/lib/slatedb/database.rb +498 -0
- data/lib/slatedb/iterator.rb +31 -0
- data/lib/slatedb/metrics.rb +20 -0
- data/lib/slatedb/reader.rb +154 -0
- data/lib/slatedb/snapshot.rb +86 -0
- data/lib/slatedb/transaction.rb +174 -0
- data/lib/slatedb/version.rb +5 -0
- data/lib/slatedb/write_batch.rb +58 -0
- data/lib/slatedb.rb +21 -0
- metadata +121 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SlateDb
|
|
4
|
+
class Reader
|
|
5
|
+
class << self
|
|
6
|
+
# Open a read-only reader at the given path.
|
|
7
|
+
#
|
|
8
|
+
# @param path [String] The path identifier for the database
|
|
9
|
+
# @param url [String, nil] Optional object store URL
|
|
10
|
+
# @param checkpoint_id [String, nil] Optional checkpoint UUID to read at
|
|
11
|
+
# @param manifest_poll_interval [Integer, nil] Poll interval in milliseconds
|
|
12
|
+
# @param checkpoint_lifetime [Integer, nil] Checkpoint lifetime in milliseconds
|
|
13
|
+
# @param max_memtable_bytes [Integer, nil] Maximum memtable size in bytes
|
|
14
|
+
# @param cache_root [String, nil] Root folder for the reader's local on-disk
|
|
15
|
+
# object-store cache. Setting this enables the cached object store; when it is
|
|
16
|
+
# not set the cache (and `max_open_file_handles`) has no effect.
|
|
17
|
+
# @param max_open_file_handles [Integer, nil] Maximum number of file handles to keep
|
|
18
|
+
# open in the reader's file-handle cache. When the limit is reached, the least
|
|
19
|
+
# recently used handle is closed (default: 1000). Only takes effect when
|
|
20
|
+
# `cache_root` is set. (Requires SlateDB >= 0.13.0)
|
|
21
|
+
# @param merge_operator [Symbol, String, nil] Optional merge operator ("string_concat" or "concat")
|
|
22
|
+
# @yield [reader] If a block is given, yields the reader and ensures it's closed
|
|
23
|
+
# @return [Reader] The opened reader (or block result if block given)
|
|
24
|
+
#
|
|
25
|
+
# @example Open a reader
|
|
26
|
+
# reader = SlateDb::Reader.open("/tmp/mydb")
|
|
27
|
+
# value = reader.get("key")
|
|
28
|
+
# reader.close
|
|
29
|
+
#
|
|
30
|
+
# @example Open with block (auto-close)
|
|
31
|
+
# SlateDb::Reader.open("/tmp/mydb") do |reader|
|
|
32
|
+
# reader.get("key")
|
|
33
|
+
# end # automatically closed
|
|
34
|
+
#
|
|
35
|
+
# @example Open at a specific checkpoint
|
|
36
|
+
# reader = SlateDb::Reader.open("/tmp/mydb", checkpoint_id: "uuid-here")
|
|
37
|
+
#
|
|
38
|
+
# @example Enable the on-disk cache and cap its open file handles
|
|
39
|
+
# reader = SlateDb::Reader.open("/tmp/mydb",
|
|
40
|
+
# cache_root: "/var/cache/slatedb",
|
|
41
|
+
# max_open_file_handles: 256)
|
|
42
|
+
#
|
|
43
|
+
def open(path, url: nil, checkpoint_id: nil,
|
|
44
|
+
manifest_poll_interval: nil, checkpoint_lifetime: nil,
|
|
45
|
+
max_memtable_bytes: nil, cache_root: nil, max_open_file_handles: nil,
|
|
46
|
+
merge_operator: nil)
|
|
47
|
+
opts = {}
|
|
48
|
+
opts[:manifest_poll_interval] = manifest_poll_interval if manifest_poll_interval
|
|
49
|
+
opts[:checkpoint_lifetime] = checkpoint_lifetime if checkpoint_lifetime
|
|
50
|
+
opts[:max_memtable_bytes] = max_memtable_bytes if max_memtable_bytes
|
|
51
|
+
opts[:cache_root] = cache_root if cache_root
|
|
52
|
+
opts[:max_open_file_handles] = max_open_file_handles if max_open_file_handles
|
|
53
|
+
opts[:merge_operator] = merge_operator.to_s if merge_operator
|
|
54
|
+
|
|
55
|
+
reader = _open(path, url, checkpoint_id, opts)
|
|
56
|
+
|
|
57
|
+
if block_given?
|
|
58
|
+
begin
|
|
59
|
+
yield reader
|
|
60
|
+
ensure
|
|
61
|
+
begin
|
|
62
|
+
reader.close
|
|
63
|
+
rescue StandardError
|
|
64
|
+
nil
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
else
|
|
68
|
+
reader
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Get a value by key.
|
|
74
|
+
#
|
|
75
|
+
# @param key [String] The key to look up
|
|
76
|
+
# @param durability_filter [String, nil] Filter by durability level ("remote" or "memory")
|
|
77
|
+
# @param dirty [Boolean, nil] Whether to include uncommitted data
|
|
78
|
+
# @param cache_blocks [Boolean, nil] Whether to cache blocks
|
|
79
|
+
# @return [String, nil] The value, or nil if not found
|
|
80
|
+
#
|
|
81
|
+
def get(key, durability_filter: nil, dirty: nil, cache_blocks: nil)
|
|
82
|
+
opts = {}
|
|
83
|
+
opts[:durability_filter] = durability_filter.to_s if durability_filter
|
|
84
|
+
opts[:dirty] = dirty unless dirty.nil?
|
|
85
|
+
opts[:cache_blocks] = cache_blocks unless cache_blocks.nil?
|
|
86
|
+
|
|
87
|
+
if opts.empty?
|
|
88
|
+
_get(key)
|
|
89
|
+
else
|
|
90
|
+
_get_with_options(key, opts)
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Scan a range of keys.
|
|
95
|
+
#
|
|
96
|
+
# @param start_key [String] The start key (inclusive)
|
|
97
|
+
# @param end_key [String, nil] The end key (exclusive)
|
|
98
|
+
# @return [Iterator] An iterator over key-value pairs
|
|
99
|
+
#
|
|
100
|
+
def scan(start_key, end_key = nil, durability_filter: nil, dirty: nil,
|
|
101
|
+
read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil, &)
|
|
102
|
+
opts = {}
|
|
103
|
+
opts[:durability_filter] = durability_filter.to_s if durability_filter
|
|
104
|
+
opts[:dirty] = dirty unless dirty.nil?
|
|
105
|
+
opts[:read_ahead_bytes] = read_ahead_bytes if read_ahead_bytes
|
|
106
|
+
opts[:cache_blocks] = cache_blocks unless cache_blocks.nil?
|
|
107
|
+
opts[:max_fetch_tasks] = max_fetch_tasks if max_fetch_tasks
|
|
108
|
+
|
|
109
|
+
iter = if opts.empty?
|
|
110
|
+
_scan(start_key, end_key)
|
|
111
|
+
else
|
|
112
|
+
_scan_with_options(start_key, end_key, opts)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
if block_given?
|
|
116
|
+
iter.each(&)
|
|
117
|
+
else
|
|
118
|
+
iter
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Scan all keys with a given prefix.
|
|
123
|
+
#
|
|
124
|
+
# @param prefix [String] The key prefix to scan
|
|
125
|
+
# @param durability_filter [String, nil] Filter by durability level
|
|
126
|
+
# @param dirty [Boolean, nil] Whether to include uncommitted data
|
|
127
|
+
# @param read_ahead_bytes [Integer, nil] Number of bytes to read ahead
|
|
128
|
+
# @param cache_blocks [Boolean, nil] Whether to cache blocks
|
|
129
|
+
# @param max_fetch_tasks [Integer, nil] Maximum number of fetch tasks
|
|
130
|
+
# @return [Iterator] An iterator over key-value pairs
|
|
131
|
+
#
|
|
132
|
+
def scan_prefix(prefix, durability_filter: nil, dirty: nil,
|
|
133
|
+
read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil, &)
|
|
134
|
+
opts = {}
|
|
135
|
+
opts[:durability_filter] = durability_filter.to_s if durability_filter
|
|
136
|
+
opts[:dirty] = dirty unless dirty.nil?
|
|
137
|
+
opts[:read_ahead_bytes] = read_ahead_bytes if read_ahead_bytes
|
|
138
|
+
opts[:cache_blocks] = cache_blocks unless cache_blocks.nil?
|
|
139
|
+
opts[:max_fetch_tasks] = max_fetch_tasks if max_fetch_tasks
|
|
140
|
+
|
|
141
|
+
iter = if opts.empty?
|
|
142
|
+
_scan_prefix(prefix)
|
|
143
|
+
else
|
|
144
|
+
_scan_prefix_with_options(prefix, opts)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
if block_given?
|
|
148
|
+
iter.each(&)
|
|
149
|
+
else
|
|
150
|
+
iter
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SlateDb
|
|
4
|
+
class Snapshot
|
|
5
|
+
# Get a value by key from the snapshot.
|
|
6
|
+
#
|
|
7
|
+
# @param key [String] The key to look up
|
|
8
|
+
# @param durability_filter [String, nil] Filter by durability level
|
|
9
|
+
# @param dirty [Boolean, nil] Whether to include uncommitted data
|
|
10
|
+
# @param cache_blocks [Boolean, nil] Whether to cache blocks
|
|
11
|
+
# @return [String, nil] The value, or nil if not found
|
|
12
|
+
#
|
|
13
|
+
def get(key, durability_filter: nil, dirty: nil, cache_blocks: nil)
|
|
14
|
+
opts = {}
|
|
15
|
+
opts[:durability_filter] = durability_filter.to_s if durability_filter
|
|
16
|
+
opts[:dirty] = dirty unless dirty.nil?
|
|
17
|
+
opts[:cache_blocks] = cache_blocks unless cache_blocks.nil?
|
|
18
|
+
|
|
19
|
+
if opts.empty?
|
|
20
|
+
_get(key)
|
|
21
|
+
else
|
|
22
|
+
_get_with_options(key, opts)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Scan a range of keys from the snapshot.
|
|
27
|
+
#
|
|
28
|
+
# @param start_key [String] The start key (inclusive)
|
|
29
|
+
# @param end_key [String, nil] The end key (exclusive)
|
|
30
|
+
# @return [Iterator] An iterator over key-value pairs
|
|
31
|
+
#
|
|
32
|
+
def scan(start_key, end_key = nil, durability_filter: nil, dirty: nil,
|
|
33
|
+
read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil, &)
|
|
34
|
+
opts = {}
|
|
35
|
+
opts[:durability_filter] = durability_filter.to_s if durability_filter
|
|
36
|
+
opts[:dirty] = dirty unless dirty.nil?
|
|
37
|
+
opts[:read_ahead_bytes] = read_ahead_bytes if read_ahead_bytes
|
|
38
|
+
opts[:cache_blocks] = cache_blocks unless cache_blocks.nil?
|
|
39
|
+
opts[:max_fetch_tasks] = max_fetch_tasks if max_fetch_tasks
|
|
40
|
+
|
|
41
|
+
iter = if opts.empty?
|
|
42
|
+
_scan(start_key, end_key)
|
|
43
|
+
else
|
|
44
|
+
_scan_with_options(start_key, end_key, opts)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
if block_given?
|
|
48
|
+
iter.each(&)
|
|
49
|
+
else
|
|
50
|
+
iter
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Scan all keys with a given prefix from the snapshot.
|
|
55
|
+
#
|
|
56
|
+
# @param prefix [String] The key prefix to scan
|
|
57
|
+
# @param durability_filter [String, nil] Filter by durability level
|
|
58
|
+
# @param dirty [Boolean, nil] Whether to include uncommitted data
|
|
59
|
+
# @param read_ahead_bytes [Integer, nil] Number of bytes to read ahead
|
|
60
|
+
# @param cache_blocks [Boolean, nil] Whether to cache blocks
|
|
61
|
+
# @param max_fetch_tasks [Integer, nil] Maximum number of fetch tasks
|
|
62
|
+
# @return [Iterator] An iterator over key-value pairs
|
|
63
|
+
#
|
|
64
|
+
def scan_prefix(prefix, durability_filter: nil, dirty: nil,
|
|
65
|
+
read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil, &)
|
|
66
|
+
opts = {}
|
|
67
|
+
opts[:durability_filter] = durability_filter.to_s if durability_filter
|
|
68
|
+
opts[:dirty] = dirty unless dirty.nil?
|
|
69
|
+
opts[:read_ahead_bytes] = read_ahead_bytes if read_ahead_bytes
|
|
70
|
+
opts[:cache_blocks] = cache_blocks unless cache_blocks.nil?
|
|
71
|
+
opts[:max_fetch_tasks] = max_fetch_tasks if max_fetch_tasks
|
|
72
|
+
|
|
73
|
+
iter = if opts.empty?
|
|
74
|
+
_scan_prefix(prefix)
|
|
75
|
+
else
|
|
76
|
+
_scan_prefix_with_options(prefix, opts)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
if block_given?
|
|
80
|
+
iter.each(&)
|
|
81
|
+
else
|
|
82
|
+
iter
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SlateDb
|
|
4
|
+
class Transaction
|
|
5
|
+
# Get a value by key within the transaction.
|
|
6
|
+
#
|
|
7
|
+
# @param key [String] The key to look up
|
|
8
|
+
# @param durability_filter [String, nil] Filter by durability level
|
|
9
|
+
# @param dirty [Boolean, nil] Whether to include uncommitted data
|
|
10
|
+
# @param cache_blocks [Boolean, nil] Whether to cache blocks
|
|
11
|
+
# @return [String, nil] The value, or nil if not found
|
|
12
|
+
#
|
|
13
|
+
def get(key, durability_filter: nil, dirty: nil, cache_blocks: nil)
|
|
14
|
+
opts = {}
|
|
15
|
+
opts[:durability_filter] = durability_filter.to_s if durability_filter
|
|
16
|
+
opts[:dirty] = dirty unless dirty.nil?
|
|
17
|
+
opts[:cache_blocks] = cache_blocks unless cache_blocks.nil?
|
|
18
|
+
|
|
19
|
+
if opts.empty?
|
|
20
|
+
_get(key)
|
|
21
|
+
else
|
|
22
|
+
_get_with_options(key, opts)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Store a key-value pair within the transaction.
|
|
27
|
+
#
|
|
28
|
+
# @param key [String] The key to store
|
|
29
|
+
# @param value [String] The value to store
|
|
30
|
+
# @param ttl [Integer, nil] Time-to-live in milliseconds
|
|
31
|
+
# @return [void]
|
|
32
|
+
#
|
|
33
|
+
def put(key, value, ttl: nil)
|
|
34
|
+
if ttl
|
|
35
|
+
_put_with_options(key, value, { ttl: ttl })
|
|
36
|
+
else
|
|
37
|
+
_put(key, value)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Delete a key within the transaction.
|
|
42
|
+
#
|
|
43
|
+
# @param key [String] The key to delete
|
|
44
|
+
# @return [void]
|
|
45
|
+
#
|
|
46
|
+
def delete(key)
|
|
47
|
+
_delete(key)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Merge a value within the transaction.
|
|
51
|
+
#
|
|
52
|
+
# @param key [String] The key to merge into
|
|
53
|
+
# @param value [String] The merge operand to apply
|
|
54
|
+
# @param ttl [Integer, nil] Time-to-live in milliseconds
|
|
55
|
+
# @return [void]
|
|
56
|
+
#
|
|
57
|
+
def merge(key, value, ttl: nil)
|
|
58
|
+
if ttl
|
|
59
|
+
_merge_with_options(key, value, { ttl: ttl })
|
|
60
|
+
else
|
|
61
|
+
_merge(key, value)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Scan a range of keys within the transaction.
|
|
66
|
+
#
|
|
67
|
+
# @param start_key [String] The start key (inclusive)
|
|
68
|
+
# @param end_key [String, nil] The end key (exclusive)
|
|
69
|
+
# @return [Iterator] An iterator over key-value pairs
|
|
70
|
+
#
|
|
71
|
+
def scan(start_key, end_key = nil, durability_filter: nil, dirty: nil,
|
|
72
|
+
read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil, &)
|
|
73
|
+
opts = {}
|
|
74
|
+
opts[:durability_filter] = durability_filter.to_s if durability_filter
|
|
75
|
+
opts[:dirty] = dirty unless dirty.nil?
|
|
76
|
+
opts[:read_ahead_bytes] = read_ahead_bytes if read_ahead_bytes
|
|
77
|
+
opts[:cache_blocks] = cache_blocks unless cache_blocks.nil?
|
|
78
|
+
opts[:max_fetch_tasks] = max_fetch_tasks if max_fetch_tasks
|
|
79
|
+
|
|
80
|
+
iter = if opts.empty?
|
|
81
|
+
_scan(start_key, end_key)
|
|
82
|
+
else
|
|
83
|
+
_scan_with_options(start_key, end_key, opts)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
if block_given?
|
|
87
|
+
iter.each(&)
|
|
88
|
+
else
|
|
89
|
+
iter
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Scan all keys with a given prefix within the transaction.
|
|
94
|
+
#
|
|
95
|
+
# @param prefix [String] The key prefix to scan
|
|
96
|
+
# @param durability_filter [String, nil] Filter by durability level
|
|
97
|
+
# @param dirty [Boolean, nil] Whether to include uncommitted data
|
|
98
|
+
# @param read_ahead_bytes [Integer, nil] Number of bytes to read ahead
|
|
99
|
+
# @param cache_blocks [Boolean, nil] Whether to cache blocks
|
|
100
|
+
# @param max_fetch_tasks [Integer, nil] Maximum number of fetch tasks
|
|
101
|
+
# @return [Iterator] An iterator over key-value pairs
|
|
102
|
+
#
|
|
103
|
+
def scan_prefix(prefix, durability_filter: nil, dirty: nil,
|
|
104
|
+
read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil, &)
|
|
105
|
+
opts = {}
|
|
106
|
+
opts[:durability_filter] = durability_filter.to_s if durability_filter
|
|
107
|
+
opts[:dirty] = dirty unless dirty.nil?
|
|
108
|
+
opts[:read_ahead_bytes] = read_ahead_bytes if read_ahead_bytes
|
|
109
|
+
opts[:cache_blocks] = cache_blocks unless cache_blocks.nil?
|
|
110
|
+
opts[:max_fetch_tasks] = max_fetch_tasks if max_fetch_tasks
|
|
111
|
+
|
|
112
|
+
iter = if opts.empty?
|
|
113
|
+
_scan_prefix(prefix)
|
|
114
|
+
else
|
|
115
|
+
_scan_prefix_with_options(prefix, opts)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
if block_given?
|
|
119
|
+
iter.each(&)
|
|
120
|
+
else
|
|
121
|
+
iter
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# Mark keys as read for conflict detection.
|
|
126
|
+
#
|
|
127
|
+
# This explicitly tracks reads for conflict checking in serializable isolation,
|
|
128
|
+
# allowing selective read-write conflict detection even when keys weren't
|
|
129
|
+
# actually read via get().
|
|
130
|
+
#
|
|
131
|
+
# @param keys [Array<String>] The keys to mark as read
|
|
132
|
+
# @return [void]
|
|
133
|
+
#
|
|
134
|
+
# @example Mark keys for conflict detection
|
|
135
|
+
# db.transaction(isolation: :serializable) do |txn|
|
|
136
|
+
# txn.mark_read(["key1", "key2"])
|
|
137
|
+
# # These keys will now be checked for conflicts on commit
|
|
138
|
+
# txn.put("key3", "value")
|
|
139
|
+
# end
|
|
140
|
+
#
|
|
141
|
+
def mark_read(keys)
|
|
142
|
+
_mark_read(Array(keys))
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# Commit the transaction.
|
|
146
|
+
#
|
|
147
|
+
# @param await_durable [Boolean, nil] Whether to wait for durability (default: true)
|
|
148
|
+
# @param seqnum [Integer, nil] User-supplied sequence number for the commit.
|
|
149
|
+
# When provided (and non-zero), it is used instead of the internally
|
|
150
|
+
# generated sequence number and must be strictly greater than the current
|
|
151
|
+
# maximum sequence number. (Requires SlateDB >= 0.13.0)
|
|
152
|
+
# @return [void]
|
|
153
|
+
#
|
|
154
|
+
# @example Commit a transaction
|
|
155
|
+
# txn = db.begin_transaction
|
|
156
|
+
# txn.put("key", "value")
|
|
157
|
+
# txn.commit
|
|
158
|
+
#
|
|
159
|
+
# @example Commit with an explicit sequence number
|
|
160
|
+
# txn.commit(seqnum: 99)
|
|
161
|
+
#
|
|
162
|
+
def commit(await_durable: nil, seqnum: nil)
|
|
163
|
+
opts = {}
|
|
164
|
+
opts[:await_durable] = await_durable unless await_durable.nil?
|
|
165
|
+
opts[:seqnum] = seqnum if seqnum
|
|
166
|
+
|
|
167
|
+
if opts.empty?
|
|
168
|
+
_commit
|
|
169
|
+
else
|
|
170
|
+
_commit_with_options(opts)
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SlateDb
|
|
4
|
+
class WriteBatch
|
|
5
|
+
# Add a put operation to the batch.
|
|
6
|
+
#
|
|
7
|
+
# @param key [String] The key to store
|
|
8
|
+
# @param value [String] The value to store
|
|
9
|
+
# @param ttl [Integer, nil] Time-to-live in milliseconds
|
|
10
|
+
# @return [self] Returns self for method chaining
|
|
11
|
+
#
|
|
12
|
+
# @example
|
|
13
|
+
# batch.put("key", "value")
|
|
14
|
+
# batch.put("key2", "value2", ttl: 60_000)
|
|
15
|
+
#
|
|
16
|
+
def put(key, value, ttl: nil)
|
|
17
|
+
if ttl
|
|
18
|
+
_put_with_options(key, value, { ttl: ttl })
|
|
19
|
+
else
|
|
20
|
+
_put(key, value)
|
|
21
|
+
end
|
|
22
|
+
self
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Add a delete operation to the batch.
|
|
26
|
+
#
|
|
27
|
+
# @param key [String] The key to delete
|
|
28
|
+
# @return [self] Returns self for method chaining
|
|
29
|
+
#
|
|
30
|
+
# @example
|
|
31
|
+
# batch.delete("key")
|
|
32
|
+
#
|
|
33
|
+
def delete(key)
|
|
34
|
+
_delete(key)
|
|
35
|
+
self
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Add a merge operation to the batch.
|
|
39
|
+
#
|
|
40
|
+
# @param key [String] The key to merge into
|
|
41
|
+
# @param value [String] The merge operand to apply
|
|
42
|
+
# @param ttl [Integer, nil] Time-to-live in milliseconds
|
|
43
|
+
# @return [self] Returns self for method chaining
|
|
44
|
+
#
|
|
45
|
+
# @example
|
|
46
|
+
# batch.merge("key", "part1")
|
|
47
|
+
# batch.merge("key", "part2", ttl: 30_000)
|
|
48
|
+
#
|
|
49
|
+
def merge(key, value, ttl: nil)
|
|
50
|
+
if ttl
|
|
51
|
+
_merge_with_options(key, value, { ttl: ttl })
|
|
52
|
+
else
|
|
53
|
+
_merge(key, value)
|
|
54
|
+
end
|
|
55
|
+
self
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
data/lib/slatedb.rb
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "slatedb/version"
|
|
4
|
+
|
|
5
|
+
# Load the native extension
|
|
6
|
+
begin
|
|
7
|
+
RUBY_VERSION =~ /(\d+\.\d+)/
|
|
8
|
+
require "slatedb/#{Regexp.last_match(1)}/slatedb"
|
|
9
|
+
rescue LoadError
|
|
10
|
+
require "slatedb/slatedb"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Load Ruby class extensions
|
|
14
|
+
require_relative "slatedb/database"
|
|
15
|
+
require_relative "slatedb/iterator"
|
|
16
|
+
require_relative "slatedb/write_batch"
|
|
17
|
+
require_relative "slatedb/transaction"
|
|
18
|
+
require_relative "slatedb/snapshot"
|
|
19
|
+
require_relative "slatedb/reader"
|
|
20
|
+
require_relative "slatedb/admin"
|
|
21
|
+
require_relative "slatedb/metrics"
|
metadata
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: slatedb
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.3.2.beta.3
|
|
5
|
+
platform: x86_64-linux
|
|
6
|
+
authors:
|
|
7
|
+
- SlateDB Contributors
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-06-16 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: rake
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '13.4'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '13.4'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake-compiler
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '1.3'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '1.3'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.13'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.13'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rubocop
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '1.86'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '1.86'
|
|
69
|
+
description: A cloud-native embedded key-value store built on object storage
|
|
70
|
+
email:
|
|
71
|
+
- slatedb@example.com
|
|
72
|
+
executables: []
|
|
73
|
+
extensions: []
|
|
74
|
+
extra_rdoc_files: []
|
|
75
|
+
files:
|
|
76
|
+
- LICENSE
|
|
77
|
+
- README.md
|
|
78
|
+
- lib/slatedb.rb
|
|
79
|
+
- lib/slatedb/3.3/slatedb.so
|
|
80
|
+
- lib/slatedb/3.4/slatedb.so
|
|
81
|
+
- lib/slatedb/4.0/slatedb.so
|
|
82
|
+
- lib/slatedb/admin.rb
|
|
83
|
+
- lib/slatedb/database.rb
|
|
84
|
+
- lib/slatedb/iterator.rb
|
|
85
|
+
- lib/slatedb/metrics.rb
|
|
86
|
+
- lib/slatedb/reader.rb
|
|
87
|
+
- lib/slatedb/snapshot.rb
|
|
88
|
+
- lib/slatedb/transaction.rb
|
|
89
|
+
- lib/slatedb/version.rb
|
|
90
|
+
- lib/slatedb/write_batch.rb
|
|
91
|
+
homepage: https://github.com/catkins/slatedb-rb
|
|
92
|
+
licenses:
|
|
93
|
+
- Apache-2.0
|
|
94
|
+
metadata:
|
|
95
|
+
homepage_uri: https://github.com/catkins/slatedb-rb
|
|
96
|
+
source_code_uri: https://github.com/catkins/slatedb-rb
|
|
97
|
+
changelog_uri: https://github.com/catkins/slatedb-rb/blob/main/CHANGELOG.md
|
|
98
|
+
rubygems_mfa_required: 'true'
|
|
99
|
+
post_install_message:
|
|
100
|
+
rdoc_options: []
|
|
101
|
+
require_paths:
|
|
102
|
+
- lib
|
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
104
|
+
requirements:
|
|
105
|
+
- - ">="
|
|
106
|
+
- !ruby/object:Gem::Version
|
|
107
|
+
version: '3.3'
|
|
108
|
+
- - "<"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: 4.1.dev
|
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
|
+
requirements:
|
|
113
|
+
- - ">="
|
|
114
|
+
- !ruby/object:Gem::Version
|
|
115
|
+
version: '0'
|
|
116
|
+
requirements: []
|
|
117
|
+
rubygems_version: 3.5.23
|
|
118
|
+
signing_key:
|
|
119
|
+
specification_version: 4
|
|
120
|
+
summary: Ruby bindings for SlateDB
|
|
121
|
+
test_files: []
|