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

Function sd_proj

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

* @param sdata The SparseData to be projected on * @param idx The index to be projected * @return The element of a SparseData at location idx. */

Source from the content-addressed store, hash-verified

1569 * @return The element of a SparseData at location idx.
1570 */
1571double sd_proj(SparseData sdata, int idx) {
1572 char * ix = sdata->index->data;
1573 double * vals = (double *)sdata->vals->data;
1574 int read, i;
1575
1576 /* error checking */
1577 if (0 >= idx || idx > sdata->total_value_count)
1578 ereport(ERROR,
1579 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1580 errmsg("Index out of bounds.")));
1581
1582 /* find desired block; as is normal in SQL, we start counting from one */
1583 read = compword_to_int8(ix);
1584 i = 0;
1585 while (read < idx) {
1586 ix += int8compstoragesize(ix);
1587 read += compword_to_int8(ix);
1588 i++;
1589 }
1590 return vals[i];
1591}
1592
1593/**
1594 * @param sdata The SparseData from which to extract a subarray

Callers 1

svec_projFunction · 0.85

Calls 1

compword_to_int8Function · 0.85

Tested by

no test coverage detected