@@ -86,12 +86,11 @@ tiledb_query_condition_init <- function(attr, value, dtype, op, qc = tiledb_quer
8686
8787# ' Combine two 'tiledb_query_condition' objects
8888# '
89- # ' Combines two query condition object using a relatiional operator. Support for operator
90- # ' 'AND' is generally available, the 'OR' operator is available if TileDB 2.10 or newer is
91- # ' used.
89+ # ' Combines two query condition objects using a relational operator. Support for operator
90+ # ' 'AND' is generally available. The 'OR' operator is available in TileDB 2.10 and later.
9291# ' @param lhs A 'tiledb_query_condition' object on the left-hand side of the relation
9392# ' @param rhs A 'tiledb_query_condition' object on the left-hand side of the relation
94- # ' @param op A character value with then relation, this must be one of 'AND', 'OR' or 'NOT '.
93+ # ' @param op A character value with then relation, this must be one of 'AND' or 'OR '.
9594# ' @return The combined 'tiledb_query_condition' object
9695# ' @export
9796tiledb_query_condition_combine <- function (lhs , rhs , op ) {
@@ -100,13 +99,29 @@ tiledb_query_condition_combine <- function(lhs, rhs, op) {
10099 " Argument 'rhs' must be a query condition object" = is(rhs , " tiledb_query_condition" ),
101100 " Argument 'op' must be a character" = is.character(op )
102101 )
103- op <- match.arg(op , c(" AND" , " OR" , " NOT " ))
102+ op <- match.arg(op , c(" AND" , " OR" ))
104103 qc <- tiledb_query_condition()
105104 qc @ ptr <- libtiledb_query_condition_combine(lhs @ ptr , rhs @ ptr , op )
106105 qc @ init <- TRUE
107106 invisible (qc )
108107}
109108
109+ # ' Negate a 'tiledb_query_condition' object
110+ # '
111+ # ' Takes a query condition object and negates it, similar to the '!' operator.
112+ # ' @param qc A 'tiledb_query_condition' object to negate
113+ # ' @return The negated 'tiledb_query_condition' object
114+ # ' @export
115+ tiledb_query_condition_negate <- function (qc ) {
116+ stopifnot(
117+ " Argument 'qc' must be a query condition object" = is(qc , " tiledb_query_condition" )
118+ )
119+ res <- tiledb_query_condition()
120+ res @ ptr <- libtiledb_query_condition_negate(qc @ ptr )
121+ res @ init <- TRUE
122+ invisible (res )
123+ }
124+
110125# ' Create a 'tiledb_query_condition' object from an expression
111126# '
112127# ' The grammar for query conditions is at present constraint to eight operators (\code{">"},
@@ -150,7 +165,8 @@ parse_query_condition <- function(expr, ta = NULL, debug = FALSE, strict = TRUE,
150165 if (.hasArray && length(ta @ sil ) == 0 ) ta @ sil <- .fill_schema_info_list(ta @ uri )
151166 `%!in%` <- Negate(`%in%` )
152167 .isComparisonOperator <- function (x ) tolower(as.character(x )) %in% c(" >" , " >=" , " <" , " <=" , " ==" , " !=" , " %in%" , " %nin%" )
153- .isBooleanOperator <- function (x ) as.character(x ) %in% c(" &&" , " ||" , " !" , " &" , " |" )
168+ .isBooleanOperator <- function (x ) as.character(x ) %in% c(" &&" , " ||" , " &" , " |" )
169+ .isNegationOperator <- function (x ) as.character(x ) == " !"
154170 .isAscii <- function (x ) grepl(" ^[[:alnum:]_]+$" , x )
155171 .isInteger <- function (x ) grepl(" ^[[:digit:]]+$" , as.character(x ))
156172 .isDouble <- function (x ) grepl(" ^[[:digit:]\\ .]+$" , as.character(x )) && length(grepRaw(" ." , as.character(x ), fixed = TRUE , all = TRUE )) == 1
@@ -224,6 +240,12 @@ parse_query_condition <- function(expr, ta = NULL, debug = FALSE, strict = TRUE,
224240 .makeExpr(x [[3 ]]),
225241 .mapBoolToCharacter(as.character(x [1 ]))
226242 )
243+ } else if (.isNegationOperator(x [1 ])) {
244+ if (debug ) {
245+ cat(" ![" , as.character(x [2 ]), " ]" )
246+ }
247+ .makeExpr(x [[2 ]], debug = debug )
248+ tiledb_query_condition_negate(.makeExpr(x [[2 ]]))
227249 } else if (.isInOperator(x [1 ])) {
228250 if (debug ) {
229251 cat(" in: [" , as.character(x [2 ]), " ]" ,
0 commit comments