Write the species_flat roll-ups and the parent split
Source:R/species.R
obis_h3_write_species_flat.RdFrom the finest cell-sorted species file flat_dir/res=<from_res>.parquet
(written by obis_h3_export_parquet()), writes
Arguments
- con
a DBI connection to DuckDB with the
h3extension loaded.- flat_dir
the release's
species_flat/folder.- from_res
the resolution of the file the others come from (default 3).
- res
the coarser resolutions to roll up to (default 1 and 2).
- split
a named integer vector, resolution = parent resolution, of the files to split (default
c("3" = 1L));NULLwrites none. A split resolution must befrom_resor one ofres.- row_group_rows
rows per row group of the roll-ups (default 10000).
- split_row_group_rows
rows per row group of the split files (default 2048, one DuckDB vector; a group holds at most twice that).
- compression
Parquet codec (default
"zstd").
Value
a data frame, one row per file written: path (relative to the
release, species_flat/...), res, parent (NA for a roll-up), rows,
bytes.
Details
res=<r>.parquetfor eachrinres(coarser thanfrom_res): one row per cell and species,obis_h3_species_rollup_sql(), so a coarse hexagon's list is its own rows, not its children's;res=<s>/p=<parent>.parquetfor eachs = names(split): the rows ofres=<s>.parquetunder one parent cell atsplit[[s]](the parent's lowercase hex id), so a page reads a file small enough for its footer to come with the first range read.
Every file written has the columns cell_id, name_key, aphiaid, n, year_min, year_max (no h3: cell_id gives it, and its string statistics
are the largest part of a footer), sorted by cell_id, aphiaid, in row
groups of row_group_rows (the roll-ups) or split_row_group_rows (the
split), so the cell_id statistics of consecutive groups ascend (a cell's
rows lie in one group or in adjacent ones). As for the layer files, DuckDB
writes a group of at most 2 x the size asked (v20261012's split: 4,081 rows
at most for 2,048). res=<from_res>.parquet is read, never rewritten.