Skip to content

Commit 9a35dd2

Browse files
author
Alena Rybakina
committed
Add processing cases with selectivities are equal as -1.
Add assert check on NaN values.
1 parent 10745e3 commit 9a35dd2

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

hash.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ get_fss_for_object(List *relsigns, List *clauselist,
260260
if (nfeatures != NULL)
261261
{
262262
(*features)[inverse_idx[i]] = log(*s);
263+
Assert(!isnan(log(*s)));
263264
if ((*features)[inverse_idx[i]] < log_selectivity_lower_bound)
264265
(*features)[inverse_idx[i]] = log_selectivity_lower_bound;
265266
}
@@ -693,7 +694,7 @@ get_eclasses(List *clauselist, int *nargs, int **args_hash, int **eclass_hash)
693694
e_hashes = palloc((*nargs) * sizeof(*e_hashes));
694695

695696
MemoryContextSwitchTo(old_ctx_m);
696-
697+
697698
for (i = 0; i < *nargs; ++i)
698699
lsts[i] = NIL;
699700

machine_learning.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ fs_distance(double *a, double *b, int len)
6969
int i;
7070

7171
for (i = 0; i < len; ++i)
72+
{
73+
Assert(!isnan(a[i]));
7274
res += (a[i] - b[i]) * (a[i] - b[i]);
75+
}
7376
if (len != 0)
7477
res = sqrt(res / len);
7578
return res;

postprocessing.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ restore_selectivities(List *clauselist, List *relidslist, JoinType join_type,
216216
else
217217
cur_sel = &rinfo->outer_selec;
218218

219+
if (*cur_sel < 0)
220+
*cur_sel = 0;
221+
222+
Assert(cur_sel > 0);
223+
219224
lst = lappend(lst, cur_sel);
220225
i++;
221226
}

storage.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,10 @@ form_matrix(double *matrix, int nrows, int ncols)
145145
elems = palloc(sizeof(*elems) * nrows * ncols);
146146
for (i = 0; i < nrows; ++i)
147147
for (j = 0; j < ncols; ++j)
148+
{
148149
elems[i * ncols + j] = Float8GetDatum(matrix[i * ncols + j]);
150+
Assert(!isnan(matrix[i * ncols + j]));
151+
}
149152

150153
array = construct_md_array(elems, NULL, 2, dims, lbs,
151154
FLOAT8OID, 8, FLOAT8PASSBYVAL, 'd');

0 commit comments

Comments
 (0)