summaryrefslogtreecommitdiff
path: root/contrib/tsearch2/rank.c
diff options
context:
space:
mode:
authorTeodor Sigaev <teodor@sigaev.ru>2005-01-25 12:36:25 +0000
committerTeodor Sigaev <teodor@sigaev.ru>2005-01-25 12:36:25 +0000
commitfe30edbab8b01123c503760d2804f6764cd27a51 (patch)
tree81b268f63c5cbc0ba4f6b74df7d46507f6d3b697 /contrib/tsearch2/rank.c
parent4405e74355733075759b9a3f1c5696897c3c55c5 (diff)
downloadpostgresql-fe30edbab8b01123c503760d2804f6764cd27a51.tar.gz
Change
typedef struct {} WordEntryPos; to typedef uint16 WordEntryPos according to http://www.pgsql.ru/db/mw/msg.html?mid=2035188 Require re-fill all tsvector fields and reindex tsvector indexes.
Diffstat (limited to 'contrib/tsearch2/rank.c')
-rw-r--r--contrib/tsearch2/rank.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/contrib/tsearch2/rank.c b/contrib/tsearch2/rank.c
index 3845ddf492..fa1dbc8bb2 100644
--- a/contrib/tsearch2/rank.c
+++ b/contrib/tsearch2/rank.c
@@ -39,7 +39,7 @@ Datum get_covers(PG_FUNCTION_ARGS);
static float weights[] = {0.1, 0.2, 0.4, 1.0};
-#define wpos(wep) ( w[ ((WordEntryPos*)(wep))->weight ] )
+#define wpos(wep) ( w[ WEP_GETWEIGHT(wep) ] )
#define DEF_NORM_METHOD 0
@@ -113,8 +113,8 @@ find_wordentry(tsvector * t, QUERYTYPE * q, ITEM * item)
}
static WordEntryPos POSNULL[] = {
- {0, 0},
- {0, MAXENTRYPOS - 1}
+ 0,
+ 0
};
static float
@@ -136,6 +136,7 @@ calc_rank_and(float *w, tsvector * t, QUERYTYPE * q)
memset(pos, 0, sizeof(uint16 **) * q->size);
*(uint16 *) POSNULL = lengthof(POSNULL) - 1;
+ WEP_SETPOS(POSNULL[1], MAXENTRYPOS-1);
for (i = 0; i < q->size; i++)
{
@@ -165,14 +166,14 @@ calc_rank_and(float *w, tsvector * t, QUERYTYPE * q)
{
for (p = 0; p < lenct; p++)
{
- dist = Abs(post[l].pos - ct[p].pos);
+ dist = Abs((int)WEP_GETPOS(post[l]) - (int)WEP_GETPOS(ct[p]));
if (dist || (dist == 0 && (pos[i] == (uint16 *) POSNULL || pos[k] == (uint16 *) POSNULL)))
{
float curw;
if (!dist)
dist = MAXENTRYPOS;
- curw = sqrt(wpos(&(post[l])) * wpos(&(ct[p])) * word_distance(dist));
+ curw = sqrt(wpos(post[l]) * wpos(ct[p]) * word_distance(dist));
res = (res < 0) ? curw : 1.0 - (1.0 - res) * (1.0 - curw);
}
}
@@ -219,9 +220,9 @@ calc_rank_or(float *w, tsvector * t, QUERYTYPE * q)
for (j = 0; j < dimt; j++)
{
if (res < 0)
- res = wpos(&(post[j]));
+ res = wpos(post[j]);
else
- res = 1.0 - (1.0 - res) * (1.0 - wpos(&(post[j])));
+ res = 1.0 - (1.0 - res) * (1.0 - wpos(post[j]));
}
}
return res;
@@ -497,7 +498,7 @@ get_docrep(tsvector * txt, QUERYTYPE * query, int *doclen)
for (j = 0; j < dimt; j++)
{
doc[cur].item = &(item[i]);
- doc[cur].pos = post[j].pos;
+ doc[cur].pos = WEP_GETPOS(post[j]);
cur++;
}
}
@@ -656,7 +657,7 @@ get_covers(PG_FUNCTION_ARGS)
{
dw[cur].w = STRPTR(txt) + pptr[i].pos;
dw[cur].len = pptr[i].len;
- dw[cur].pos = posdata[j].pos;
+ dw[cur].pos = WEP_GETPOS(posdata[j]);
cur++;
}
len += (pptr[i].len + 1) * (int) POSDATALEN(txt, &(pptr[i]));