import type { PathBuilderLike } from "path-ts"; /** * Options for {@link mergeSourceFiles}. */ export interface MergeSourceOptions { /** * The parquet files to merge, read in the order given. */ inputs: readonly PathBuilderLike[]; /** * The output path. * Each written file receives a five-digit index in its stem. */ output: PathBuilderLike; /** * The number of rows held in memory while shuffling. * * @defaultValue the corpus writer's window. */ windowSize?: number; /** * Keep at most `rowsPerCountry` rows of each country, chosen by a hash of each row's `source_id`, * and write the kept rows of every input in one hash order rather than through the window. * * A build writes a source's rows in record order, so the 250,000-row window mixes a few thousand * neighboring records, and a training draw that reads one row group sees one stretch of one country. * The hash order makes every row group a sample of the whole selection. */ rowsPerCountry?: number; /** * Keep the first rows of every cell before the per-country fill, so a rare structure * reaches the sample regardless of the row count for its country. * * With a floor, `rowsPerCountry` is exact: each country keeps its floor rows, * then the rest of its rows in hash order up to `rowsPerCountry`. * Without `rowsPerCountry`, each country keeps only its floor rows. */ cellFloor?: CellFloor; /** * The shuffle seed. * * The default matches the corpus writer's seed. * This makes rebuilds reproducible. */ seed?: number; /** * The maximum rows per output file. * * `writeParquetFile` builds one Arrow table per file. * Arrow's list builder overflows on very large tables. */ rowsPerFile?: number; } /** * The rows every cell keeps in a {@link mergeSourceFiles} sample. */ export interface CellFloor { /** * Rows each cell keeps, chosen in hash order. * A cell with fewer rows keeps them all. */ rows: number; /** * SQL expressions over a row's columns. * * Each one splits every country's rows into cells, and a row is kept * when it is among the first `rows` of any of its cells. */ keys: readonly string[]; } /** * The components a row's `B-` labels open, in order, such as `locality region country`. * * The order represents the rendered record's placetype, its neighboring levels and their order. */ export declare const LABEL_ORDER_SQL = "array_to_string(list_transform(list_filter(labels, lambda x: x LIKE 'B-%'), lambda x: substr(x, 3)), ' ')"; /** * The cell keys a {@link CellFloor} can reference. * * `structure` is the label order and the surface augmentation, for any source. * `wof-name-slot` adds the WOF name slot's kind to that structure, * and keys a second cell by the slot's language. */ export declare const CELL_KEYS: { readonly structure: readonly ["array_to_string(list_transform(list_filter(labels, lambda x: x LIKE 'B-%'), lambda x: substr(x, 3)), ' ') || '|' || coalesce(augmentation, '')"]; readonly "wof-name-slot": readonly [`array_to_string(list_transform(list_filter(labels, lambda x: x LIKE 'B-%'), lambda x: substr(x, 3)), ' ') || '|' || coalesce(augmentation, '') || '|' || ${string}`, string]; }; /** * The files that {@link mergeSourceFiles} wrote and the row counts they hold. */ export interface MergeSourceResult { inputs: readonly string[]; /** * The files written, in order. */ outputs: readonly string[]; rows: number; /** * Row counts per `country` value. */ byCountry: Record; /** * Row counts per `source` value. * A successful merge has one entry. */ bySource: Record; } /** * The `source_id` values a {@link CellFloor} sample keeps, as a subquery over the inputs. * * Within each country a row is a floor row when it is among the first `floor.rows` * of any of its cells in hash order. * The country then keeps its floor rows and, in hash order, its other rows until it holds `fill` rows. */ export declare function cellFloorSQL(inputs: readonly PathBuilderLike[], floor: CellFloor, fill: number, seed: number): string; /** * Merges the inputs through a windowed shuffle into one or more parquet files and reports their contents. * * Each written file gets a record beside it. * Its extract hash covers every input's sha256 in order. * * The record keeps the checkout commits shared by its inputs' records. * It records none when any input lacks them. * * @throws When the inputs contain more than one `source`, because a manifest * entry records one source per file. * An output file that would mix sources is refused when it is written. * A file flushed before the second source arrived remains on disk. */ export declare function mergeSourceFiles(options: MergeSourceOptions): Promise; //# sourceMappingURL=merge-source.d.ts.map