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

Method extract_value

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

Extract a column value as a `Value`, performing type-aware decoding. This is the general-purpose extraction path. For hot paths, prefer `extract_fixed_raw` / `extract_variable_raw` to avoid `Value` allocation.

(&self, tuple: &[u8], col_idx: usize)

Source from the content-addressed store, hash-verified

206 /// This is the general-purpose extraction path. For hot paths, prefer
207 /// `extract_fixed_raw` / `extract_variable_raw` to avoid `Value` allocation.
208 pub fn extract_value(&self, tuple: &[u8], col_idx: usize) -> Result<Value, StrictError> {
209 self.check_bounds(col_idx)?;
210
211 if self.is_null(tuple, col_idx)? {
212 return Ok(Value::Null);
213 }
214
215 let col = &self.schema.columns[col_idx];
216
217 if col.column_type.fixed_size().is_some() {
218 let raw = self
219 .extract_fixed_raw(tuple, col_idx)?
220 .ok_or(StrictError::TypeMismatch {
221 column: col.name.clone(),
222 expected: col.column_type,
223 })?;
224 Ok(decode_fixed_value(&col.column_type, raw))
225 } else {
226 let raw =
227 self.extract_variable_raw(tuple, col_idx)?
228 .ok_or(StrictError::TypeMismatch {
229 column: col.name.clone(),
230 expected: col.column_type,
231 })?;
232 Ok(decode_variable_value(&col.column_type, raw))
233 }
234 }
235
236 /// Extract all columns from a tuple into a Vec<Value>.
237 pub fn extract_all(&self, tuple: &[u8]) -> Result<Vec<Value>, StrictError> {

Callers 5

extract_allMethod · 0.80
extract_by_nameMethod · 0.80
column_out_of_rangeFunction · 0.80

Calls 8

decode_fixed_valueFunction · 0.85
decode_variable_valueFunction · 0.85
check_boundsMethod · 0.80
fixed_sizeMethod · 0.80
extract_fixed_rawMethod · 0.80
extract_variable_rawMethod · 0.80
is_nullMethod · 0.45
cloneMethod · 0.45

Tested by 2

column_out_of_rangeFunction · 0.64