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

Function extract_u64

nodedb-sql/src/planner/select/entry_ann.rs:229–245  ·  view source on GitHub ↗

Extract a non-negative integer from a function argument expression.

(expr: &ast::Expr, option: &str)

Source from the content-addressed store, hash-verified

227
228/// Extract a non-negative integer from a function argument expression.
229fn extract_u64(expr: &ast::Expr, option: &str) -> Result<u64> {
230 match expr {
231 ast::Expr::Value(v) => match &v.value {
232 ast::Value::Number(n, _) => n.parse::<u64>().map_err(|_| SqlError::Unsupported {
233 detail: format!("ANN option '{option}' expects a non-negative integer, got: {n}"),
234 }),
235 _ => Err(SqlError::Unsupported {
236 detail: format!(
237 "ANN option '{option}' expects a non-negative integer, got: {expr}"
238 ),
239 }),
240 },
241 _ => Err(SqlError::Unsupported {
242 detail: format!("ANN option '{option}' expects a non-negative integer, got: {expr}"),
243 }),
244 }
245}
246
247/// Extract a float from a function argument expression.
248fn extract_f64(expr: &ast::Expr, option: &str) -> Result<f64> {

Callers 1

parse_ann_optionsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected