Qwiratry *::DatabaseStorage::Location
NAME
Qwiratry *::DatabaseStorage::Location β Location (+ Format) as table transport
AUTHOR
Tim Nelson - https://github.com/wayland
Blob Locations (File, HTTP) stay URI text I/O. Live tables that happen to
live in a document on a Location compose that Location (and a Format) here β
subclasses override document-to-rows / rows-to-document (Basics Β§4.2).
Default layout: $.location is a directory; each table is
$location/$name.json (extension from $.file-extension).
Qwiratry::DatabaseStorage::Location::Table
class Qwiratry::DatabaseStorage::Location::Table does Qwiratry::DatabaseStorage::Table
In-process row buffer with load/flush through the parent Location driver. Mutations flush back to the Location after each successful write.
method initial-create-document(|c)
method initial-create-document(|c)
|c
Capture of the creating table-action arguments.
Called when a table action materialises a file that did not yet exist.
Default: flush the (possibly empty) in-memory rows. Subclasses may require
fields, write headers-only, etc.
method finish-open()
method finish-open()
Complete deferred open: either C<begin-lazy-load> or C<load-from-location>,
then C<after-finish-open>.
method prefer-lazy-load(-- Bool)>
method prefer-lazy-load(--> Bool)
When C<True>, C<finish-open> calls C<begin-lazy-load> instead of
C<load-from-location>. Default C<False> (eager load).
method begin-lazy-load()
method begin-lazy-load()
Subclass hook for deferred materialisation (e.g. seed CSV headers only).
Default: no-op.
method after-finish-open()
method after-finish-open()
Subclass hook after lazy or eager open completes (e.g. flush altered
schema). Default: no-op.
method load-from-location()
method load-from-location()
Read the table file via Location Source + Format Parse, then map with
C<document-to-rows>.
method register-document-fields(Mu $parser, Mu $document)
method register-document-fields(Mu $parser, Mu $document)
$parser
Format Parse instance used for this load (may expose header metadata).
$document
Parsed document root before document-to-rows.
Optional hook after Format Parse during load: pre-register field names
(e.g. CSV headers) before fill_from_aoh so FieldMode sees schema first
(CD3). Default: no-op.
method flush-to-location()
method flush-to-location()
Map rows with C<rows-to-document>, Format Render, then Location Destination
overwrite (creating the path when absent via ensure-present semantics on
first write).
method render-document-options(-- Hash)>
method render-document-options(--> Hash)
Extra named options passed to Format Render during flush (e.g. CSV field order for header-only files). Default: none.
method clear-row-buffer()
Empty the in-memory row buffer without flushing (subclass hydrate helper).
method note-content-loaded(Bool $loaded = True)
Record whether the row buffer reflects Location content (subclass hydrate
helper).
Qwiratry::DatabaseStorage::Location
class Qwiratry::DatabaseStorage::Location does Qwiratry::DatabaseStorage
Abstract Location-backed database driver. Subclasses must implement
document-to-rows and rows-to-document.
Attributes
- Str $.location
- Directory (or base path) for table documents.
- Str $.format
- Format name for Parse/Render (default
JSONdemo). TheQwiratry::Format::JSONdistβsβ¦::Location::JSONdefaults toJSON.
- Str $.file-extension
- Suffix for per-table files (default
json).
.table-file-for
method table-file-for(Str $table-name --> Str)
Path of the document file for C<$table-name>.
.document-to-rows
Map a parsed Format document to a list of row Associatives. Subclasses
override.
.rows-to-document
Map an in-memory row list back to a Format document root. Subclasses
override.
.useTable
method useTable(:$table!, *%params)
Returns (or creates) per-table Location storage. Re-applies C<:action> on
reopen (DQ14.2).