SolrPromise-class: SolrPromise

SolrPromise-classR Documentation

SolrPromise

Description

SolrPromise is a vector-like representation of a deferred computation within Solr. It may promise to simply return a field, to perform arithmetic on a combination of fields, to aggregate a field, etc. Methods on SolrPromise allow the R user to manipulate Solr data with the ordinary R API. The typical way to fulfill a promise is to explicitly coerce the promise to a materialized data type, such as an R vector.

Details

In general, SolrPromise acts just like an R vector. It supports all of the basic vector manipulations, including the Logic, Compare, Arith, Math, and Summary group generics, as well as length, lengths, %in%, complete.cases, is.na, [, grepl, grep, round, signif, ifelse, pmax, pmin, cut, mean, quantile, median, weighted.mean, IQR, mad, anyNA. All of these functions are lazy, in that they return another promise.

The promise is really only known to rsolr, as all actual Solr queries are eager. SolrPromise does its best to defer computations, but the computations will be forced if one performs an operation that is not supported by Solr.

These functions are also supported, but they are eager: cbind, rbind, summary, window, head, tail, unique, intersect, setdiff, union, table and ftable. These functions from the Math group generic are eager: cummax, cummin, cumprod, cumsum, log2, and *gamma.

The [<- function will be lazy as long as both x and i are promises. i is assumed to represent a logical subscript. Otherwise, [<- is eager.

SolrPromise also extends the R API with some new operations: nunique (number of unique elements), rescale (rescale to within a min/max), ndoc, windows, heads, tails.

Limitations

This section outlines some limitations of SolrPromise methods, compared to the base vector implementation. The primary limitation is that binary operations generally only work between two promises that derive from the same data source, including all pending manipulations (filters, ordering, etc). Operations between a promise and an ordinary vector usually only work if the vector is of length one (a scalar).

Some specific notes:

  • x[i]: The index i is ideally a promise. The return value will be restricted such that it will only combine with promises with the same restriction.

  • x %in% table: The x argument must always refer to a simple field, and the table argument should be either a field, potentially predicated via table[i] (where the index i is a promise), or a “short” vector.

  • grepl(pattern, x, fixed = FALSE): Applies when x is a promise. Besides pattern, only the fixed argument is supported from the base function.

  • grep(pattern, x, value = FALSE, fixed = FALSE, invert = FALSE): One must always set value=TRUE. Beyond that, only fixed and invert are supported from the base function.

  • cut(x, breaks, include.lowest = FALSE, right = TRUE): Only supports uniform (constant separation) breaks.

  • mad(x, center = median(x, na.rm=na.rm), constant = 1.4826, na.rm = FALSE, low = FALSE, high = FALSE): The low and high parameters must be FALSE. If there any NAs, then na.rm must be TRUE. Does not work when the context is grouped.

Author(s)

Michael Lawrence

See Also

SolrFrame, which yields promises when it is deferred.


rsolr documentation built on May 18, 2022, 9:07 a.m.