slatedb 0.2.0 → 0.4.4
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/README.md +140 -8
- data/ext/slatedb/Cargo.toml +8 -7
- data/ext/slatedb/src/admin.rs +22 -3
- data/ext/slatedb/src/database.rs +182 -41
- data/ext/slatedb/src/iterator.rs +4 -1
- data/ext/slatedb/src/lib.rs +2 -0
- data/ext/slatedb/src/merge_ops.rs +1 -3
- data/ext/slatedb/src/metrics.rs +47 -0
- data/ext/slatedb/src/reader.rs +85 -25
- data/ext/slatedb/src/snapshot.rs +34 -3
- data/ext/slatedb/src/transaction.rs +50 -9
- data/ext/slatedb/src/utils.rs +46 -4
- data/ext/slatedb/src/write_batch.rs +6 -1
- data/lib/slatedb/database.rb +116 -24
- data/lib/slatedb/metrics.rb +20 -0
- data/lib/slatedb/reader.rb +45 -10
- data/lib/slatedb/snapshot.rb +15 -7
- data/lib/slatedb/transaction.rb +44 -7
- data/lib/slatedb/version.rb +1 -1
- data/lib/slatedb.rb +1 -0
- metadata +15 -13
data/lib/slatedb/database.rb
CHANGED
|
@@ -95,12 +95,44 @@ module SlateDb
|
|
|
95
95
|
end
|
|
96
96
|
end
|
|
97
97
|
|
|
98
|
+
# Get a key-value pair with SlateDB metadata.
|
|
99
|
+
#
|
|
100
|
+
# @param key [String] The key to look up
|
|
101
|
+
# @param durability_filter [String, nil] Filter by durability level ("remote" or "memory")
|
|
102
|
+
# @param dirty [Boolean, nil] Whether to include uncommitted data
|
|
103
|
+
# @param cache_blocks [Boolean, nil] Whether to cache blocks
|
|
104
|
+
# @return [Hash, nil] A hash with :key, :value, :seq, :create_ts, and :expire_ts, or nil if not found
|
|
105
|
+
#
|
|
106
|
+
# @example Inspect metadata
|
|
107
|
+
# entry = db.get_key_value("mykey")
|
|
108
|
+
# entry[:value] # => "myvalue"
|
|
109
|
+
# entry[:seq] # => sequence number
|
|
110
|
+
#
|
|
111
|
+
def get_key_value(key, durability_filter: nil, dirty: nil, cache_blocks: nil)
|
|
112
|
+
opts = {}
|
|
113
|
+
opts[:durability_filter] = durability_filter.to_s if durability_filter
|
|
114
|
+
opts[:dirty] = dirty unless dirty.nil?
|
|
115
|
+
opts[:cache_blocks] = cache_blocks unless cache_blocks.nil?
|
|
116
|
+
|
|
117
|
+
if opts.empty?
|
|
118
|
+
_get_key_value(key)
|
|
119
|
+
else
|
|
120
|
+
_get_key_value_with_options(key, opts)
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
alias get_entry get_key_value
|
|
125
|
+
|
|
98
126
|
# Store a key-value pair.
|
|
99
127
|
#
|
|
100
128
|
# @param key [String] The key to store
|
|
101
129
|
# @param value [String] The value to store
|
|
102
130
|
# @param ttl [Integer, nil] Time-to-live in milliseconds
|
|
103
131
|
# @param await_durable [Boolean] Whether to wait for durability (default: true)
|
|
132
|
+
# @param seqnum [Integer, nil] User-supplied sequence number for this write.
|
|
133
|
+
# When provided (and non-zero), it is used instead of the internally
|
|
134
|
+
# generated sequence number. It must be strictly greater than the current
|
|
135
|
+
# maximum sequence number or the write fails. (Requires SlateDB >= 0.13.0)
|
|
104
136
|
# @return [void]
|
|
105
137
|
#
|
|
106
138
|
# @example Basic put
|
|
@@ -112,10 +144,14 @@ module SlateDb
|
|
|
112
144
|
# @example Put without waiting for durability
|
|
113
145
|
# db.put("mykey", "myvalue", await_durable: false)
|
|
114
146
|
#
|
|
115
|
-
|
|
147
|
+
# @example Put with an explicit sequence number
|
|
148
|
+
# db.put("mykey", "myvalue", seqnum: 42)
|
|
149
|
+
#
|
|
150
|
+
def put(key, value, ttl: nil, await_durable: nil, seqnum: nil)
|
|
116
151
|
opts = {}
|
|
117
152
|
opts[:ttl] = ttl if ttl
|
|
118
153
|
opts[:await_durable] = await_durable unless await_durable.nil?
|
|
154
|
+
opts[:seqnum] = seqnum if seqnum
|
|
119
155
|
|
|
120
156
|
if opts.empty?
|
|
121
157
|
_put(key, value)
|
|
@@ -128,6 +164,8 @@ module SlateDb
|
|
|
128
164
|
#
|
|
129
165
|
# @param key [String] The key to delete
|
|
130
166
|
# @param await_durable [Boolean] Whether to wait for durability (default: true)
|
|
167
|
+
# @param seqnum [Integer, nil] User-supplied sequence number for this write.
|
|
168
|
+
# See {#put} for semantics. (Requires SlateDB >= 0.13.0)
|
|
131
169
|
# @return [void]
|
|
132
170
|
#
|
|
133
171
|
# @example Basic delete
|
|
@@ -136,11 +174,15 @@ module SlateDb
|
|
|
136
174
|
# @example Delete without waiting for durability
|
|
137
175
|
# db.delete("mykey", await_durable: false)
|
|
138
176
|
#
|
|
139
|
-
def delete(key, await_durable: nil)
|
|
140
|
-
|
|
177
|
+
def delete(key, await_durable: nil, seqnum: nil)
|
|
178
|
+
opts = {}
|
|
179
|
+
opts[:await_durable] = await_durable unless await_durable.nil?
|
|
180
|
+
opts[:seqnum] = seqnum if seqnum
|
|
181
|
+
|
|
182
|
+
if opts.empty?
|
|
141
183
|
_delete(key)
|
|
142
184
|
else
|
|
143
|
-
_delete_with_options(key,
|
|
185
|
+
_delete_with_options(key, opts)
|
|
144
186
|
end
|
|
145
187
|
end
|
|
146
188
|
|
|
@@ -153,6 +195,7 @@ module SlateDb
|
|
|
153
195
|
# @param read_ahead_bytes [Integer, nil] Number of bytes to read ahead
|
|
154
196
|
# @param cache_blocks [Boolean, nil] Whether to cache blocks
|
|
155
197
|
# @param max_fetch_tasks [Integer, nil] Maximum number of fetch tasks
|
|
198
|
+
# @param order [Symbol, String, nil] Iteration order (:asc/:ascending or :desc/:descending)
|
|
156
199
|
# @return [Iterator] An iterator over key-value pairs
|
|
157
200
|
#
|
|
158
201
|
# @example Basic scan
|
|
@@ -171,13 +214,15 @@ module SlateDb
|
|
|
171
214
|
# end
|
|
172
215
|
#
|
|
173
216
|
def scan(start_key, end_key = nil, durability_filter: nil, dirty: nil,
|
|
174
|
-
read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil, &)
|
|
175
|
-
opts =
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
217
|
+
read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil, order: nil, &)
|
|
218
|
+
opts = scan_options(
|
|
219
|
+
durability_filter: durability_filter,
|
|
220
|
+
dirty: dirty,
|
|
221
|
+
read_ahead_bytes: read_ahead_bytes,
|
|
222
|
+
cache_blocks: cache_blocks,
|
|
223
|
+
max_fetch_tasks: max_fetch_tasks,
|
|
224
|
+
order: order
|
|
225
|
+
)
|
|
181
226
|
|
|
182
227
|
iter = if opts.empty?
|
|
183
228
|
_scan(start_key, end_key)
|
|
@@ -200,6 +245,12 @@ module SlateDb
|
|
|
200
245
|
# @param read_ahead_bytes [Integer, nil] Number of bytes to read ahead
|
|
201
246
|
# @param cache_blocks [Boolean, nil] Whether to cache blocks
|
|
202
247
|
# @param max_fetch_tasks [Integer, nil] Maximum number of fetch tasks
|
|
248
|
+
# @param order [Symbol, String, nil] Iteration order (:asc/:ascending or :desc/:descending)
|
|
249
|
+
# @param from [String, nil] Inclusive lower bound suffix, appended to the
|
|
250
|
+
# prefix, to start scanning from (e.g. prefix "user:" with from "100"
|
|
251
|
+
# starts at "user:100"). Defaults to the start of the prefix.
|
|
252
|
+
# @param to [String, nil] Exclusive upper bound suffix, appended to the
|
|
253
|
+
# prefix, to stop scanning at. Defaults to the end of the prefix.
|
|
203
254
|
# @return [Iterator] An iterator over key-value pairs
|
|
204
255
|
#
|
|
205
256
|
# @example Scan all user keys
|
|
@@ -207,14 +258,23 @@ module SlateDb
|
|
|
207
258
|
# puts "#{key}: #{value}"
|
|
208
259
|
# end
|
|
209
260
|
#
|
|
261
|
+
# @example Scan a sub-range within a prefix
|
|
262
|
+
# # keys "user:100" (inclusive) up to "user:200" (exclusive)
|
|
263
|
+
# db.scan_prefix("user:", from: "100", to: "200")
|
|
264
|
+
#
|
|
210
265
|
def scan_prefix(prefix, durability_filter: nil, dirty: nil,
|
|
211
|
-
read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil,
|
|
212
|
-
|
|
213
|
-
opts
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
266
|
+
read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil, order: nil,
|
|
267
|
+
from: nil, to: nil, &)
|
|
268
|
+
opts = scan_options(
|
|
269
|
+
durability_filter: durability_filter,
|
|
270
|
+
dirty: dirty,
|
|
271
|
+
read_ahead_bytes: read_ahead_bytes,
|
|
272
|
+
cache_blocks: cache_blocks,
|
|
273
|
+
max_fetch_tasks: max_fetch_tasks,
|
|
274
|
+
order: order
|
|
275
|
+
)
|
|
276
|
+
opts[:subrange_from] = from if from
|
|
277
|
+
opts[:subrange_to] = to if to
|
|
218
278
|
|
|
219
279
|
iter = if opts.empty?
|
|
220
280
|
_scan_prefix(prefix)
|
|
@@ -229,10 +289,26 @@ module SlateDb
|
|
|
229
289
|
end
|
|
230
290
|
end
|
|
231
291
|
|
|
292
|
+
def scan_options(durability_filter:, dirty:, read_ahead_bytes:, cache_blocks:,
|
|
293
|
+
max_fetch_tasks:, order:)
|
|
294
|
+
opts = {}
|
|
295
|
+
opts[:durability_filter] = durability_filter.to_s if durability_filter
|
|
296
|
+
opts[:dirty] = dirty unless dirty.nil?
|
|
297
|
+
opts[:read_ahead_bytes] = read_ahead_bytes if read_ahead_bytes
|
|
298
|
+
opts[:cache_blocks] = cache_blocks unless cache_blocks.nil?
|
|
299
|
+
opts[:max_fetch_tasks] = max_fetch_tasks if max_fetch_tasks
|
|
300
|
+
opts[:order] = order.to_s if order
|
|
301
|
+
opts
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
private :scan_options
|
|
305
|
+
|
|
232
306
|
# Write a batch of operations atomically.
|
|
233
307
|
#
|
|
234
308
|
# @param batch [WriteBatch] The batch to write
|
|
235
309
|
# @param await_durable [Boolean] Whether to wait for durability (default: true)
|
|
310
|
+
# @param seqnum [Integer, nil] User-supplied sequence number applied to the
|
|
311
|
+
# batch. See {#put} for semantics. (Requires SlateDB >= 0.13.0)
|
|
236
312
|
# @return [void]
|
|
237
313
|
#
|
|
238
314
|
# @example Write a batch
|
|
@@ -248,11 +324,15 @@ module SlateDb
|
|
|
248
324
|
# b.put("key2", "value2")
|
|
249
325
|
# end
|
|
250
326
|
#
|
|
251
|
-
def write(batch, await_durable: nil)
|
|
252
|
-
|
|
327
|
+
def write(batch, await_durable: nil, seqnum: nil)
|
|
328
|
+
opts = {}
|
|
329
|
+
opts[:await_durable] = await_durable unless await_durable.nil?
|
|
330
|
+
opts[:seqnum] = seqnum if seqnum
|
|
331
|
+
|
|
332
|
+
if opts.empty?
|
|
253
333
|
_write(batch)
|
|
254
334
|
else
|
|
255
|
-
_write_with_options(batch,
|
|
335
|
+
_write_with_options(batch, opts)
|
|
256
336
|
end
|
|
257
337
|
end
|
|
258
338
|
|
|
@@ -262,6 +342,8 @@ module SlateDb
|
|
|
262
342
|
# @param value [String] The merge operand to apply
|
|
263
343
|
# @param ttl [Integer, nil] Time-to-live in milliseconds
|
|
264
344
|
# @param await_durable [Boolean] Whether to wait for durability (default: true)
|
|
345
|
+
# @param seqnum [Integer, nil] User-supplied sequence number for this write.
|
|
346
|
+
# See {#put} for semantics. (Requires SlateDB >= 0.13.0)
|
|
265
347
|
# @return [void]
|
|
266
348
|
#
|
|
267
349
|
# @example Merge with string concatenation operator
|
|
@@ -269,10 +351,11 @@ module SlateDb
|
|
|
269
351
|
# db.merge("key", "part1")
|
|
270
352
|
# db.merge("key", "part2")
|
|
271
353
|
#
|
|
272
|
-
def merge(key, value, ttl: nil, await_durable: nil)
|
|
354
|
+
def merge(key, value, ttl: nil, await_durable: nil, seqnum: nil)
|
|
273
355
|
opts = {}
|
|
274
356
|
opts[:ttl] = ttl if ttl
|
|
275
357
|
opts[:await_durable] = await_durable unless await_durable.nil?
|
|
358
|
+
opts[:seqnum] = seqnum if seqnum
|
|
276
359
|
|
|
277
360
|
if opts.empty?
|
|
278
361
|
_merge(key, value)
|
|
@@ -284,6 +367,8 @@ module SlateDb
|
|
|
284
367
|
# Create and write a batch using a block.
|
|
285
368
|
#
|
|
286
369
|
# @param await_durable [Boolean] Whether to wait for durability (default: true)
|
|
370
|
+
# @param seqnum [Integer, nil] User-supplied sequence number applied to the
|
|
371
|
+
# batch. See {#put} for semantics. (Requires SlateDB >= 0.13.0)
|
|
287
372
|
# @yield [batch] Yields a WriteBatch to the block
|
|
288
373
|
# @return [void]
|
|
289
374
|
#
|
|
@@ -294,10 +379,10 @@ module SlateDb
|
|
|
294
379
|
# b.delete("old_key")
|
|
295
380
|
# end
|
|
296
381
|
#
|
|
297
|
-
def batch(await_durable: nil)
|
|
382
|
+
def batch(await_durable: nil, seqnum: nil)
|
|
298
383
|
b = WriteBatch.new
|
|
299
384
|
yield b
|
|
300
|
-
write(b, await_durable: await_durable)
|
|
385
|
+
write(b, await_durable: await_durable, seqnum: seqnum)
|
|
301
386
|
end
|
|
302
387
|
|
|
303
388
|
# Begin a new transaction.
|
|
@@ -414,5 +499,12 @@ module SlateDb
|
|
|
414
499
|
opts[:name] = name if name
|
|
415
500
|
_create_checkpoint(opts)
|
|
416
501
|
end
|
|
502
|
+
|
|
503
|
+
# Get database metrics registry.
|
|
504
|
+
#
|
|
505
|
+
# @return [Metrics] Metrics registry
|
|
506
|
+
def metrics
|
|
507
|
+
_metrics
|
|
508
|
+
end
|
|
417
509
|
end
|
|
418
510
|
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SlateDb
|
|
4
|
+
class Metrics
|
|
5
|
+
# Get a metric value by name.
|
|
6
|
+
#
|
|
7
|
+
# @param name [String] Metric name
|
|
8
|
+
# @return [Integer, nil] Current value or nil if not found
|
|
9
|
+
def [](name)
|
|
10
|
+
get(name)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Convert all metrics to a hash.
|
|
14
|
+
#
|
|
15
|
+
# @return [Hash] Map of metric name to value
|
|
16
|
+
def to_h
|
|
17
|
+
names.to_h { |metric_name| [metric_name, get(metric_name)] }
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
data/lib/slatedb/reader.rb
CHANGED
|
@@ -7,10 +7,24 @@ module SlateDb
|
|
|
7
7
|
#
|
|
8
8
|
# @param path [String] The path identifier for the database
|
|
9
9
|
# @param url [String, nil] Optional object store URL
|
|
10
|
-
# @param checkpoint_id [String, nil] Optional checkpoint UUID to read at
|
|
10
|
+
# @param checkpoint_id [String, nil] Optional checkpoint UUID to read at. When
|
|
11
|
+
# given, the reader is pinned to that checkpoint and does not follow new writes.
|
|
12
|
+
# @param follow_latest [Boolean, nil] When true, the reader tails the latest
|
|
13
|
+
# manifest without creating or maintaining its own checkpoint. This performs no
|
|
14
|
+
# object-store writes but provides no protection from garbage collection, so it
|
|
15
|
+
# is best suited to read-only or mirrored databases. Mutually exclusive with
|
|
16
|
+
# +checkpoint_id+. When neither is set (the default), the reader manages its own
|
|
17
|
+
# checkpoint and refreshes it periodically. (Requires SlateDB >= 0.15.0)
|
|
11
18
|
# @param manifest_poll_interval [Integer, nil] Poll interval in milliseconds
|
|
12
19
|
# @param checkpoint_lifetime [Integer, nil] Checkpoint lifetime in milliseconds
|
|
13
20
|
# @param max_memtable_bytes [Integer, nil] Maximum memtable size in bytes
|
|
21
|
+
# @param cache_root [String, nil] Root folder for the reader's local on-disk
|
|
22
|
+
# object-store cache. Setting this enables the cached object store; when it is
|
|
23
|
+
# not set the cache (and `max_open_file_handles`) has no effect.
|
|
24
|
+
# @param max_open_file_handles [Integer, nil] Maximum number of file handles to keep
|
|
25
|
+
# open in the reader's file-handle cache. When the limit is reached, the least
|
|
26
|
+
# recently used handle is closed (default: 1000). Only takes effect when
|
|
27
|
+
# `cache_root` is set. (Requires SlateDB >= 0.13.0)
|
|
14
28
|
# @param merge_operator [Symbol, String, nil] Optional merge operator ("string_concat" or "concat")
|
|
15
29
|
# @yield [reader] If a block is given, yields the reader and ensures it's closed
|
|
16
30
|
# @return [Reader] The opened reader (or block result if block given)
|
|
@@ -28,13 +42,25 @@ module SlateDb
|
|
|
28
42
|
# @example Open at a specific checkpoint
|
|
29
43
|
# reader = SlateDb::Reader.open("/tmp/mydb", checkpoint_id: "uuid-here")
|
|
30
44
|
#
|
|
31
|
-
|
|
45
|
+
# @example Follow the latest state without managing a checkpoint
|
|
46
|
+
# reader = SlateDb::Reader.open("/tmp/mydb", follow_latest: true)
|
|
47
|
+
#
|
|
48
|
+
# @example Enable the on-disk cache and cap its open file handles
|
|
49
|
+
# reader = SlateDb::Reader.open("/tmp/mydb",
|
|
50
|
+
# cache_root: "/var/cache/slatedb",
|
|
51
|
+
# max_open_file_handles: 256)
|
|
52
|
+
#
|
|
53
|
+
def open(path, url: nil, checkpoint_id: nil, follow_latest: nil,
|
|
32
54
|
manifest_poll_interval: nil, checkpoint_lifetime: nil,
|
|
33
|
-
max_memtable_bytes: nil,
|
|
55
|
+
max_memtable_bytes: nil, cache_root: nil, max_open_file_handles: nil,
|
|
56
|
+
merge_operator: nil)
|
|
34
57
|
opts = {}
|
|
58
|
+
opts[:follow_latest] = follow_latest unless follow_latest.nil?
|
|
35
59
|
opts[:manifest_poll_interval] = manifest_poll_interval if manifest_poll_interval
|
|
36
60
|
opts[:checkpoint_lifetime] = checkpoint_lifetime if checkpoint_lifetime
|
|
37
61
|
opts[:max_memtable_bytes] = max_memtable_bytes if max_memtable_bytes
|
|
62
|
+
opts[:cache_root] = cache_root if cache_root
|
|
63
|
+
opts[:max_open_file_handles] = max_open_file_handles if max_open_file_handles
|
|
38
64
|
opts[:merge_operator] = merge_operator.to_s if merge_operator
|
|
39
65
|
|
|
40
66
|
reader = _open(path, url, checkpoint_id, opts)
|
|
@@ -112,16 +138,25 @@ module SlateDb
|
|
|
112
138
|
# @param read_ahead_bytes [Integer, nil] Number of bytes to read ahead
|
|
113
139
|
# @param cache_blocks [Boolean, nil] Whether to cache blocks
|
|
114
140
|
# @param max_fetch_tasks [Integer, nil] Maximum number of fetch tasks
|
|
141
|
+
# @param from [String, nil] Inclusive lower bound suffix, appended to the
|
|
142
|
+
# prefix, to start scanning from (e.g. prefix "user:" with from "100"
|
|
143
|
+
# starts at "user:100"). Defaults to the start of the prefix.
|
|
144
|
+
# @param to [String, nil] Exclusive upper bound suffix, appended to the
|
|
145
|
+
# prefix, to stop scanning at. Defaults to the end of the prefix.
|
|
115
146
|
# @return [Iterator] An iterator over key-value pairs
|
|
116
147
|
#
|
|
117
148
|
def scan_prefix(prefix, durability_filter: nil, dirty: nil,
|
|
118
|
-
read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil,
|
|
119
|
-
|
|
120
|
-
opts
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
149
|
+
read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil,
|
|
150
|
+
from: nil, to: nil, &)
|
|
151
|
+
opts = {
|
|
152
|
+
durability_filter: durability_filter&.to_s,
|
|
153
|
+
dirty: dirty,
|
|
154
|
+
read_ahead_bytes: read_ahead_bytes,
|
|
155
|
+
cache_blocks: cache_blocks,
|
|
156
|
+
max_fetch_tasks: max_fetch_tasks,
|
|
157
|
+
subrange_from: from,
|
|
158
|
+
subrange_to: to
|
|
159
|
+
}.compact
|
|
125
160
|
|
|
126
161
|
iter = if opts.empty?
|
|
127
162
|
_scan_prefix(prefix)
|
data/lib/slatedb/snapshot.rb
CHANGED
|
@@ -59,16 +59,24 @@ module SlateDb
|
|
|
59
59
|
# @param read_ahead_bytes [Integer, nil] Number of bytes to read ahead
|
|
60
60
|
# @param cache_blocks [Boolean, nil] Whether to cache blocks
|
|
61
61
|
# @param max_fetch_tasks [Integer, nil] Maximum number of fetch tasks
|
|
62
|
+
# @param from [String, nil] Inclusive lower bound suffix, appended to the
|
|
63
|
+
# prefix, to start scanning from. Defaults to the start of the prefix.
|
|
64
|
+
# @param to [String, nil] Exclusive upper bound suffix, appended to the
|
|
65
|
+
# prefix, to stop scanning at. Defaults to the end of the prefix.
|
|
62
66
|
# @return [Iterator] An iterator over key-value pairs
|
|
63
67
|
#
|
|
64
68
|
def scan_prefix(prefix, durability_filter: nil, dirty: nil,
|
|
65
|
-
read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil,
|
|
66
|
-
|
|
67
|
-
opts
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil,
|
|
70
|
+
from: nil, to: nil, &)
|
|
71
|
+
opts = {
|
|
72
|
+
durability_filter: durability_filter&.to_s,
|
|
73
|
+
dirty: dirty,
|
|
74
|
+
read_ahead_bytes: read_ahead_bytes,
|
|
75
|
+
cache_blocks: cache_blocks,
|
|
76
|
+
max_fetch_tasks: max_fetch_tasks,
|
|
77
|
+
subrange_from: from,
|
|
78
|
+
subrange_to: to
|
|
79
|
+
}.compact
|
|
72
80
|
|
|
73
81
|
iter = if opts.empty?
|
|
74
82
|
_scan_prefix(prefix)
|
data/lib/slatedb/transaction.rb
CHANGED
|
@@ -98,16 +98,24 @@ module SlateDb
|
|
|
98
98
|
# @param read_ahead_bytes [Integer, nil] Number of bytes to read ahead
|
|
99
99
|
# @param cache_blocks [Boolean, nil] Whether to cache blocks
|
|
100
100
|
# @param max_fetch_tasks [Integer, nil] Maximum number of fetch tasks
|
|
101
|
+
# @param from [String, nil] Inclusive lower bound suffix, appended to the
|
|
102
|
+
# prefix, to start scanning from. Defaults to the start of the prefix.
|
|
103
|
+
# @param to [String, nil] Exclusive upper bound suffix, appended to the
|
|
104
|
+
# prefix, to stop scanning at. Defaults to the end of the prefix.
|
|
101
105
|
# @return [Iterator] An iterator over key-value pairs
|
|
102
106
|
#
|
|
103
107
|
def scan_prefix(prefix, durability_filter: nil, dirty: nil,
|
|
104
|
-
read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil,
|
|
105
|
-
|
|
106
|
-
opts
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil,
|
|
109
|
+
from: nil, to: nil, &)
|
|
110
|
+
opts = {
|
|
111
|
+
durability_filter: durability_filter&.to_s,
|
|
112
|
+
dirty: dirty,
|
|
113
|
+
read_ahead_bytes: read_ahead_bytes,
|
|
114
|
+
cache_blocks: cache_blocks,
|
|
115
|
+
max_fetch_tasks: max_fetch_tasks,
|
|
116
|
+
subrange_from: from,
|
|
117
|
+
subrange_to: to
|
|
118
|
+
}.compact
|
|
111
119
|
|
|
112
120
|
iter = if opts.empty?
|
|
113
121
|
_scan_prefix(prefix)
|
|
@@ -141,5 +149,34 @@ module SlateDb
|
|
|
141
149
|
def mark_read(keys)
|
|
142
150
|
_mark_read(Array(keys))
|
|
143
151
|
end
|
|
152
|
+
|
|
153
|
+
# Commit the transaction.
|
|
154
|
+
#
|
|
155
|
+
# @param await_durable [Boolean, nil] Whether to wait for durability (default: true)
|
|
156
|
+
# @param seqnum [Integer, nil] User-supplied sequence number for the commit.
|
|
157
|
+
# When provided (and non-zero), it is used instead of the internally
|
|
158
|
+
# generated sequence number and must be strictly greater than the current
|
|
159
|
+
# maximum sequence number. (Requires SlateDB >= 0.13.0)
|
|
160
|
+
# @return [void]
|
|
161
|
+
#
|
|
162
|
+
# @example Commit a transaction
|
|
163
|
+
# txn = db.begin_transaction
|
|
164
|
+
# txn.put("key", "value")
|
|
165
|
+
# txn.commit
|
|
166
|
+
#
|
|
167
|
+
# @example Commit with an explicit sequence number
|
|
168
|
+
# txn.commit(seqnum: 99)
|
|
169
|
+
#
|
|
170
|
+
def commit(await_durable: nil, seqnum: nil)
|
|
171
|
+
opts = {}
|
|
172
|
+
opts[:await_durable] = await_durable unless await_durable.nil?
|
|
173
|
+
opts[:seqnum] = seqnum if seqnum
|
|
174
|
+
|
|
175
|
+
if opts.empty?
|
|
176
|
+
_commit
|
|
177
|
+
else
|
|
178
|
+
_commit_with_options(opts)
|
|
179
|
+
end
|
|
180
|
+
end
|
|
144
181
|
end
|
|
145
182
|
end
|
data/lib/slatedb/version.rb
CHANGED
data/lib/slatedb.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: slatedb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- SlateDB Contributors
|
|
@@ -15,70 +15,70 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - "~>"
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version:
|
|
18
|
+
version: 0.9.128
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version:
|
|
25
|
+
version: 0.9.128
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: rake
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
30
|
- - "~>"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '13.
|
|
32
|
+
version: '13.4'
|
|
33
33
|
type: :development
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '13.
|
|
39
|
+
version: '13.4'
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: rake-compiler
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
|
43
43
|
requirements:
|
|
44
44
|
- - "~>"
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: '1.
|
|
46
|
+
version: '1.3'
|
|
47
47
|
type: :development
|
|
48
48
|
prerelease: false
|
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
51
|
- - "~>"
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: '1.
|
|
53
|
+
version: '1.3'
|
|
54
54
|
- !ruby/object:Gem::Dependency
|
|
55
55
|
name: rspec
|
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
|
57
57
|
requirements:
|
|
58
58
|
- - "~>"
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: '3.
|
|
60
|
+
version: '3.13'
|
|
61
61
|
type: :development
|
|
62
62
|
prerelease: false
|
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
64
64
|
requirements:
|
|
65
65
|
- - "~>"
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: '3.
|
|
67
|
+
version: '3.13'
|
|
68
68
|
- !ruby/object:Gem::Dependency
|
|
69
69
|
name: rubocop
|
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
|
71
71
|
requirements:
|
|
72
72
|
- - "~>"
|
|
73
73
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: '1.
|
|
74
|
+
version: '1.86'
|
|
75
75
|
type: :development
|
|
76
76
|
prerelease: false
|
|
77
77
|
version_requirements: !ruby/object:Gem::Requirement
|
|
78
78
|
requirements:
|
|
79
79
|
- - "~>"
|
|
80
80
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: '1.
|
|
81
|
+
version: '1.86'
|
|
82
82
|
description: A cloud-native embedded key-value store built on object storage
|
|
83
83
|
email:
|
|
84
84
|
- slatedb@example.com
|
|
@@ -98,6 +98,7 @@ files:
|
|
|
98
98
|
- ext/slatedb/src/iterator.rs
|
|
99
99
|
- ext/slatedb/src/lib.rs
|
|
100
100
|
- ext/slatedb/src/merge_ops.rs
|
|
101
|
+
- ext/slatedb/src/metrics.rs
|
|
101
102
|
- ext/slatedb/src/reader.rs
|
|
102
103
|
- ext/slatedb/src/runtime.rs
|
|
103
104
|
- ext/slatedb/src/snapshot.rs
|
|
@@ -108,6 +109,7 @@ files:
|
|
|
108
109
|
- lib/slatedb/admin.rb
|
|
109
110
|
- lib/slatedb/database.rb
|
|
110
111
|
- lib/slatedb/iterator.rb
|
|
112
|
+
- lib/slatedb/metrics.rb
|
|
111
113
|
- lib/slatedb/reader.rb
|
|
112
114
|
- lib/slatedb/snapshot.rb
|
|
113
115
|
- lib/slatedb/transaction.rb
|
|
@@ -128,14 +130,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
128
130
|
requirements:
|
|
129
131
|
- - ">="
|
|
130
132
|
- !ruby/object:Gem::Version
|
|
131
|
-
version: 3.
|
|
133
|
+
version: 3.3.0
|
|
132
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
135
|
requirements:
|
|
134
136
|
- - ">="
|
|
135
137
|
- !ruby/object:Gem::Version
|
|
136
138
|
version: '0'
|
|
137
139
|
requirements: []
|
|
138
|
-
rubygems_version: 4.0.
|
|
140
|
+
rubygems_version: 4.0.16
|
|
139
141
|
specification_version: 4
|
|
140
142
|
summary: Ruby bindings for SlateDB
|
|
141
143
|
test_files: []
|