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

Function encode_column

arrow-row/src/lib.rs:1871–2057  ·  view source on GitHub ↗

Encodes a column to the provided [`Rows`] incrementing the offsets as it progresses

(
    data: &mut [u8],
    offsets: &mut [usize],
    column: &dyn Array,
    opts: SortOptions,
    encoder: &Encoder<'_>,
)

Source from the content-addressed store, hash-verified

1869
1870/// Encodes a column to the provided [`Rows`] incrementing the offsets as it progresses
1871fn encode_column(
1872 data: &mut [u8],
1873 offsets: &mut [usize],
1874 column: &dyn Array,
1875 opts: SortOptions,
1876 encoder: &Encoder<'_>,
1877) {
1878 match encoder {
1879 Encoder::Stateless => {
1880 downcast_primitive_array! {
1881 column => {
1882 if let Some(nulls) = column.nulls().filter(|n| n.null_count() > 0){
1883 fixed::encode(data, offsets, column.values(), nulls, opts)
1884 } else {
1885 fixed::encode_not_null(data, offsets, column.values(), opts)
1886 }
1887 }
1888 DataType::Null => {
1889 for offset in offsets.iter_mut().skip(1) {
1890 variable::encode_null_value(&mut data[*offset..], opts);
1891 *offset += 2;
1892 }
1893 }
1894 DataType::Boolean => {
1895 if let Some(nulls) = column.nulls().filter(|n| n.null_count() > 0){
1896 fixed::encode_boolean(data, offsets, column.as_boolean().values(), nulls, opts)
1897 } else {
1898 fixed::encode_boolean_not_null(data, offsets, column.as_boolean().values(), opts)
1899 }
1900 }
1901 DataType::Binary => {
1902 variable::encode_generic_byte_array(data, offsets, as_generic_binary_array::<i32>(column), opts)
1903 }
1904 DataType::BinaryView => {
1905 variable::encode(data, offsets, column.as_binary_view().iter(), opts)
1906 }
1907 DataType::LargeBinary => {
1908 variable::encode_generic_byte_array(data, offsets, as_generic_binary_array::<i64>(column), opts)
1909 }
1910 DataType::Utf8 => variable::encode_generic_byte_array(
1911 data, offsets,
1912 column.as_string::<i32>(),
1913 opts,
1914 ),
1915 DataType::LargeUtf8 => variable::encode_generic_byte_array(
1916 data, offsets,
1917 column.as_string::<i64>(),
1918 opts,
1919 ),
1920 DataType::Utf8View => variable::encode(
1921 data, offsets,
1922 column.as_string_view().iter().map(|x| x.map(|x| x.as_bytes())),
1923 opts,
1924 ),
1925 DataType::FixedSizeBinary(_) => {
1926 let array = column.as_any().downcast_ref().unwrap();
1927 fixed::encode_fixed_size_binary(data, offsets, array, opts)
1928 }

Callers 1

appendMethod · 0.85

Calls 15

null_sentinelFunction · 0.85
as_list_arrayFunction · 0.85
as_large_list_arrayFunction · 0.85
compute_list_view_boundsFunction · 0.85
encode_list_viewFunction · 0.85
encode_fixed_size_listFunction · 0.85
as_fixed_size_list_arrayFunction · 0.85
encodeFunction · 0.70
num_rowsMethod · 0.45
data_typeMethod · 0.45
iterMethod · 0.45
skipMethod · 0.45

Tested by

no test coverage detected