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

Function concat_replicate

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

* @param rep The SparseData to be replicated * @param multiplier The number of times to replicate rep * @return The input rep SparseData replicated multiplier times. */

Source from the content-addressed store, hash-verified

1713 * @return The input rep SparseData replicated multiplier times.
1714 */
1715SparseData concat_replicate(SparseData rep, int multiplier) {
1716 if (rep == NULL) return NULL;
1717
1718 SparseData sdata = makeEmptySparseData();
1719 char *vals,*index;
1720 int l_val_len = rep->vals->len;
1721 int l_ind_len = rep->index->len;
1722 int val_len = l_val_len*multiplier;
1723 int ind_len = l_ind_len*multiplier;
1724
1725 vals = (char *)palloc(sizeof(char)*val_len + 1);
1726 index = (char *)palloc(sizeof(char)*ind_len + 1);
1727
1728 for (int i=0;i<multiplier;i++) {
1729 memcpy(vals+i*l_val_len,rep->vals->data,l_val_len);
1730 memcpy(index+i*l_ind_len,rep->index->data,l_ind_len);
1731 }
1732 vals[val_len] = '\0';
1733 index[ind_len] = '\0';
1734
1735 sdata->vals = makeStringInfoFromData(vals,val_len);
1736 sdata->index = makeStringInfoFromData(index,ind_len);
1737 sdata->type_of_data = rep->type_of_data;
1738 sdata->unique_value_count = multiplier * rep->unique_value_count;
1739 sdata->total_value_count = multiplier * rep->total_value_count;
1740
1741 return sdata;
1742}
1743
1744static bool lapply_error_checking(Oid foid, List * funcname);
1745

Callers 1

svec_concat_replicateFunction · 0.85

Calls 2

makeEmptySparseDataFunction · 0.85
makeStringInfoFromDataFunction · 0.85

Tested by

no test coverage detected