DimensionRecordSetDeserializer

class lsst.daf.butler.DimensionRecordSetDeserializer(element: DimensionElement, mapping: dict[tuple[DataIdValue, ...], SerializedKeyValueDimensionRecord])

Bases: object

A helper class for deserializing sets of dimension records, with support for only fully deserializing certain records.

The from_raw factory method should generally be used instead of calling the constructor directly.

Parameters:
elementDimensionElement

Dimension element that defines all records.

mappingdict [ tuple, list ]

A dictionary that maps the data ID required-values tuple for reach record to the remainder of its raw serialization (i.e. an item in this dict is a pair returned by DimensionRecord.deserialize_key). This dict will be used directly to back the deserializer, not copied.

Notes

The keys (data ID required-values tuples) of all rows are deserialized immediately, but the remaining fields are deserialized only on demand; use __iter__ to deserialize all records or __getitem__ to deserialize only a few. An instance should really only be used for a single iteration or multiple __getitem__ calls, as each call will re-deserialize the records in play; deserialized records are not cached.

The caller is responsible for ensuring that the serialized records are for the given dimension element, as this cannot be checked. Mismatches will probably result in a (confusing) type-validation error, but are not guaranteed to.

Methods Summary

from_raw(element, raw_records)

Construct from raw serialized records.

Methods Documentation

classmethod from_raw(element: DimensionElement, raw_records: Iterable[SerializedKeyValueDimensionRecord]) Self

Construct from raw serialized records.

Parameters:
elementDimensionElement

Dimension element that defines all records.

raw_recordsIterable [ list ]

Serialized records, as returned by DimensionRecordSet.serialize_records or repeated calls to DimensionRecord.serialize_key_value.

Returns:
deserializerDimensionRecordSetDeserializer

New deserializer instance.