MCPcopy Create free account
hub / github.com/apache/arrow-rs / layout

Function layout

arrow-data/src/data.rs:1730–1823  ·  view source on GitHub ↗

Return the expected [`DataTypeLayout`] Arrays of this data type are expected to have

(data_type: &DataType)

Source from the content-addressed store, hash-verified

1728/// Return the expected [`DataTypeLayout`] Arrays of this data
1729/// type are expected to have
1730pub fn layout(data_type: &DataType) -> DataTypeLayout {
1731 // based on C/C++ implementation in
1732 // https://github.com/apache/arrow/blob/661c7d749150905a63dd3b52e0a04dac39030d95/cpp/src/arrow/type.h (and .cc)
1733 use arrow_schema::IntervalUnit::*;
1734
1735 match data_type {
1736 DataType::Null => DataTypeLayout {
1737 buffers: vec![],
1738 can_contain_null_mask: false,
1739 variadic: false,
1740 },
1741 DataType::Boolean => DataTypeLayout {
1742 buffers: vec![BufferSpec::BitMap],
1743 can_contain_null_mask: true,
1744 variadic: false,
1745 },
1746 DataType::Int8 => DataTypeLayout::new_fixed_width::<i8>(),
1747 DataType::Int16 => DataTypeLayout::new_fixed_width::<i16>(),
1748 DataType::Int32 => DataTypeLayout::new_fixed_width::<i32>(),
1749 DataType::Int64 => DataTypeLayout::new_fixed_width::<i64>(),
1750 DataType::UInt8 => DataTypeLayout::new_fixed_width::<u8>(),
1751 DataType::UInt16 => DataTypeLayout::new_fixed_width::<u16>(),
1752 DataType::UInt32 => DataTypeLayout::new_fixed_width::<u32>(),
1753 DataType::UInt64 => DataTypeLayout::new_fixed_width::<u64>(),
1754 DataType::Float16 => DataTypeLayout::new_fixed_width::<half::f16>(),
1755 DataType::Float32 => DataTypeLayout::new_fixed_width::<f32>(),
1756 DataType::Float64 => DataTypeLayout::new_fixed_width::<f64>(),
1757 DataType::Timestamp(_, _) => DataTypeLayout::new_fixed_width::<i64>(),
1758 DataType::Date32 => DataTypeLayout::new_fixed_width::<i32>(),
1759 DataType::Date64 => DataTypeLayout::new_fixed_width::<i64>(),
1760 DataType::Time32(_) => DataTypeLayout::new_fixed_width::<i32>(),
1761 DataType::Time64(_) => DataTypeLayout::new_fixed_width::<i64>(),
1762 DataType::Interval(YearMonth) => DataTypeLayout::new_fixed_width::<i32>(),
1763 DataType::Interval(DayTime) => DataTypeLayout::new_fixed_width::<IntervalDayTime>(),
1764 DataType::Interval(MonthDayNano) => {
1765 DataTypeLayout::new_fixed_width::<IntervalMonthDayNano>()
1766 }
1767 DataType::Duration(_) => DataTypeLayout::new_fixed_width::<i64>(),
1768 DataType::Decimal32(_, _) => DataTypeLayout::new_fixed_width::<i32>(),
1769 DataType::Decimal64(_, _) => DataTypeLayout::new_fixed_width::<i64>(),
1770 DataType::Decimal128(_, _) => DataTypeLayout::new_fixed_width::<i128>(),
1771 DataType::Decimal256(_, _) => DataTypeLayout::new_fixed_width::<i256>(),
1772 DataType::FixedSizeBinary(size) => {
1773 let spec = BufferSpec::FixedWidth {
1774 byte_width: (*size).try_into().unwrap(),
1775 alignment: mem::align_of::<u8>(),
1776 };
1777 DataTypeLayout {
1778 buffers: vec![spec],
1779 can_contain_null_mask: true,
1780 variadic: false,
1781 }
1782 }
1783 DataType::Binary => DataTypeLayout::new_binary::<i32>(),
1784 DataType::LargeBinary => DataTypeLayout::new_binary::<i64>(),
1785 DataType::Utf8 => DataTypeLayout::new_binary::<i32>(),
1786 DataType::LargeUtf8 => DataTypeLayout::new_binary::<i64>(),
1787 DataType::BinaryView | DataType::Utf8View => DataTypeLayout::new_view(),

Callers 9

extract_sparseFunction · 0.85
extract_denseFunction · 0.85
consumeMethod · 0.85
test_layoutFunction · 0.85
newMethod · 0.85
get_slice_memory_sizeMethod · 0.85
align_buffersMethod · 0.85
validateMethod · 0.85
get_or_truncate_bufferFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_layoutFunction · 0.68