graflo.architecture.schema.derive¶
Normal forms, parts and keys of field values, and the fields derived from them.
A field's match declares how its values split into parts and which
normalizer they go through (:class:~graflo.architecture.schema.vertex.FieldMatch);
a derived field stores one form of another field's value
(:class:~graflo.architecture.schema.vertex.FieldDerived). Everything here is
pure and reads no database.
Attributes¶
Classes¶
Functions:¶
complete_derived(vertex, values)
¶
values with each derived field its source states set from that source.
For reads: a derived value stated without its source is kept, so a stored
normal form can address a vertex. Writes use :func:derive_fields.
Source code in graflo/architecture/schema/derive.py
derive_fields(vertex, doc)
¶
Set every derived field of vertex on doc from its source, in place.
Idempotent. A stated value is always overwritten, and a derived field whose source is missing is removed: core computes these, a document never supplies them.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
doc. |
Source code in graflo/architecture/schema/derive.py
derived_sources(vertex, names)
¶
names with each derived field replaced by its source, order kept.
Source code in graflo/architecture/schema/derive.py
derived_value(vertex, field, doc)
¶
The value of derived field for doc, from its source's value.
Source code in graflo/architecture/schema/derive.py
normal_value(field, value)
¶
value through the field's match.normalizer, or unchanged without one.
Returns None for a missing value or one that normalizes to nothing.
Source code in graflo/architecture/schema/derive.py
value_keys(field, value)
¶
Every less specific form of value, joined by spaces, general first (keys_v1).
The runs of its parts that keep the general end: leading runs for
general_first, trailing runs for specific_first. "Berlin, pump hall
2" split on , gives berlin, berlin pump hall 2. unordered
parts give no keys: every part would be one, and a common part reaches every
value that contains it.
Source code in graflo/architecture/schema/derive.py
value_parts(field, value)
¶
The normalized parts of value, as the field's match.parts splits it.
Separators split the raw value and each part is then normalized; words
splits the normalized value on whitespace. Empty parts are dropped.
None when the field declares no parts or value has none.