(array: &str, dim: &DimSpec, value: &CoordValue, bits: u32)
| 52 | } |
| 53 | |
| 54 | fn normalize_one(array: &str, dim: &DimSpec, value: &CoordValue, bits: u32) -> ArrayResult<u64> { |
| 55 | let max = if bits >= 64 { |
| 56 | u64::MAX |
| 57 | } else { |
| 58 | (1u64 << bits) - 1 |
| 59 | }; |
| 60 | match (&dim.dtype, value, &dim.domain.lo, &dim.domain.hi) { |
| 61 | (DimType::Int64, CoordValue::Int64(v), DomainBound::Int64(lo), DomainBound::Int64(hi)) |
| 62 | | ( |
| 63 | DimType::TimestampMs, |
| 64 | CoordValue::TimestampMs(v), |
| 65 | DomainBound::TimestampMs(lo), |
| 66 | DomainBound::TimestampMs(hi), |
| 67 | ) => map_int(array, dim, *v, *lo, *hi, max), |
| 68 | ( |
| 69 | DimType::Float64, |
| 70 | CoordValue::Float64(v), |
| 71 | DomainBound::Float64(lo), |
| 72 | DomainBound::Float64(hi), |
| 73 | ) => map_float(array, dim, *v, *lo, *hi, max), |
| 74 | ( |
| 75 | DimType::String, |
| 76 | CoordValue::String(v), |
| 77 | DomainBound::String(_), |
| 78 | DomainBound::String(_), |
| 79 | ) => Ok(map_string(v, max)), |
| 80 | _ => Err(ArrayError::CoordOutOfDomain { |
| 81 | array: array.to_string(), |
| 82 | dim: dim.name.clone(), |
| 83 | detail: "coord variant does not match dim dtype".to_string(), |
| 84 | }), |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | fn map_int(array: &str, dim: &DimSpec, v: i64, lo: i64, hi: i64, max: u64) -> ArrayResult<u64> { |
| 89 | if v < lo || v > hi { |
no test coverage detected