MCPcopy Create free account
hub / github.com/apache/madlib / lapply

Function lapply

methods/svec/src/pg_gp/SparseData.c:1754–1768  ·  view source on GitHub ↗

* This function applies an input function on all elements of a sparse data. * The function is modelled after the corresponding function in R. * * @param func The name of the function to apply * @param sdata The input sparse data to be modified * @return A SparseData with the same dimension as sdata but with each element sdata[i] replaced by func(sdata[i]) */

Source from the content-addressed store, hash-verified

1752 * @return A SparseData with the same dimension as sdata but with each element sdata[i] replaced by func(sdata[i])
1753 */
1754SparseData lapply(text * func, SparseData sdata) {
1755 Oid argtypes[1] = { FLOAT8OID };
1756 List * funcname = textToQualifiedNameList(func);
1757 SparseData result = makeSparseDataCopy(sdata);
1758 Oid foid = LookupFuncName(funcname, 1, argtypes, false);
1759
1760 lapply_error_checking(foid, funcname);
1761
1762 for (int i=0; i<sdata->unique_value_count; i++)
1763 valref(float8,result,i) =
1764 DatumGetFloat8(
1765 OidFunctionCall1(foid,
1766 Float8GetDatum(valref(float8,sdata,i))));
1767 return result;
1768}
1769
1770/* This function checks for error conditions in lapply() function calls.
1771 */

Callers 1

svec_lapplyFunction · 0.85

Calls 2

makeSparseDataCopyFunction · 0.85
lapply_error_checkingFunction · 0.85

Tested by

no test coverage detected