MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / extract_fixed_raw

Method extract_fixed_raw

nodedb-strict/src/decode.rs:110–145  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

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 ///

Callers 10

extract_int64Function · 0.80
extract_float64Function · 0.80
extract_boolFunction · 0.80
extract_timestampFunction · 0.80
extract_uuidFunction · 0.80
extract_vectorFunction · 0.80
extract_valueMethod · 0.80
extract_i64Function · 0.80
raw_fixed_extractionFunction · 0.80

Calls 6

check_boundsMethod · 0.80
check_min_sizeMethod · 0.80
is_null_uncheckedMethod · 0.80
fixed_sizeMethod · 0.80
cloneMethod · 0.45
lenMethod · 0.45

Tested by 1

raw_fixed_extractionFunction · 0.64