SolrPromise-class {rsolr} | R 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 indexi
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
: Thex
argument must always refer to a simple field, and thetable
argument should be either a field, potentially predicated viatable[i]
(where the indexi
is a promise), or a “short” vector.grepl(pattern, x, fixed = FALSE)
: Applies whenx
is a promise. Besidespattern
, only thefixed
argument is supported from the base function.grep(pattern, x, value = FALSE, fixed = FALSE, invert = FALSE)
: One must always setvalue=TRUE
. Beyond that, onlyfixed
andinvert
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)
: Thelow
andhigh
parameters must beFALSE
. If there any NAs, thenna.rm
must beTRUE
. Does not work when the context is grouped.
Author(s)
Michael Lawrence
See Also
SolrFrame
, which yields promises when it is
defer
red.