The array over which we're aggregating
Function to turn a buffer into the actual output
The initial value for each element in the aggregation buffer
Function to merge two buffers' elements
Function to update an element of the buffer with a new input element
To create bound lambda functions, we bind each of the child higher order functions, extract their bound lambda functions, and then copy.
To create bound lambda functions, we bind each of the child higher order functions, extract their bound lambda functions, and then copy.
An expression that allows users to aggregate over all array elements at a specific index in an array column. For example, this expression can be used to compute per-sample summary statistics from a genotypes column.
The user must provide the following arguments: - The array for aggregation - The initialValue for each element in the per-index buffer - An update function to update the buffer with a new element - A merge function to combine two buffers
The user may optionally provide an evaluate function. If it's not provided, the identity function is used.
Example usage to calculate average depth across all sites for a sample: aggregate_by_index( genotypes, named_struct('sum', 0l, 'count', 0l), (buf, genotype) -> named_struct('sum', buf.sum + genotype.depth, 'count', buf.count + 1), (buf1, buf2) -> named_struct('sum', buf1.sum + buf2.sum, 'count', buf1.count + buf2.count), buf -> buf.sum / buf.count)