slatedb 0.5.0 → 0.6.1

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
  SHA256:
3
- metadata.gz: dd1077018f7a8738545fc60b626a0e51d3240ae4141d9616787bf642489a22bc
4
- data.tar.gz: 7aea1d1d0f9e1e3ee349d742246b7f89353ab8af39a6aca12d3167d7064d9023
3
+ metadata.gz: c46e1c81aa2f9f98834847d89ebe70a3caa18dd7307ec864d2d18fb448b8c366
4
+ data.tar.gz: 1e24f5bb9dc914c3f9f5fe7025d481b0eb93160ffd5834f78d039c333d66e434
5
5
  SHA512:
6
- metadata.gz: 2fcbdc5f116120c4d06bb857407047505a5ca5c526a9c8209cb06411635adc506b9a634024db9152c23f5b98f46d9600d2cf21d4826cf5a947b335cb72449eb2
7
- data.tar.gz: e40b8fde694ca637e5ab80d529e161eefe8901cf478a768ebbc2ddd35b9cc16f42e8858feb4cd149333e7e3db6f4ee977770485390c56303ba8dba3fd88803ff
6
+ metadata.gz: 3b5fce35dda024e1011917c41685c88eadf9537558bcc643c06e4db988fc99dd3819f4d0b5f5be1ff5f660a33053b3c4b6fc579e1723523edc940cef67682d39
7
+ data.tar.gz: e0025127be66530aa82e64bcc98141b20cf5e5fd0a66290f32bcd88b16b4b7143a144238f85b0f209c7f7fc56477d85cfa3556f5b1808940f31d55086bf7e99d
data/README.md CHANGED
@@ -64,6 +64,34 @@ SlateDb::Database.open("/tmp/mydb") do |db|
64
64
  end # automatically closed
65
65
  ```
66
66
 
67
+ ### Compaction Controls
68
+
69
+ SlateDB 0.17 adds controls for how long compaction inputs remain protected from
70
+ garbage collection and when to consolidate sorted runs:
71
+
72
+ ```ruby
73
+ SlateDb::Database.open("mydb",
74
+ url: "s3://mybucket/path",
75
+ compactor_checkpoint_lifetime: 30 * 60_000,
76
+ sorted_run_consolidation_threshold: 8) do |db|
77
+ db.put("key", "value")
78
+ end
79
+ ```
80
+
81
+ `compactor_checkpoint_lifetime` is in milliseconds and defaults to 15 minutes.
82
+ Reads, scans, snapshots, and transactions using old compaction inputs must finish
83
+ within that time; after it expires, garbage collection can remove those inputs.
84
+
85
+ `sorted_run_consolidation_threshold` starts fallback consolidation when the
86
+ projected sorted-run count exceeds the threshold. It is not a hard limit.
87
+ Zero disables it (the default); use at least two to enable it. SlateDB warns and
88
+ disables the trigger for one. Low thresholds can increase storage reads and writes.
89
+
90
+ ### Key Size
91
+
92
+ Keys can now exceed the previous 65,535-byte limit, up to SlateDB's new
93
+ 4,294,967,295-byte limit. Very large keys still require enough memory to process.
94
+
67
95
  ### Persistent Storage
68
96
 
69
97
  For persistent storage, provide an object store URL:
@@ -501,6 +529,14 @@ SlateDb::Reader.open("/tmp/mydb", url: "s3://bucket/path") do |reader|
501
529
  reader.scan("prefix:").each do |k, v|
502
530
  puts "#{k}: #{v}"
503
531
  end
532
+
533
+ # Range and prefix scans accept :asc/:ascending or :desc/:descending.
534
+ reader.scan("user:100", "user:200", order: :desc).each do |k, v|
535
+ puts "#{k}: #{v}"
536
+ end
537
+ reader.scan_prefix("user:", from: "100", to: "200", order: :desc).each do |k, v|
538
+ puts "#{k}: #{v}"
539
+ end
504
540
  end
505
541
 
506
542
  # Open at a specific checkpoint (pins the reader to that checkpoint's state)
@@ -11,13 +11,13 @@ name = "slatedb"
11
11
  crate-type = ["cdylib"]
12
12
 
13
13
  [dependencies]
14
- slatedb = "0.16.0"
15
- magnus = { version = "0.8.2", features = ["rb-sys"] }
16
- rb-sys = { version = "0.9.128", features = ["stable-api-compiled-fallback"] }
17
- tokio = { version = "1.52.3", features = ["rt-multi-thread", "sync"] }
18
- bytes = "1.11.1"
19
- serde_json = "1.0.145"
14
+ slatedb = "0.17.0"
15
+ magnus = { version = "0.9.3", features = ["rb-sys"] }
16
+ rb-sys = { version = "0.9.130", features = ["stable-api-compiled-fallback"] }
17
+ tokio = { version = "1.54.1", features = ["rt-multi-thread", "sync"] }
18
+ bytes = "1.12.1"
19
+ serde_json = "1.0.154"
20
20
  url = "2.5.8"
21
21
  once_cell = "1.21.4"
22
- log = "0.4.29"
23
- uuid = "1.23.1"
22
+ log = "0.4.34"
23
+ uuid = "1.29.0"
@@ -5,7 +5,7 @@ use magnus::prelude::*;
5
5
  use magnus::{function, method, Error, RHash, Ruby};
6
6
  use slatedb::config::{
7
7
  CloseOptions, DurabilityLevel, FlushOptions, FlushType, MergeOptions, PutOptions, ReadOptions,
8
- ScanOptions, Ttl, WriteOptions,
8
+ ScanOptions, Settings, Ttl, WriteOptions,
9
9
  };
10
10
  use slatedb::object_store::memory::InMemory;
11
11
  use slatedb::{Db, IsolationLevel, IterationOrder, KeyValue};
@@ -120,6 +120,23 @@ impl Database {
120
120
  pub fn open(path: String, url: Option<String>, kwargs: RHash) -> Result<Self, Error> {
121
121
  // Try string-based merge operator first, then proc-based
122
122
  let merge_operator = parse_merge_operator(&kwargs)?.or(parse_merge_operator_proc(&kwargs)?);
123
+ let checkpoint_lifetime = get_optional::<u64>(&kwargs, "compactor_checkpoint_lifetime")?
124
+ .map(std::time::Duration::from_millis);
125
+ let consolidation_threshold =
126
+ get_optional::<usize>(&kwargs, "sorted_run_consolidation_threshold")?;
127
+
128
+ let mut settings = Settings::default();
129
+ if let Some(compactor) = settings.compactor_options.as_mut() {
130
+ if let Some(lifetime) = checkpoint_lifetime {
131
+ compactor.checkpoint_lifetime = lifetime;
132
+ }
133
+ if let Some(threshold) = consolidation_threshold {
134
+ compactor.scheduler_options.insert(
135
+ "sorted_run_consolidation_threshold".to_string(),
136
+ threshold.to_string(),
137
+ );
138
+ }
139
+ }
123
140
 
124
141
  let db = block_on_result(async {
125
142
  let object_store: Arc<dyn slatedb::object_store::ObjectStore> =
@@ -129,7 +146,7 @@ impl Database {
129
146
  Arc::new(InMemory::new())
130
147
  };
131
148
 
132
- let mut builder = Db::builder(path, object_store);
149
+ let mut builder = Db::builder(path, object_store).with_settings(settings);
133
150
  if let Some(merge_operator) = merge_operator {
134
151
  builder = builder.with_merge_operator(merge_operator);
135
152
  }
@@ -12,6 +12,12 @@ module SlateDb
12
12
  # @param merge_operator [Symbol, String, Proc, nil] Optional merge operator.
13
13
  # Can be a symbol/string ("string_concat" or "concat") or a Proc/lambda
14
14
  # that takes (key, existing_value, new_value) and returns the merged value.
15
+ # @param compactor_checkpoint_lifetime [Integer, nil] How long compaction inputs
16
+ # are protected from garbage collection, in milliseconds (default: 15 minutes).
17
+ # Reads using those inputs must finish within this time.
18
+ # @param sorted_run_consolidation_threshold [Integer, nil] Sorted-run count above
19
+ # which fallback consolidation starts. Zero disables it (default); use at least
20
+ # two to enable it. One is disabled by SlateDB with a warning. This is not a hard limit.
15
21
  # @yield [db] If a block is given, yields the database and ensures it's closed
16
22
  # @return [Database] The opened database (or block result if block given)
17
23
  #
@@ -38,8 +44,12 @@ module SlateDb
38
44
  # db.merge("counter", "3")
39
45
  # db.get("counter") # => "8"
40
46
  #
41
- def open(path, url: nil, merge_operator: nil)
42
- opts = {}
47
+ def open(path, url: nil, merge_operator: nil,
48
+ compactor_checkpoint_lifetime: nil, sorted_run_consolidation_threshold: nil)
49
+ opts = {
50
+ compactor_checkpoint_lifetime: compactor_checkpoint_lifetime,
51
+ sorted_run_consolidation_threshold: sorted_run_consolidation_threshold
52
+ }.compact
43
53
 
44
54
  case merge_operator
45
55
  when Symbol, String
@@ -106,16 +106,19 @@ module SlateDb
106
106
  #
107
107
  # @param start_key [String] The start key (inclusive)
108
108
  # @param end_key [String, nil] The end key (exclusive)
109
+ # @param order [Symbol, String, nil] Iteration order (:asc/:ascending or :desc/:descending)
109
110
  # @return [Iterator] An iterator over key-value pairs
110
111
  #
111
112
  def scan(start_key, end_key = nil, durability_filter: nil, dirty: nil,
112
- read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil, &)
113
- opts = {}
114
- opts[:durability_filter] = durability_filter.to_s if durability_filter
115
- opts[:dirty] = dirty unless dirty.nil?
116
- opts[:read_ahead_bytes] = read_ahead_bytes if read_ahead_bytes
117
- opts[:cache_blocks] = cache_blocks unless cache_blocks.nil?
118
- opts[:max_fetch_tasks] = max_fetch_tasks if max_fetch_tasks
113
+ read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil, order: nil, &)
114
+ opts = {
115
+ durability_filter: durability_filter&.to_s,
116
+ dirty: dirty,
117
+ read_ahead_bytes: read_ahead_bytes,
118
+ cache_blocks: cache_blocks,
119
+ max_fetch_tasks: max_fetch_tasks,
120
+ order: order&.to_s
121
+ }.compact
119
122
 
120
123
  iter = if opts.empty?
121
124
  _scan(start_key, end_key)
@@ -138,6 +141,7 @@ module SlateDb
138
141
  # @param read_ahead_bytes [Integer, nil] Number of bytes to read ahead
139
142
  # @param cache_blocks [Boolean, nil] Whether to cache blocks
140
143
  # @param max_fetch_tasks [Integer, nil] Maximum number of fetch tasks
144
+ # @param order [Symbol, String, nil] Iteration order (:asc/:ascending or :desc/:descending)
141
145
  # @param from [String, nil] Inclusive lower bound suffix, appended to the
142
146
  # prefix, to start scanning from (e.g. prefix "user:" with from "100"
143
147
  # starts at "user:100"). Defaults to the start of the prefix.
@@ -146,7 +150,7 @@ module SlateDb
146
150
  # @return [Iterator] An iterator over key-value pairs
147
151
  #
148
152
  def scan_prefix(prefix, durability_filter: nil, dirty: nil,
149
- read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil,
153
+ read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil, order: nil,
150
154
  from: nil, to: nil, &)
151
155
  opts = {
152
156
  durability_filter: durability_filter&.to_s,
@@ -154,6 +158,7 @@ module SlateDb
154
158
  read_ahead_bytes: read_ahead_bytes,
155
159
  cache_blocks: cache_blocks,
156
160
  max_fetch_tasks: max_fetch_tasks,
161
+ order: order&.to_s,
157
162
  subrange_from: from,
158
163
  subrange_to: to
159
164
  }.compact
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SlateDb
4
- VERSION = "0.5.0"
4
+ VERSION = "0.6.1"
5
5
  end
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.5.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - SlateDB Contributors
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.9.128
18
+ version: 0.9.130
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: 0.9.128
25
+ version: 0.9.130
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rake
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -71,14 +71,14 @@ dependencies:
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '1.86'
74
+ version: '1.92'
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.86'
81
+ version: '1.92'
82
82
  description: A cloud-native embedded key-value store built on object storage
83
83
  email:
84
84
  - slatedb@example.com