MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / push_datum

Function push_datum

src/repr/src/row.rs:1842–2068  ·  view source on GitHub ↗
(data: &mut D, datum: Datum)

Source from the content-addressed store, hash-verified

1840const LONG: usize = 1 << 32;
1841
1842fn push_datum<D>(data: &mut D, datum: Datum)
1843where
1844 D: Vector<u8>,
1845{
1846 match datum {
1847 Datum::Null => data.push(Tag::Null.into()),
1848 Datum::False => data.push(Tag::False.into()),
1849 Datum::True => data.push(Tag::True.into()),
1850 Datum::Int16(i) => {
1851 let mbs = min_bytes_signed(i);
1852 let tag = u8::from(if i.is_negative() {
1853 Tag::NegativeInt16_0
1854 } else {
1855 Tag::NonNegativeInt16_0
1856 }) + mbs;
1857
1858 data.push(tag);
1859 data.extend_from_slice(&i.to_le_bytes()[0..usize::from(mbs)]);
1860 }
1861 Datum::Int32(i) => {
1862 let mbs = min_bytes_signed(i);
1863 let tag = u8::from(if i.is_negative() {
1864 Tag::NegativeInt32_0
1865 } else {
1866 Tag::NonNegativeInt32_0
1867 }) + mbs;
1868
1869 data.push(tag);
1870 data.extend_from_slice(&i.to_le_bytes()[0..usize::from(mbs)]);
1871 }
1872 Datum::Int64(i) => {
1873 let mbs = min_bytes_signed(i);
1874 let tag = u8::from(if i.is_negative() {
1875 Tag::NegativeInt64_0
1876 } else {
1877 Tag::NonNegativeInt64_0
1878 }) + mbs;
1879
1880 data.push(tag);
1881 data.extend_from_slice(&i.to_le_bytes()[0..usize::from(mbs)]);
1882 }
1883 Datum::UInt8(i) => {
1884 let mbu = min_bytes_unsigned(i);
1885 let tag = u8::from(Tag::UInt8_0) + mbu;
1886 data.push(tag);
1887 data.extend_from_slice(&i.to_le_bytes()[0..usize::from(mbu)]);
1888 }
1889 Datum::UInt16(i) => {
1890 let mbu = min_bytes_unsigned(i);
1891 let tag = u8::from(Tag::UInt16_0) + mbu;
1892 data.push(tag);
1893 data.extend_from_slice(&i.to_le_bytes()[0..usize::from(mbu)]);
1894 }
1895 Datum::UInt32(i) => {
1896 let mbu = min_bytes_unsigned(i);
1897 let tag = u8::from(Tag::UInt32_0) + mbu;
1898 data.push(tag);
1899 data.extend_from_slice(&i.to_le_bytes()[0..usize::from(mbu)]);

Callers 3

pushMethod · 0.85
extendMethod · 0.85
try_extendMethod · 0.85

Calls 15

min_bytes_signedFunction · 0.85
min_bytes_unsignedFunction · 0.85
push_dateFunction · 0.85
push_timeFunction · 0.85
checked_timestamp_nanosFunction · 0.85
push_naive_dateFunction · 0.85
push_lengthed_bytesFunction · 0.85
push_untagged_bytesFunction · 0.85
cx_datumFunction · 0.85
is_negativeMethod · 0.80
to_naiveMethod · 0.80
dateMethod · 0.80

Tested by

no test coverage detected