Extract raw bytes for a fixed-size column. Returns `None` if null. This is the O(1) fast path: a single bounds check + pointer slice.
(
&self,
tuple: &'a [u8],
col_idx: usize,
)
| 108 | /// |
| 109 | /// This is the O(1) fast path: a single bounds check + pointer slice. |
| 110 | pub fn extract_fixed_raw<'a>( |
| 111 | &self, |
| 112 | tuple: &'a [u8], |
| 113 | col_idx: usize, |
| 114 | ) -> Result<Option<&'a [u8]>, StrictError> { |
| 115 | self.check_bounds(col_idx)?; |
| 116 | self.check_min_size(tuple)?; |
| 117 | |
| 118 | if self.is_null_unchecked(tuple, col_idx) { |
| 119 | return Ok(None); |
| 120 | } |
| 121 | |
| 122 | let offset = self.fixed_offsets[col_idx].ok_or(StrictError::TypeMismatch { |
| 123 | column: self.schema.columns[col_idx].name.clone(), |
| 124 | expected: self.schema.columns[col_idx].column_type, |
| 125 | })?; |
| 126 | |
| 127 | let size = self.schema.columns[col_idx] |
| 128 | .column_type |
| 129 | .fixed_size() |
| 130 | .ok_or(StrictError::TypeMismatch { |
| 131 | column: self.schema.columns[col_idx].name.clone(), |
| 132 | expected: self.schema.columns[col_idx].column_type, |
| 133 | })?; |
| 134 | let start = self.header_size + offset; |
| 135 | let end = start + size; |
| 136 | |
| 137 | if end > tuple.len() { |
| 138 | return Err(StrictError::TruncatedTuple { |
| 139 | expected: end, |
| 140 | got: tuple.len(), |
| 141 | }); |
| 142 | } |
| 143 | |
| 144 | Ok(Some(&tuple[start..end])) |
| 145 | } |
| 146 | |
| 147 | /// Extract raw bytes for a variable-length column. Returns `None` if null. |
| 148 | /// |