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

Method get_value

nodedb-columnar/src/memtable/column_data/access.rs:60–128  ·  view source on GitHub ↗

Extract a single row's value as `nodedb_types::Value`.

(&self, row: usize)

Source from the content-addressed store, hash-verified

58
59 /// Extract a single row's value as `nodedb_types::Value`.
60 pub(crate) fn get_value(&self, row: usize) -> Value {
61 if self.is_null(row) {
62 return Value::Null;
63 }
64 match self {
65 Self::Int64 { values, .. } => Value::Integer(values[row]),
66 Self::Float64 { values, .. } => Value::Float(values[row]),
67 Self::Bool { values, .. } => Value::Bool(values[row]),
68 Self::Timestamp { values, .. } => Value::DateTime(
69 nodedb_types::datetime::NdbDateTime::from_micros(values[row]),
70 ),
71 Self::Decimal { values, .. } => {
72 Value::Decimal(rust_decimal::Decimal::deserialize(values[row]))
73 }
74 Self::Uuid { values, .. } => {
75 Value::Uuid(uuid::Uuid::from_bytes(values[row]).to_string())
76 }
77 Self::String { data, offsets, .. } => {
78 let start = offsets[row] as usize;
79 let end = offsets[row + 1] as usize;
80 let s = std::str::from_utf8(&data[start..end])
81 .unwrap_or("")
82 .to_string();
83 Value::String(s)
84 }
85 Self::Bytes { data, offsets, .. } => {
86 let start = offsets[row] as usize;
87 let end = offsets[row + 1] as usize;
88 Value::Bytes(data[start..end].to_vec())
89 }
90 Self::Json { data, offsets, .. } => {
91 let start = offsets[row] as usize;
92 let end = offsets[row + 1] as usize;
93 let slice = &data[start..end];
94 if slice.is_empty() {
95 Value::Null
96 } else {
97 value_from_msgpack(slice).unwrap_or(Value::Null)
98 }
99 }
100 Self::Geometry { data, offsets, .. } => {
101 let start = offsets[row] as usize;
102 let end = offsets[row + 1] as usize;
103 let s = std::str::from_utf8(&data[start..end])
104 .unwrap_or("")
105 .to_string();
106 Value::String(s)
107 }
108 Self::Vector { data, dim, .. } => {
109 let d = *dim as usize;
110 let start = row * d;
111 let floats: Vec<Value> = data[start..start + d]
112 .iter()
113 .map(|&f| Value::Float(f as f64))
114 .collect();
115 Value::Array(floats)
116 }
117 Self::DictEncoded {

Callers 7

get_rowMethod · 0.80
nextMethod · 0.80
list_getFunction · 0.80
read_row_as_ofMethod · 0.80
read_at_versionMethod · 0.80
read_rowMethod · 0.80
read_fieldMethod · 0.80

Calls 10

deserializeFunction · 0.85
value_from_msgpackFunction · 0.85
to_stringMethod · 0.80
collectMethod · 0.80
is_nullMethod · 0.45
to_vecMethod · 0.45
is_emptyMethod · 0.45
iterMethod · 0.45
lenMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected