-
Notifications
You must be signed in to change notification settings - Fork 186
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
Query Condition NOT support #3844
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
00722f2
feature
abigalekim 9550ad2
restore to dev
abigalekim 4ec05f4
code complete
abigalekim ae9500d
progress
abigalekim b579479
wip
abigalekim 48c32b0
more stuff
abigalekim 8d76804
Update tests for more coverage
davisp 4902c00
Add top level `tiledb_query_condition_negate` API
davisp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2629,7 +2629,9 @@ int32_t tiledb_query_condition_combine( | |
// Sanity check | ||
if (sanity_check(ctx) == TILEDB_ERR || | ||
sanity_check(ctx, left_cond) == TILEDB_ERR || | ||
sanity_check(ctx, right_cond) == TILEDB_ERR) | ||
(combination_op != TILEDB_NOT && | ||
sanity_check(ctx, right_cond) == TILEDB_ERR) || | ||
(combination_op == TILEDB_NOT && right_cond != nullptr)) | ||
return TILEDB_ERR; | ||
|
||
// Create the combined query condition struct | ||
|
@@ -2655,21 +2657,42 @@ int32_t tiledb_query_condition_combine( | |
return TILEDB_OOM; | ||
} | ||
|
||
if (SAVE_ERROR_CATCH( | ||
ctx, | ||
left_cond->query_condition_->combine( | ||
*right_cond->query_condition_, | ||
static_cast<tiledb::sm::QueryConditionCombinationOp>( | ||
combination_op), | ||
(*combined_cond)->query_condition_))) { | ||
delete (*combined_cond)->query_condition_; | ||
delete *combined_cond; | ||
return TILEDB_ERR; | ||
if (combination_op == TILEDB_NOT) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be useful here to have a comment that we are partially evaluating the tree and applying NOT via DeMorgan's theorem. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will do. |
||
if (SAVE_ERROR_CATCH( | ||
ctx, | ||
left_cond->query_condition_->negate( | ||
static_cast<tiledb::sm::QueryConditionCombinationOp>( | ||
combination_op), | ||
(*combined_cond)->query_condition_))) { | ||
delete (*combined_cond)->query_condition_; | ||
delete *combined_cond; | ||
return TILEDB_ERR; | ||
} | ||
} else { | ||
if (SAVE_ERROR_CATCH( | ||
ctx, | ||
left_cond->query_condition_->combine( | ||
*right_cond->query_condition_, | ||
static_cast<tiledb::sm::QueryConditionCombinationOp>( | ||
combination_op), | ||
(*combined_cond)->query_condition_))) { | ||
delete (*combined_cond)->query_condition_; | ||
delete *combined_cond; | ||
return TILEDB_ERR; | ||
} | ||
} | ||
|
||
return TILEDB_OK; | ||
} | ||
|
||
int32_t tiledb_query_condition_negate( | ||
tiledb_ctx_t* const ctx, | ||
const tiledb_query_condition_t* const cond, | ||
tiledb_query_condition_t** const negated_cond) { | ||
return api::tiledb_query_condition_combine( | ||
ctx, cond, nullptr, TILEDB_NOT, negated_cond); | ||
} | ||
|
||
/* ****************************** */ | ||
/* ARRAY */ | ||
/* ****************************** */ | ||
|
@@ -6848,6 +6871,14 @@ int32_t tiledb_query_condition_combine( | |
ctx, left_cond, right_cond, combination_op, combined_cond); | ||
} | ||
|
||
int32_t tiledb_query_condition_negate( | ||
tiledb_ctx_t* const ctx, | ||
const tiledb_query_condition_t* const cond, | ||
tiledb_query_condition_t** const negated_cond) noexcept { | ||
return api_entry<tiledb::api::tiledb_query_condition_negate>( | ||
ctx, cond, negated_cond); | ||
} | ||
|
||
/* ****************************** */ | ||
/* UPDATE CONDITION */ | ||
/* ****************************** */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I like using one half of a binary operator to be a unary operator. OTOH, not sure if it is worth changing if all we are going to have is AND, OR, NOT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had this same exact thought. My first reaction was to do away with the existing implementation and then provide a
tiledb_query_condition_negate
function. I polled the language binding crowd and the only responses I got were in favor of keeping things as is, reusingtiledb_query_condition_combine
.If I had it to do all over again, I would change the combine API from:
to:
The second definition removes the baked in 2-arity semantics of the
combination_op
so thatNOT
and>2
-arity AND/OR operators would also be naturally expressed. I briefly considered combining this approach with #3814 but @eric-hughes-tiledb had some other concerns around the general approach of #3814 so I'm leaving it be for now.