pub fn attach(
path: impl AsRef<Path>,
table: &str,
attachments: &[Attachment<'_>],
) -> Result<Table>Expand description
Attaches graph sections to a table already committed in a file, without rewriting a page.
This is the second pass spec/graph/03-the-file-format.md section 3.8 asks for. A key map has to exist before the link that uses it can be built, and it is built by reading the key column back, so the structures of a table cannot be written during the load that wrote the table. They are written afterwards, by this, and the file in between the two is a correct file that answers every query more slowly.
Nothing is overwritten. The payloads, the extent tables, the new directory for this table and
the new catalog all go on the end of the file past the committed generation, and the last write
is the header slot, exactly as Writer::finish does it. So a crash anywhere in here leaves
the generation before it intact, and leaves unreferenced trailing bytes that the next commit
writes past.
An attachment replaces any section of the same kind and id, and every other section is carried
through untouched, including one whose kind this build does not know. The table’s own generation
is carried through too, because attaching a section moves no row: see Table::generation.
§Errors
If the file has no valid committed directory, is an older format than this build writes, holds no table of that name, names a section whose payload cannot be written, or would end up naming more sections than the format allows.