Chunk tables
chunk_tables, §M14.22 E7
Ez az oldal a nucleus saját dokumentációjából készül, ezért angol nyelvű.
CREATE TABLE c CHUNKS OF docs (body) BY sentences | tokens | markdown SIZE n [OVERLAP n] [USING model]: a table of the chunks chunks()
(§8.25) cuts from docs.body, kept current with docs. Its columns:
docs’ primary key columns (names and types), position, chunk,
start, length, headings, size, all NOT NULL; its primary key
the documents’ key and position; its lineage a foreign key
c_document_fkey to docs ON DELETE CASCADE ON UPDATE CASCADE. The
table record (version 16) keeps a chunk table’s ChunkSpec (the foreign
key’s name, the text column’s position, by, size, overlap, model) after
its columns’ generations. Made by SQL the module writes and
session::create_table, then filled from every document. Needs: a
primary key on docs, a text column (42804), a table neither
partitioned nor a chunk table (0A000); CREATE on the schema,
SELECT on the column and REFERENCES on the key.
Kept current in the writer’s transaction (chunking is local; no call
leaves the process): Writer::new of a table finds its chunk tables
among the foreign keys referencing it (chunk_tables::of); after an
insert (store_batch) the new documents’ chunks are inserted in one
batch; after an update (update_rows, past the foreign keys’ actions)
each document whose text changed is chunked again (rechunk): its
chunks read by the foreign key, matched with the new ones by text (the
same position first); unmatched old ones deleted, matched ones whose
position moved updated through negative positions (so no two meet on the
primary key), their other derived values set, unmatched new ones
inserted. A matched chunk keeps its row, so an embedding column over
chunk keeps its vector and gets no job. A key change is the foreign
key’s cascade; a delete, its cascade. INSERT, DELETE, COPY into a
chunk table and UPDATE of a derived or key column are refused
(42809); columns added to it are the user’s. Its foreign key is not
dropped (2BP01); the text column’s and the derived columns’ types are
not changed (0A000); DROP TABLE docs is 2BP01 while it has chunk
tables, … CASCADE drops them with it. A chunk table USING m counts
tokens without its writers’ USAGE on m (its maker’s was checked),
keeps m from being dropped, and is filled by a validated scan (a
document committed meanwhile makes the CREATE conflict); neither it
nor its documents’ table can be attached as a partition (0A000). Tests: tests/chunk_tables.rs,
and the crash workload of tests/embedding_columns.rs keeps one.