gizmodel/copy
The pieces every copy into GizDB shares: the page credit, the rows a source answers, and the one proof of a copy, an order-free checksum of its rows (Store.copy and Store.move, gizdb migrate). Federation's model/source.giz owns query planning, not data movement.
import * as Copy from "gizmodel/copy";Types
Column
type Column = { slot: Slot; declared: string; }Preserve the declared type; a text slot cannot identify JSON by itself.
slot:M142.Slotdeclared:string
Rows
type Rows = { columns: Vec<Column>; rows: Vec<Vec<Value>>; }The columns and the rows of one page of a copy.
columns:Vec<M126.Column>rows:Vec<Vec<M143.Value>>
Copy
type Copy = { table: string; rows: i64; bytes: i64; done: bool; }The state of the copy of one table: rows and bytes copied, and whether it is done.
table:stringrows:i64bytes:i64done:bool
Verification
type Verification = { table: string; status: string; source: Checksum; target: Checksum; firstKey: string; bytes: i64; }The check of one copied table: its status, the checksums of source and target, and the first key that differs.
table:stringstatus:stringsource:M126.Checksumtarget:M126.ChecksumfirstKey:stringbytes:i64
Progress
type Progress = { source: string; table: string; lastKey: string; offset: i64; done: bool; rows: i64; bytes: i64; schema: string; }Where the copy of one table stands: the last key and offset copied, the rows and bytes so far, and its schema.
source:stringtable:stringlastKey:stringoffset:i64done:boolrows:i64bytes:i64schema:string
Checksum
type Checksum = { count: i64; sum: bytes; }The proof of a copy: the SHA-256 digests of its rows summed modulo 2^256, and their count. The order of the rows does not change it, so a source and a target that order keys apart, and pages copied in any order, compare equal.
count:i64sum:bytes
Functions
checksum
function checksum(): ChecksumAn empty checksum: no rows, a zero sum.
Effects: fail, alloc.
contentDigest
function contentDigest(row: Vec<Value>): bytes throws DbErrorThe SHA-256 digest of the encoded ROW. A row over 8 MiB is refused.
Effects: fail, alloc.
Methods
Checksum.add
function Checksum.add(self: mut Checksum, row: Vec<Value>): bool throws DbErrorAdds the digest of ROW to the checksum.
Effects: fail, alloc.
Checksum.include
function Checksum.include(self: mut Checksum, other: Checksum): bool throws DbErrorAdds the rows that OTHER counts.
Effects: fail, alloc.
Constants
TARGET_PAGE_BYTES
const TARGET_PAGE_BYTES: i64 = 262144Page credit fits the native actor. It does not limit the complete result.
MAX_PAGE_ROWS
const MAX_PAGE_ROWS: i64 = 1000The most rows in one page of a copy.