| evalPostgresAggregatorInitialization {REmbeddedPostgres} | R Documentation |
An RAggregator is a Postgres data-type whose
functionality is implemented in R. Such an object is initialized
by a user-specified Postgres string which is expected to create
an R object (usually a closure) that can be used to incrementally compute
some statistic by being passed each record within an SQL query one
at a time. This function converts the Postgres initialization string
into an R object which can be used as the aggregator.
evalPostgresAggregatorInitialization(txt)
txt |
the string from Postgres that is to be parse and evaluated |
An object which can be used in the plRaggregate
procedural language within Postgres. This typically
is a list returned from a closure definition.
By default, the first element of the list should be
the function that is called for each record and which updates
the internal state of the closure. It is called with a single argument -
the value of the record.
The second function is typically called with no arguments to retrieve the final result
when all the records have been processed by Postgres and passed
to the update function.
The positions of these functions can be changed depending on
how the aggregator is defined within Postgres. It is much simpler
to user this ordering.
Duncan Temple Lang
http://www.postgresql.org, http://www.omegahat.org/DBMS/Postgres/R
evalPostgresAggregatorInitialization('jsumGenerator()')
evalPostgresAggregatorInitialization('(function() {
minVal <- Inf
update <- function(recordValue) {
minVal <- min(minVal, recordValue)
}
getMinVal <- function() {
minVal
}
return(list(update, getMinVal))
})()')