zer_adapters/lib.rs
1/// Type adapters that bridge external data-frame / record-batch libraries to
2/// `zer_core::record::Record` without a string round-trip.
3///
4/// # Feature flags
5///
6/// | flag | what it adds |
7/// |----------|---------------------------------------------------|
8/// | `polars` | `PolarsIngest` extension trait for Polars DataFrames |
9/// | `arrow` | `ArrowIngest` extension trait for Arrow RecordBatches |
10///
11/// Enable only the features you need to keep compile times low.
12pub mod bench_writer;
13pub mod time;
14
15pub use bench_writer::{
16 band_to_match, AccuracyMetrics, BenchBatchSummary, BenchResultWriter, PairRecord,
17};
18pub use time::{fmt_unix_secs, unix_secs_now, utc_timestamp_iso};
19
20#[cfg(feature = "polars")]
21pub mod polars;
22
23#[cfg(feature = "arrow")]
24pub mod arrow;
25
26#[cfg(feature = "polars")]
27pub use polars::PolarsIngest;
28
29#[cfg(feature = "arrow")]
30pub use arrow::ArrowIngest;
31
32/// Configuration for loading a dataset from an external source.
33///
34/// Specifies which column holds the record's natural key (e.g. BSN, UUID,
35/// or any primary-key column) and what source label to attach.
36///
37/// The adapter uses `key_column` to extract the natural key from each row,
38/// then derives a stable `RecordId` via `FNV-1a(source:key)`. This removes
39/// the need for users to maintain sequential integer offsets across datasets.
40///
41/// # Example
42///
43/// ```rust
44/// use zer_adapters::DatasetConfig;
45///
46/// let cfg = DatasetConfig::new("brp", "bsn");
47/// assert_eq!(cfg.source, "brp");
48/// assert_eq!(cfg.key_column, "bsn");
49/// ```
50#[derive(Debug, Clone)]
51pub struct DatasetConfig {
52 /// Source label attached to every record (e.g. `"brp"`, `"kvk"`).
53 pub source: String,
54 /// Name of the column whose value is the record's natural key.
55 pub key_column: String,
56}
57
58impl DatasetConfig {
59 pub fn new(source: impl Into<String>, key_column: impl Into<String>) -> Self {
60 Self {
61 source: source.into(),
62 key_column: key_column.into(),
63 }
64 }
65}