Implement exporting (and importing) #194

Open
opened 2020-08-06 16:56:28 +00:00 by gburd · 0 comments
gburd commented 2020-08-06 16:56:28 +00:00 (Migrated from github.com)

With a small amount of work we can extract Tolstoy's tx_processor, moving it into db and wrapping it in conn.rs.

The signature might look something like this:

impl<'a, 'c> InProgress<'a, 'c> {
    /// Write out the contents of the store in a way that can be loaded.
    /// There are two ways to do this:
    ///
    /// - Preserving identifiers. Loading onto a non-empty store is likely to fail.
    ///   Loading into the existing store should transact nothing.
    /// - Remapping all identifiers to temporary IDs. This is more work to load, and
    ///   repeated loads will result in some duplicated entities, but smushing should
    ///   cause identifiers to be unified.
    ///
    /// The file will be populated with a sequence of transactions, each consisting of
    /// a sequence of datoms.
    fn export(&self, file: File) -> Result<File> {
        …
    }
}

impl<'a, 'c> InProgressRead<'a, 'c> {
    fn export(&self, file: File) -> Result<File> {
        self.inner.export(file)
    }
}

impl Conn {
    fn export(&self, file: File) -> Result<File> {
        self.begin_read()?.export(file)
    }
}

impl Store {
    fn export(&self, file: File) -> Result<File> {
        self.conn.export(file)
    }
}

That block comment is one way this could work.

With a small amount of work we can extract Tolstoy's `tx_processor`, moving it into `db` and wrapping it in `conn.rs`. The signature might look something like this: ``` impl<'a, 'c> InProgress<'a, 'c> { /// Write out the contents of the store in a way that can be loaded. /// There are two ways to do this: /// /// - Preserving identifiers. Loading onto a non-empty store is likely to fail. /// Loading into the existing store should transact nothing. /// - Remapping all identifiers to temporary IDs. This is more work to load, and /// repeated loads will result in some duplicated entities, but smushing should /// cause identifiers to be unified. /// /// The file will be populated with a sequence of transactions, each consisting of /// a sequence of datoms. fn export(&self, file: File) -> Result<File> { … } } impl<'a, 'c> InProgressRead<'a, 'c> { fn export(&self, file: File) -> Result<File> { self.inner.export(file) } } impl Conn { fn export(&self, file: File) -> Result<File> { self.begin_read()?.export(file) } } impl Store { fn export(&self, file: File) -> Result<File> { self.conn.export(file) } } ``` That block comment is one way this could work.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: greg/mentat#194
No description provided.