return res;
}
-/* A dummy WordEntryPos array to use when haspos is false */
-static WordEntryPosVector POSNULL = {
- 1, /* Number of elements that follow */
- {0}
-};
-
static float
calc_rank_and(const float *w, TSVector t, TSQuery q)
{
WordEntryPosVector **pos;
+ WordEntryPosVector1 posnull;
+ WordEntryPosVector *POSNULL;
int i,
k,
l,
return calc_rank_or(w, t, q);
}
pos = (WordEntryPosVector **) palloc0(sizeof(WordEntryPosVector *) * q->size);
- WEP_SETPOS(POSNULL.pos[0], MAXENTRYPOS - 1);
+
+ /* A dummy WordEntryPos array to use when haspos is false */
+ posnull.npos = 1;
+ posnull.pos[0] = 0;
+ WEP_SETPOS(posnull.pos[0], MAXENTRYPOS - 1);
+ POSNULL = (WordEntryPosVector *) &posnull;
for (i = 0; i < size; i++)
{
if (entry->haspos)
pos[i] = _POSVECPTR(t, entry);
else
- pos[i] = &POSNULL;
+ pos[i] = POSNULL;
dimt = pos[i]->npos;
post = pos[i]->pos;
for (p = 0; p < lenct; p++)
{
dist = Abs((int) WEP_GETPOS(post[l]) - (int) WEP_GETPOS(ct[p]));
- if (dist || (dist == 0 && (pos[i] == &POSNULL || pos[k] == &POSNULL)))
+ if (dist || (dist == 0 && (pos[i] == POSNULL || pos[k] == POSNULL)))
{
float curw;
{
WordEntry *entry,
*firstentry;
+ WordEntryPosVector1 posnull;
WordEntryPos *post;
int32 dimt,
j,
QueryOperand **item;
int size = q->size;
+ /* A dummy WordEntryPos array to use when haspos is false */
+ posnull.npos = 1;
+ posnull.pos[0] = 0;
+
item = SortAndUniqItems(q, &size);
for (i = 0; i < size; i++)
}
else
{
- dimt = POSNULL.npos;
- post = POSNULL.pos;
+ dimt = posnull.npos;
+ post = posnull.pos;
}
resj = 0.0;