DimensionRecordTable

final class lsst.daf.butler.DimensionRecordTable(element: DimensionElement | str | None = None, records: Iterable[DimensionRecord] = (), universe: DimensionUniverse | None = None, table: pa.Table | None = None, batch_size: int | None = None)

Bases: object

A table-like container for DimensionRecord objects.

Parameters:
elementDimensionElement or str, optional

The dimension element that defines the records held by this table. If not a DimensionElement instance, universe must be provided. If not provided, table must have an “element” entry in its metadata (as is the case for tables returned by the to_arrow method).

recordsIterable [ DimensionRecord ], optional

Dimension records to add to the table.

universeDimensionUniverse, optional

Object that defines all dimensions. Ignored if element is a DimensionElement instance.

tablepyarrow.Table

Arrow table to copy columns from. Must have schema returned by make_arrow_schema for this element. This argument is primarily intended to serve as the way to reconstruct a DimensionRecordTable that has been serialized to an Arrow-supported file or IPC format.

batch_sizeint, optional

How many elements of records should be processed at a time, with each batch yielding a pyarrow.RecordBatch in the created table. Smaller values will reduce peak memory usage for large iterables. Ignored if records is empty.

Notes

DimensionRecordTable should generally have a smaller memory footprint than DimensionRecordSet if its rows are unique, and it provides fast column-oriented access and Arrow interoperability that DimensionRecordSet lacks entirely. In other respects DimensionRecordSet is more featureful and simpler to use efficiently.

Attributes Summary

element

The dimension element that defines the records of this table.

Methods Summary

column(name)

Return a single column from the table as an array.

extend(records)

Add new rows to the end of the table.

make_arrow_schema(element)

Return the Arrow schema of the table returned by to_arrow with the given dimension element.

to_arrow()

Return a Arrow table holding the same records.

Attributes Documentation

element

The dimension element that defines the records of this table.

Methods Documentation

column(name: str) ChunkedArray

Return a single column from the table as an array.

Parameters:
namestr

Name of the column. Valid options are given by DimensionElement.schema.names, and are the same as the attributes of the dimension records.

Returns:
arraypyarrow.ChunkedArray

An array view of the column.

extend(records: Iterable[DimensionRecord]) None

Add new rows to the end of the table.

Parameters:
recordsIterable [ DimensionRecord ]

Dimension records to add to the table.

classmethod make_arrow_schema(element: DimensionElement) pa.Schema

Return the Arrow schema of the table returned by to_arrow with the given dimension element.

Parameters:
elementDimensionElement

Dimension element that defines the schema.

Returns:
schemapyarrow.Schema

Arrow schema.

to_arrow() Table

Return a Arrow table holding the same records.