pub struct DecisionSchema { /* private fields */ }Expand description
The Arrow-emission view over a set of questions. Cheap to clone (the questions are shared); the Arrow schema itself is rebuilt on demand so an emitted schema can never drift from the IR.
Implementations§
Source§impl DecisionSchema
impl DecisionSchema
Sourcepub fn new(questions: Vec<QuestionSpec>) -> Result<Self, ArrowSchemaError>
pub fn new(questions: Vec<QuestionSpec>) -> Result<Self, ArrowSchemaError>
Build from validated questions. The conformal-set column is emitted by default
(reserved in v1); see DecisionSchema::without_conformal_set.
Sourcepub fn from_question_set(set: &QuestionSet) -> Result<Self, ArrowSchemaError>
pub fn from_question_set(set: &QuestionSet) -> Result<Self, ArrowSchemaError>
Build from an authored question set (the state is not part of the columnar contract).
Sourcepub fn without_conformal_set(self) -> Self
pub fn without_conformal_set(self) -> Self
Omit the reserved conformal-set columns (v1 consumers that do not read them).
Sourcepub fn questions(&self) -> &[QuestionSpec]
pub fn questions(&self) -> &[QuestionSpec]
The questions backing this schema, in canonical order.
Sourcepub fn arrow_schema(&self) -> Schema
pub fn arrow_schema(&self) -> Schema
The Arrow schema. Schema metadata is always empty by construction: labels live in field metadata, calibration parameters in P0.3 tables.
Sourcepub fn fingerprint(&self) -> String
pub fn fingerprint(&self) -> String
A stable content fingerprint over (id, kind, labels) per question plus the conformal-set flag. Registries persist this to detect drift; the hex string is safe to embed in P0.3 rows.
Sourcepub fn check_evolution(
old: &Self,
new: &Self,
) -> Result<EvolutionReport, EvolutionError>
pub fn check_evolution( old: &Self, new: &Self, ) -> Result<EvolutionReport, EvolutionError>
Fail-loud schema evolution check. Adding or removing questions is compatible
(reported); changing an existing question’s kind or label set — or flipping
conformal-set emission, which changes the emitted column set — is not: mint a new
schema version instead. The rejected inputs are exactly the ones
DecisionSchema::fingerprint distinguishes.
Sourcepub fn build_batch(
&self,
version: &VersionTriple,
rows: &[AnswerRow],
) -> Result<RecordBatch, BatchError>
pub fn build_batch( &self, version: &VersionTriple, rows: &[AnswerRow], ) -> Result<RecordBatch, BatchError>
Encode rows into a record batch under this schema. Every row must carry an answer (possibly abstained) for every declared question; distributions are validated against the producer tolerance (D5).
Trait Implementations§
Source§impl Clone for DecisionSchema
impl Clone for DecisionSchema
Source§fn clone(&self) -> DecisionSchema
fn clone(&self) -> DecisionSchema
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more