lora-ruby 0.4.0 → 0.5.5
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 +7 -7
- data/lib/lora_ruby/version.rb +1 -1
- data/src/lib.rs +37 -14
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b5ba0aa4fc27617800ec4053cabef91152e7aeb369c37671b5b42c8b63262191
|
|
4
|
+
data.tar.gz: 68db7428ccf49b03dddf70bfe430c92388269060653541819c19bcebd120db38
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c25ead41256e9c1a7db8b9842f161d5c9efad153dc52da52323381d5eb380a9f81d616f5dba8bcc9f1e0bbca4a5010f5b57a6f0e09c048cc4ac0367bc30384a0
|
|
7
|
+
data.tar.gz: 891572a4890c93d4af1f92020e623724e3a7509340f29d6985f7a106e3e4ec0085c92aa08b98301219e4ca75cd45fe2062945bf51fe62f58c058ce5fd03dd08e
|
data/README.md
CHANGED
|
@@ -43,10 +43,10 @@ Initialization rule:
|
|
|
43
43
|
|
|
44
44
|
```ruby
|
|
45
45
|
scratch = LoraRuby::Database.create # in-memory
|
|
46
|
-
persistent = LoraRuby::Database.create("
|
|
46
|
+
persistent = LoraRuby::Database.create("app", {"database_dir": "./data"}) # persistent: ./data/app.loradb
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
If you want persistence, pass a
|
|
49
|
+
If you want persistence, pass a database name and `database_dir` to
|
|
50
50
|
`LoraRuby::Database.create(...)` or `LoraRuby::Database.new(...)`.
|
|
51
51
|
|
|
52
52
|
### Params
|
|
@@ -148,16 +148,16 @@ db.execute(
|
|
|
148
148
|
|
|
149
149
|
## Persistence
|
|
150
150
|
|
|
151
|
-
`LoraRuby::Database.create("
|
|
152
|
-
`LoraRuby::Database.new("
|
|
153
|
-
persistent database
|
|
151
|
+
`LoraRuby::Database.create("app", {"database_dir": "./data"})` and
|
|
152
|
+
`LoraRuby::Database.new("app", { database_dir: "./data" })` open or create
|
|
153
|
+
an archive-backed persistent database at `./data/app.loradb`. Reopening the same path
|
|
154
154
|
replays committed writes before returning the handle.
|
|
155
155
|
|
|
156
|
-
Call `db.close` before reopening the same
|
|
156
|
+
Call `db.close` before reopening the same archive inside one
|
|
157
157
|
process.
|
|
158
158
|
|
|
159
159
|
This first Ruby persistence slice intentionally stays small: the
|
|
160
|
-
binding exposes
|
|
160
|
+
binding exposes archive-backed initialization plus the existing snapshot
|
|
161
161
|
APIs, but not checkpoint, truncate, status, or sync-mode controls.
|
|
162
162
|
|
|
163
163
|
## Concurrency (GVL release)
|
data/lib/lora_ruby/version.rb
CHANGED
|
@@ -10,5 +10,5 @@ module LoraRuby
|
|
|
10
10
|
# Guard against redefinition so re-requiring this file (or loading
|
|
11
11
|
# both paths) doesn't emit a "warning: already initialized constant"
|
|
12
12
|
# when the native extension loads second with the identical value.
|
|
13
|
-
VERSION = "0.
|
|
13
|
+
VERSION = "0.5.5" unless const_defined?(:VERSION)
|
|
14
14
|
end
|
data/src/lib.rs
CHANGED
|
@@ -24,8 +24,8 @@ use magnus::{
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
use lora_database::{
|
|
27
|
-
Database as InnerDatabase, ExecuteOptions, InMemoryGraph, LoraValue,
|
|
28
|
-
|
|
27
|
+
Database as InnerDatabase, DatabaseOpenOptions, ExecuteOptions, InMemoryGraph, LoraValue,
|
|
28
|
+
QueryResult, ResultFormat,
|
|
29
29
|
};
|
|
30
30
|
use lora_store::{
|
|
31
31
|
LoraDate, LoraDateTime, LoraDuration, LoraLocalDateTime, LoraLocalTime, LoraPoint, LoraTime,
|
|
@@ -138,8 +138,9 @@ impl Database {
|
|
|
138
138
|
// singletons so callers can use whichever idiom they prefer; both are
|
|
139
139
|
// cost-equivalent.
|
|
140
140
|
fn database_new(ruby: &Ruby, args: &[Value]) -> Result<Database, MagnusError> {
|
|
141
|
-
let
|
|
142
|
-
let db = without_gvl(move || open_database(
|
|
141
|
+
let (database_name, options) = database_open_args(ruby, args)?;
|
|
142
|
+
let db = without_gvl(move || open_database(database_name, options))
|
|
143
|
+
.map_err(|e| query_error(ruby, e))?;
|
|
143
144
|
Ok(Database::from_db(db))
|
|
144
145
|
}
|
|
145
146
|
|
|
@@ -233,28 +234,50 @@ fn snapshot_meta_to_rhash(
|
|
|
233
234
|
Ok(h)
|
|
234
235
|
}
|
|
235
236
|
|
|
236
|
-
fn
|
|
237
|
+
fn database_open_args(
|
|
238
|
+
ruby: &Ruby,
|
|
239
|
+
args: &[Value],
|
|
240
|
+
) -> Result<(Option<String>, DatabaseOpenOptions), MagnusError> {
|
|
237
241
|
match args.len() {
|
|
238
|
-
0 => Ok(None),
|
|
242
|
+
0 => Ok((None, DatabaseOpenOptions::default())),
|
|
239
243
|
1 => {
|
|
240
244
|
if args[0].is_nil() {
|
|
241
|
-
Ok(None)
|
|
245
|
+
Ok((None, DatabaseOpenOptions::default()))
|
|
246
|
+
} else {
|
|
247
|
+
Ok((
|
|
248
|
+
Some(RString::try_convert(args[0])?.to_string()?),
|
|
249
|
+
DatabaseOpenOptions::default(),
|
|
250
|
+
))
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
2 => {
|
|
254
|
+
let database_name = if args[0].is_nil() {
|
|
255
|
+
None
|
|
242
256
|
} else {
|
|
243
|
-
|
|
257
|
+
Some(RString::try_convert(args[0])?.to_string()?)
|
|
258
|
+
};
|
|
259
|
+
let mut options = DatabaseOpenOptions::default();
|
|
260
|
+
let hash = RHash::try_convert(args[1])?;
|
|
261
|
+
if let Some(dir) = hash_get_either(ruby, hash, "database_dir")
|
|
262
|
+
.or_else(|| hash_get_either(ruby, hash, "databaseDir"))
|
|
263
|
+
{
|
|
264
|
+
options.database_dir = RString::try_convert(dir)?.to_string()?.into();
|
|
244
265
|
}
|
|
266
|
+
Ok((database_name, options))
|
|
245
267
|
}
|
|
246
268
|
n => Err(MagnusError::new(
|
|
247
269
|
ruby.exception_arg_error(),
|
|
248
|
-
format!("wrong number of arguments (given {n}, expected 0..
|
|
270
|
+
format!("wrong number of arguments (given {n}, expected 0..2)"),
|
|
249
271
|
)),
|
|
250
272
|
}
|
|
251
273
|
}
|
|
252
274
|
|
|
253
|
-
fn open_database(
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
275
|
+
fn open_database(
|
|
276
|
+
database_name: Option<String>,
|
|
277
|
+
options: DatabaseOpenOptions,
|
|
278
|
+
) -> Result<Arc<InnerDatabase<InMemoryGraph>>, String> {
|
|
279
|
+
let db = match database_name {
|
|
280
|
+
Some(name) => InnerDatabase::open_named(name, options).map_err(|e| e.to_string())?,
|
|
258
281
|
None => InnerDatabase::in_memory(),
|
|
259
282
|
};
|
|
260
283
|
Ok(Arc::new(db))
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lora-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- LoraDB, Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-04-
|
|
11
|
+
date: 2026-04-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rb_sys
|