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

Method execute

graphlite/src/functions/special_functions.rs:55–88  ·  view source on GitHub ↗
(&self, context: &FunctionContext)

Source from the content-addressed store, hash-verified

53 }
54
55 fn execute(&self, context: &FunctionContext) -> FunctionResult<Value> {
56 debug!(
57 "Executing ALL_DIFFERENT function with {} arguments",
58 context.arguments.len()
59 );
60
61 // Validate minimum argument count
62 if context.arguments.is_empty() {
63 return Err(FunctionError::InvalidArgumentCount {
64 expected: 1,
65 actual: 0,
66 });
67 }
68
69 // Use HashSet to track seen values for O(n) performance
70 let mut seen_values = HashSet::new();
71
72 for (i, arg) in context.arguments.iter().enumerate() {
73 debug!("Checking argument {}: {:?}", i, arg);
74
75 // Convert Value to a comparable representation
76 let comparable_value = value_to_comparable(arg)?;
77
78 if seen_values.contains(&comparable_value) {
79 debug!("Found duplicate value: {:?}", comparable_value);
80 return Ok(Value::Boolean(false));
81 }
82
83 seen_values.insert(comparable_value);
84 }
85
86 debug!("All {} values are different", context.arguments.len());
87 Ok(Value::Boolean(true))
88 }
89
90 fn graph_context_required(&self) -> bool {
91 false // Pure function that doesn't need graph context

Calls 7

value_to_comparableFunction · 0.85
containsMethod · 0.80
is_emptyMethod · 0.45
iterMethod · 0.45
insertMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected