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

Function makeSparseDataFromDouble

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

* @param constant The value of an RLE block * @param dimension The size of an RLE block * @return A SparseData with a single RLE block of size dimension having value constant */

Source from the content-addressed store, hash-verified

1243 * @return A SparseData with a single RLE block of size dimension having value constant
1244 */
1245SparseData makeSparseDataFromDouble(double constant,int64 dimension) {
1246 char *bytestore=(char *)palloc(sizeof(char)*9);
1247 SparseData sdata = float8arr_to_sdata(&constant,1);
1248 int8_to_compword(dimension,bytestore); /* create compressed version of
1249 int8 value */
1250
1251 int newlen = int8compstoragesize(bytestore);
1252 sdata->index->len = 0; // write over existing value
1253 appendBinaryStringInfo(sdata->index, bytestore, newlen);
1254
1255 sdata->total_value_count = dimension;
1256
1257 return sdata;
1258}
1259
1260/**
1261 * Frees up the memory occupied by sdata

Callers 1

svec_countFunction · 0.85

Calls 2

float8arr_to_sdataFunction · 0.85
int8_to_compwordFunction · 0.85

Tested by

no test coverage detected