Skip to content

Commit

Permalink
Switch f32_array to square brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
deven96 committed Sep 26, 2024
1 parent e9cdde2 commit 883ad6a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions ahnlich/dsl/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ fn parse_f32_array(pair: Pair<Rule>) -> 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
Expand Down
2 changes: 1 addition & 1 deletion ahnlich/dsl/src/syntax/syntax.pest
Original file line number Diff line number Diff line change
Expand Up @@ -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)* }
Expand Down
16 changes: 8 additions & 8 deletions ahnlich/dsl/src/tests/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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")
};
Expand Down

0 comments on commit 883ad6a

Please sign in to comment.