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:
- element
DimensionElement
orstr
, 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 theto_arrow
method).- records
Iterable
[DimensionRecord
], optional Dimension records to add to the table.
- universe
DimensionUniverse
, optional Object that defines all dimensions. Ignored if
element
is aDimensionElement
instance.- table
pyarrow.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 aDimensionRecordTable
that has been serialized to an Arrow-supported file or IPC format.- batch_size
int
, optional How many elements of
records
should be processed at a time, with each batch yielding apyarrow.RecordBatch
in the created table. Smaller values will reduce peak memory usage for large iterables. Ignored ifrecords
is empty.
- element
Notes
DimensionRecordTable
should generally have a smaller memory footprint thanDimensionRecordSet
if its rows are unique, and it provides fast column-oriented access and Arrow interoperability thatDimensionRecordSet
lacks entirely. In other respectsDimensionRecordSet
is more featureful and simpler to use efficiently.Attributes Summary
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:
- name
str
Name of the column. Valid options are given by
DimensionElement.schema.names
, and are the same as the attributes of the dimension records.
- name
- Returns:
- array
pyarrow.ChunkedArray
An array view of the column.
- array
- extend(records: Iterable[DimensionRecord]) None ¶
Add new rows to the end of the table.
- Parameters:
- records
Iterable
[DimensionRecord
] Dimension records to add to the table.
- records
- 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:
- element
DimensionElement
Dimension element that defines the schema.
- element
- Returns:
- schema
pyarrow.Schema
Arrow schema.
- schema
- to_arrow() Table ¶
Return a Arrow table holding the same records.