MCPcopy Create free account
hub / github.com/cosdata/cosdata / from

Method from

src/models/types.rs:115–128  ·  view source on GitHub ↗
(dims: MetadataDimensions)

Source from the content-addressed store, hash-verified

113
114impl From<MetadataDimensions> for Metadata {
115 fn from(dims: MetadataDimensions) -> Self {
116 let total = dims
117 .iter()
118 .map(|d| {
119 let x = *d as f32;
120 x * x
121 })
122 .sum::<f32>();
123 // @NOTE: As `MetadataDimensions` have high weight values, we
124 // need to handle overflow during intermediate addition when
125 // calculating the euclidean norm
126 let mag = total.min(f32::MAX).sqrt();
127 Self { mag, mbits: dims }
128 }
129}
130
131impl From<&QueryFilterDimensions> for Metadata {

Callers

nothing calls this directly

Calls 2

minMethod · 0.80
iterMethod · 0.45

Tested by

no test coverage detected