pub struct Importer<'a, S> { /* private fields */ }Expand description
Restores exported records into a store, in batches within
MAX_BATCH_OPS and MAX_BATCH_BYTES (so they fit Durable Object
limits), one partition per batch; one write per batch on a store without
atomic_multi_key. A partition’s records must be contiguous, as an
export writes them.
On the first record of each partition, ImportMode::Fresh checks the
partition is empty. After a partition’s last record, a store that holds
the v class gets v = the header’s layout version if the export had
no v row (a RefsOnly export), written only if absent. Records are
plain puts, so an interrupted import can be rerun with
ImportMode::Merge.
Implementations§
Source§impl<'a, S: NamespaceStore> Importer<'a, S>
impl<'a, S: NamespaceStore> Importer<'a, S>
Sourcepub fn new(
store: &'a S,
header: &ExportHeader,
mode: ImportMode,
) -> Result<Self, StoreError>
pub fn new( store: &'a S, header: &ExportHeader, mode: ImportMode, ) -> Result<Self, StoreError>
An importer for an export with header.
§Errors
StoreError::Unsupported if the export’s layout version is newer
than keys::LAYOUT_VERSION, or differs from the implicit layout
version of a store that cannot hold v.
Sourcepub async fn push(&mut self, record: ExportRecord) -> Result<(), StoreError>
pub async fn push(&mut self, record: ExportRecord) -> Result<(), StoreError>
Queue record, committing the pending batch first if the record
changes partition or would overflow it.
§Errors
StoreError::Unsupported for a v row newer than this binary’s
layout; StoreError::Invalid for a non-empty partition under
ImportMode::Fresh; any error of the store’s apply.
Sourcepub async fn finish(self) -> Result<u64, StoreError>
pub async fn finish(self) -> Result<u64, StoreError>
Commit the pending batches; the number of records imported.