pub struct Record {
pub id: RecordId,
pub key: String,
pub fields: AHashMap<FieldName, FieldValue>,
pub source: Option<String>,
}Expand description
A single data record with a unique ID and a map of field values.
id is an internal u64 used for fast indexing and joins. treat it as
opaque. key is the user-visible natural key: the value of whichever
column was nominated as the identity column when loading the dataset (e.g.
BSN, UUID, or primary-key value). The .zes output references records by
(source, key), not by id.
§Construction
Record::from_key. preferred when loading real data via azer_adapters::DatasetConfig. Derivesidfromhash(source:key).Record::new. for synthetic/test records; setskey = id.to_string().
Fields§
§id: RecordId§key: String§fields: AHashMap<FieldName, FieldValue>§source: Option<String>Implementations§
Source§impl Record
impl Record
Sourcepub fn new(id: RecordId) -> Self
pub fn new(id: RecordId) -> Self
Create a record with an explicit numeric ID.
key is set to id.to_string(). Use this only for synthetic or test
records. For real data use Record::from_key so that the natural
key is preserved in the .zes output.
Sourcepub fn from_key(source: impl Into<String>, key: impl Into<String>) -> Self
pub fn from_key(source: impl Into<String>, key: impl Into<String>) -> Self
Create a record whose identity comes from a natural key column.
id is derived deterministically via FNV-1a(source:key) so that the
same (source, key) pair always produces the same internal ID. The
source label is stored on the record, so calling Record::with_source
afterwards is not required (but is a no-op).
pub fn with_source(self, source: impl Into<String>) -> Self
pub fn insert( self, name: impl Into<String>, value: impl Into<FieldValue>, ) -> Self
pub fn get(&self, name: &str) -> Option<&FieldValue>
pub fn text(&self, name: &str) -> Option<&str>
Sourcepub fn field_as_str(&self, name: &str) -> Option<Cow<'_, str>>
pub fn field_as_str(&self, name: &str) -> Option<Cow<'_, str>>
Returns the field value as a string, coercing non-text scalars to their string representation.
Sourcepub fn field_as<T: FromFieldValue>(&self, name: &str) -> Option<T>
pub fn field_as<T: FromFieldValue>(&self, name: &str) -> Option<T>
Extract a typed value from a named field using the FromFieldValue trait.
use zer_core::record::{Record, FieldValue};
let r = Record::new(1).insert("lat", 52.37f64);
let lat: Option<f64> = r.field_as::<f64>("lat");
assert_eq!(lat, Some(52.37f64));