Management of open stores #228
Labels
No labels
A-build
A-cli
A-core
A-design
A-edn
A-ffi
A-query
A-sdk
A-sdk-android
A-sdk-ios
A-sync
A-transact
A-views
A-vocab
P-Android
P-desktop
P-iOS
bug
correctness
dependencies
dev-ergonomics
discussion
documentation
duplicate
enhancement
enquiry
good first bug
good first issue
help wanted
hygiene
in progress
invalid
question
ready
size
speed
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: greg/mentat#228
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
It's important that a particular store is only opened once at a time (see also #547).
Further, it's convenient for FFI to have a static place to root open stores.
The obvious solution is a manager, just like rkv's.
But what do we manage?
I propose:
Store
'sconn
fieldArc
. This gives us the ability to shareConn
s and thus useStore
as a pair of a connection and aConn
when there are multiple open SQLite connections.Store
, perhaps namedfork
, that yields a new store with clonedconn
using a providedrusqlite::Connection
. This allows us to get a new copy of a store that's already open.Store
to create an in-memory store. The empty path will now be confusing. (I believe the FFI already makes a distinction…)Store
s, just as in rkv. It's important to canonicalize file paths. "Stores" might be a good name.fn is_open(path: PathBuf) -> bool
Store
, opening it if necessary.fn open(path: PathBuf) -> Result<&mut Store>
fn {get,get_mut}(path: PathBuf) -> Option<{&mut,&} Store>
Store
instance with its own SQLite connection. I understand that I now have to work with SQLite's concurrency model (e.g., I can encounterSQLITE_BUSY
), but Mentat will serialize writes toMetadata
.fn connect(path: PathBuf) -> Result<Store>
Store.conn
and fail if it's more than 1. It can only be more than 1 if a caller has cloned the store, either explicitly or viaconnect
.The usual pattern for working with a store then changes from:
to
— a one-character change and a change in type.