Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add isNull condition for payload filtering #1617

Merged
merged 17 commits into from
Apr 1, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
reuse same variable in condition checker tests
  • Loading branch information
ibrahim-akrab committed Mar 29, 2023
commit 6c4baae2624d067d4522dc110790c18bd36511d8
33 changes: 15 additions & 18 deletions lib/segment/src/payload_storage/query_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,56 +260,54 @@ mod tests {
Arc::new(AtomicRefCell::new(id_tracker)),
);

let is_empty_condition_1 = Filter::new_must(Condition::IsEmpty(IsEmptyCondition {
let is_empty_condition = Filter::new_must(Condition::IsEmpty(IsEmptyCondition {
is_empty: PayloadField {
key: "price".to_string(),
},
}));
assert!(!payload_checker.check(0, &is_empty_condition));

let is_empty_condition_2 = Filter::new_must(Condition::IsEmpty(IsEmptyCondition {
let is_empty_condition = Filter::new_must(Condition::IsEmpty(IsEmptyCondition {
is_empty: PayloadField {
key: "something_new".to_string(),
},
}));
assert!(payload_checker.check(0, &is_empty_condition));

let is_empty_condition_3 = Filter::new_must(Condition::IsEmpty(IsEmptyCondition {
let is_empty_condition = Filter::new_must(Condition::IsEmpty(IsEmptyCondition {
is_empty: PayloadField {
key: "parts".to_string(),
},
}));
assert!(payload_checker.check(0, &is_empty_condition));

assert!(!payload_checker.check(0, &is_empty_condition_1));
assert!(payload_checker.check(0, &is_empty_condition_2));
assert!(payload_checker.check(0, &is_empty_condition_3));

let is_null_condition_1 = Filter::new_must(Condition::IsNull(IsNullCondition {
let is_null_condition = Filter::new_must(Condition::IsNull(IsNullCondition {
is_null: PayloadField {
key: "amount".to_string(),
},
}));
assert!(!payload_checker.check(0, &is_null_condition));

let is_null_condition_2 = Filter::new_must(Condition::IsNull(IsNullCondition {
let is_null_condition = Filter::new_must(Condition::IsNull(IsNullCondition {
is_null: PayloadField {
key: "parts".to_string(),
},
}));
assert!(!payload_checker.check(0, &is_null_condition));

let is_null_condition_3 = Filter::new_must(Condition::IsNull(IsNullCondition {
let is_null_condition = Filter::new_must(Condition::IsNull(IsNullCondition {
is_null: PayloadField {
key: "something_else".to_string(),
},
}));
assert!(!payload_checker.check(0, &is_null_condition));

let is_null_condition_4 = Filter::new_must(Condition::IsNull(IsNullCondition {
let is_null_condition = Filter::new_must(Condition::IsNull(IsNullCondition {
is_null: PayloadField {
key: "packaging".to_string(),
},
}));

assert!(!payload_checker.check(0, &is_null_condition_1));
assert!(!payload_checker.check(0, &is_null_condition_2));
assert!(!payload_checker.check(0, &is_null_condition_3));
assert!(payload_checker.check(0, &is_null_condition_4));
assert!(payload_checker.check(0, &is_null_condition));

let match_red = Condition::Field(FieldCondition::new_match(
"color".to_string(),
Expand All @@ -334,6 +332,7 @@ mod tests {
lte: None,
},
)));
assert!(!payload_checker.check(0, &many_value_count_condition));

let few_value_count_condition =
Filter::new_must(Condition::Field(FieldCondition::new_values_count(
Expand All @@ -345,8 +344,6 @@ mod tests {
lte: None,
},
)));

assert!(!payload_checker.check(0, &many_value_count_condition));
assert!(payload_checker.check(0, &few_value_count_condition));

let in_berlin = Condition::Field(FieldCondition::new_geo_bounding_box(
Expand Down