diff --git a/ahnlich/dsl/src/db.rs b/ahnlich/dsl/src/db.rs index 0578f0d3..2bea33c9 100644 --- a/ahnlich/dsl/src/db.rs +++ b/ahnlich/dsl/src/db.rs @@ -40,10 +40,10 @@ fn parse_f32_array(pair: Pair) -> StoreKey { // DROPPREDINDEX IF EXISTS (key1, key2) in store_name // CREATENONLINEARALGORITHMINDEX (kdtree) in store_name // DROPNONLINEARALGORITHMINDEX IF EXISTS (kdtree) in store_name -// GETKEY ((1.0, 2.0), (3.0, 4.0)) IN my_store -// DELKEY ((1.2, 3.0), (5.6, 7.8)) IN my_store +// GETKEY ([1.0, 2.0], [3.0, 4.0]) IN my_store +// DELKEY ([1.2, 3.0], [5.6, 7.8]) IN my_store // GETPRED ((author = dickens) OR (country != Nigeria)) IN my_store -// GETSIMN 4 WITH (0.65, 2.78) USING cosinesimilarity IN my_store WHERE (author = dickens) +// GETSIMN 4 WITH [0.65, 2.78] USING cosinesimilarity IN my_store WHERE (author = dickens) // CREATESTORE IF NOT EXISTS my_store DIMENSION 21 PREDICATES (author, country) NONLINEARALGORITHMINDEX (kdtree) // // #TODO diff --git a/ahnlich/dsl/src/syntax/syntax.pest b/ahnlich/dsl/src/syntax/syntax.pest index ffe0cd16..1e039618 100644 --- a/ahnlich/dsl/src/syntax/syntax.pest +++ b/ahnlich/dsl/src/syntax/syntax.pest @@ -59,7 +59,7 @@ index_names = { index_name ~ (whitespace* ~ "," ~ whitespace* ~ index_name)* } non_zero = { '1'..'9' ~ ASCII_DIGIT* } f32 = { ASCII_DIGIT+ ~ ("." ~ ASCII_DIGIT+)? } // Array of floating-point numbers -f32_array = { "(" ~ f32 ~ (whitespace* ~ "," ~ whitespace* ~ f32)* ~ ")"} +f32_array = { "[" ~ f32 ~ (whitespace* ~ "," ~ whitespace* ~ f32)* ~ "]"} // List of f32 arrays (comma-separated) f32_arrays = { f32_array ~ (whitespace* ~ "," ~ whitespace* ~ f32_array)* } diff --git a/ahnlich/dsl/src/tests/db.rs b/ahnlich/dsl/src/tests/db.rs index a29f6a87..b27f9b26 100644 --- a/ahnlich/dsl/src/tests/db.rs +++ b/ahnlich/dsl/src/tests/db.rs @@ -210,12 +210,12 @@ fn test_create_non_linear_algorithm_parse() { #[test] fn test_get_sim_n_parse() { // passing in a zero value to ensure it doesn't work - let input = r#"GETSIMN 0 with (0.1, 0.2) using kdtree in store1 where ( author = hi )"#; + let input = r#"GETSIMN 0 with [0.1, 0.2] using kdtree in store1 where ( author = hi )"#; let DslError::UnexpectedSpan((start, end)) = parse_db_query(input).unwrap_err() else { panic!("Unexpected error pattern found") }; assert_eq!((start, end), (0, 70)); - let input = r#"GETSIMN 5 with (34.1, 72.2) using cosinesimilarity in random"#; + let input = r#"GETSIMN 5 with [34.1, 72.2] using cosinesimilarity in random"#; assert_eq!( parse_db_query(input).expect("Could not parse query input"), vec![DBQuery::GetSimN { @@ -226,7 +226,7 @@ fn test_get_sim_n_parse() { condition: None }] ); - let input = r#"GETSIMN 8 with (3.7, 9.6) using euclideandistance in other where ((year != 2012) AND (month not in (december, october)))"#; + let input = r#"GETSIMN 8 with [3.7, 9.6] using euclideandistance in other where ((year != 2012) AND (month not in (december, october)))"#; assert_eq!( parse_db_query(input).expect("Could not parse query input"), vec![DBQuery::GetSimN { @@ -280,12 +280,12 @@ fn test_drop_non_linear_algorithm_parse() { #[test] fn test_get_key_parse() { - let input = r#"getkey ((a, b, c), (3.0, 4.0)) in 1234"#; + let input = r#"getkey ([a, b, c], [3.0, 4.0]) in 1234"#; let DslError::UnexpectedSpan((start, end)) = parse_db_query(input).unwrap_err() else { panic!("Unexpected error pattern found") }; assert_eq!((start, end), (0, 38)); - let input = r#"getkey ((1, 2, 3), (3.0, 4.0)) in 1234"#; + let input = r#"getkey ([1, 2, 3], [3.0, 4.0]) in 1234"#; assert_eq!( parse_db_query(input).expect("Could not parse query input"), vec![DBQuery::GetKey { @@ -300,12 +300,12 @@ fn test_get_key_parse() { #[test] fn test_del_key_parse() { - let input = r#"DELKEY ((a, b, c), (3.0, 4.0)) in 1234"#; + let input = r#"DELKEY ([a, b, c], [3.0, 4.0]) in 1234"#; let DslError::UnexpectedSpan((start, end)) = parse_db_query(input).unwrap_err() else { panic!("Unexpected error pattern found") }; assert_eq!((start, end), (0, 38)); - let input = r#"DELKEY ((1, 2, 3), (3.0, 4.0)) in 1234"#; + let input = r#"DELKEY ([1, 2, 3], [3.0, 4.0]) in 1234"#; assert_eq!( parse_db_query(input).expect("Could not parse query input"), vec![DBQuery::DelKey { @@ -320,7 +320,7 @@ fn test_del_key_parse() { #[test] fn test_get_pred_parse() { - let input = r#"GETPRED ((a, b, c), (3.0, 4.0)) in 1234"#; + let input = r#"GETPRED ([a, b, c], [3.0, 4.0]) in 1234"#; let DslError::UnexpectedSpan((start, end)) = parse_db_query(input).unwrap_err() else { panic!("Unexpected error pattern found") };