Normally we don't need these functions. But in case we do, they are flexible in constructing high-order AFL expressions, e.g. AFL raw string or expressions generated in one place and used in other places with or without modification.

Methods


Method e_to_afl()

Convert filter expression(s) to AFL filter; wrapper around scidb::filter_to_afl

Usage

AFLUtils$e_to_afl(e, regex_func = NULL, ignore_case = NULL)

Arguments

e

A list of R expression(s). If more than one expression is provided, they will be joined with logic AND.

regex_func

deprecated option to determine how %like% etc. are implemented

ignore_case

deprecated option to determine how %like% etc. are implemented

Returns

An AFL filter string


Method e()

Create a list of R expressions; wrapper around scidb::filter

The ... ellipsis arg can include arbitrary expressions, where all names are preserved in their literal forms, except for those prefixed with !! (double exclamation marks) which will be evaluated to their actual values in the calling environment.

Besides common comparison operators including ==, >, <, >=, <=, !=, there are a few special operators supported to ease AFL generation:

  • %in% semantically similar to R. a %in% !!c(1,2,3) will be translated to (a == 1 or a == 2 or a == 3)

  • %like% for string regex matching.

Usage

AFLUtils$e(...)

Arguments

...

The ellipsis arg can have multiple items as expressions, but NO named items as in a named list.

Returns

A list of R expressions


Method e_merge()

Merge multiple R expressions into one

Merge an ExprsList into a single Expression so that it can be used as a FilterExpr

Usage

AFLUtils$e_merge(el, mode = "AND")

Arguments

el

A list of scidb::filter expressions

mode

'AND' | 'OR'. Logical relationships when merging the expressions.

Returns

R expression


Method join_fields()

Join multiple fields with sep = ','

Default behavior: paste(..., sep = sep, collapse = sep) where sep = ','

afl(...) will convert vectors to joined strings separated by ,. This function is useful in concatenating multiple vectors in parallel, e.g. joining a new field vector and expression vector for the apply operator.

Usage

AFLUtils$join_fields(..., sep = ",")

Arguments

...

Multiple string vectors

sep

A single character string, defaullt ",", as field separator.


Method validate_filter_expr()

Validate a filter expression

Current only report errors on:

  1. Name symbols that are not known schema fields, defined by param all_fields

  2. Non-atomic R 'values' in the expression

Usage

AFLUtils$validate_filter_expr(filter_expr, all_fields)

Arguments

filter_expr

AFL captured as a single R expression

all_fields

A list of strings as the scope of valid fields

Returns

A list object with named elements: success:bool, absent_fields: c(”), error_msgs: c(”)