MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / value_to_comparable

Function value_to_comparable

graphlite/src/functions/special_functions.rs:243–260  ·  view source on GitHub ↗

Convert a Value to a comparable representation for equality/uniqueness checks This handles the complexity of comparing different Value types consistently

(value: &Value)

Source from the content-addressed store, hash-verified

241/// Convert a Value to a comparable representation for equality/uniqueness checks
242/// This handles the complexity of comparing different Value types consistently
243fn value_to_comparable(value: &Value) -> FunctionResult<ComparableValue> {
244 match value {
245 Value::Boolean(b) => Ok(ComparableValue::Boolean(*b)),
246 Value::Number(n) => Ok(ComparableValue::Number(n.to_bits())), // Use bit representation for exact floating point comparison
247 Value::String(s) => Ok(ComparableValue::String(s.clone())),
248 Value::DateTime(dt) => Ok(ComparableValue::DateTime(dt.timestamp())),
249 Value::DateTimeWithFixedOffset(dt) => Ok(ComparableValue::DateTime(dt.timestamp())),
250 Value::DateTimeWithNamedTz(_, dt) => Ok(ComparableValue::DateTime(dt.timestamp())),
251 Value::TimeWindow(tw) => Ok(ComparableValue::String(format!("{:?}", tw))), // Use debug format for comparison
252 // Add more value types as needed
253 _ => {
254 warn!("Unsupported value type for comparison: {:?}", value);
255 Err(FunctionError::InvalidArgumentType {
256 message: format!("Value type {:?} is not supported for comparison", value),
257 })
258 }
259 }
260}
261
262/// Comparable representation of values for equality and uniqueness checks
263/// This ensures consistent comparison across different value types

Callers 2

executeMethod · 0.85

Calls 1

cloneMethod · 0.80

Tested by

no test coverage detected