aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/tsrank.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2007-11-15 21:14:46 +0000
committerBruce Momjian <bruce@momjian.us>2007-11-15 21:14:46 +0000
commitfdf5a5efb7b28c13085fe7313658de8d7b9914f6 (patch)
treea75cf1422fa1eef4e801cf502b148d8ce1b5dfe7 /src/backend/utils/adt/tsrank.c
parent3adc760fb92eab1a8720337a8bf9b66486609eb3 (diff)
downloadpostgresql-fdf5a5efb7b28c13085fe7313658de8d7b9914f6.tar.gz
postgresql-fdf5a5efb7b28c13085fe7313658de8d7b9914f6.zip
pgindent run for 8.3.
Diffstat (limited to 'src/backend/utils/adt/tsrank.c')
-rw-r--r--src/backend/utils/adt/tsrank.c78
1 files changed, 42 insertions, 36 deletions
diff --git a/src/backend/utils/adt/tsrank.c b/src/backend/utils/adt/tsrank.c
index 297724710ff..a918ee3d3ca 100644
--- a/src/backend/utils/adt/tsrank.c
+++ b/src/backend/utils/adt/tsrank.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/tsrank.c,v 1.9 2007/11/14 23:43:27 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/tsrank.c,v 1.10 2007/11/15 21:14:39 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -58,7 +58,7 @@ cnt_length(TSVector t)
while (ptr < end)
{
- int clen = POSDATALEN(t, ptr);
+ int clen = POSDATALEN(t, ptr);
if (clen == 0)
len += 1;
@@ -72,7 +72,7 @@ cnt_length(TSVector t)
}
static int
-WordECompareQueryItem(char *eval, char *qval, WordEntry *ptr, QueryOperand *item)
+WordECompareQueryItem(char *eval, char *qval, WordEntry * ptr, QueryOperand * item)
{
if (ptr->len == item->length)
return strncmp(
@@ -88,7 +88,7 @@ WordECompareQueryItem(char *eval, char *qval, WordEntry *ptr, QueryOperand *item
* is the TSQuery containing 'item'. Returns NULL if not found.
*/
static WordEntry *
-find_wordentry(TSVector t, TSQuery q, QueryOperand *item)
+find_wordentry(TSVector t, TSQuery q, QueryOperand * item)
{
WordEntry *StopLow = ARRPTR(t);
WordEntry *StopHigh = (WordEntry *) STRPTR(t);
@@ -141,8 +141,8 @@ compareQueryOperand(const void *a, const void *b, void *arg)
static QueryOperand **
SortAndUniqItems(TSQuery q, int *size)
{
- char *operand = GETOPERAND(q);
- QueryItem * item = GETQUERY(q);
+ char *operand = GETOPERAND(q);
+ QueryItem *item = GETQUERY(q);
QueryOperand **res,
**ptr,
**prevptr;
@@ -186,14 +186,14 @@ SortAndUniqItems(TSQuery q, int *size)
/* A dummy WordEntryPos array to use when haspos is false */
static WordEntryPosVector POSNULL = {
- 1, /* Number of elements that follow */
- { 0 }
+ 1, /* Number of elements that follow */
+ {0}
};
static float
calc_rank_and(float *w, TSVector t, TSQuery q)
{
- WordEntryPosVector **pos;
+ WordEntryPosVector **pos;
int i,
k,
l,
@@ -469,7 +469,7 @@ typedef struct
int16 nitem;
uint8 wclass;
int32 pos;
-} DocRepresentation;
+} DocRepresentation;
static int
compareDocR(const void *va, const void *vb)
@@ -482,19 +482,20 @@ compareDocR(const void *va, const void *vb)
return (a->pos > b->pos) ? 1 : -1;
}
-typedef struct
+typedef struct
{
TSQuery query;
bool *operandexist;
-} QueryRepresentation;
+} QueryRepresentation;
-#define QR_GET_OPERAND_EXISTS(q, v) ( (q)->operandexist[ ((QueryItem*)(v)) - GETQUERY((q)->query) ] )
-#define QR_SET_OPERAND_EXISTS(q, v) QR_GET_OPERAND_EXISTS(q,v) = true
+#define QR_GET_OPERAND_EXISTS(q, v) ( (q)->operandexist[ ((QueryItem*)(v)) - GETQUERY((q)->query) ] )
+#define QR_SET_OPERAND_EXISTS(q, v) QR_GET_OPERAND_EXISTS(q,v) = true
static bool
-checkcondition_QueryOperand(void *checkval, QueryOperand *val)
+checkcondition_QueryOperand(void *checkval, QueryOperand * val)
{
- QueryRepresentation *qr = (QueryRepresentation*)checkval;
+ QueryRepresentation *qr = (QueryRepresentation *) checkval;
+
return QR_GET_OPERAND_EXISTS(qr, val);
}
@@ -505,22 +506,24 @@ typedef struct
int q;
DocRepresentation *begin;
DocRepresentation *end;
-} Extention;
+} Extention;
static bool
-Cover(DocRepresentation *doc, int len, QueryRepresentation *qr, Extention *ext)
+Cover(DocRepresentation * doc, int len, QueryRepresentation * qr, Extention * ext)
{
DocRepresentation *ptr;
int lastpos = ext->pos;
int i;
bool found = false;
- /* since this function recurses, it could be driven to stack overflow.
- * (though any decent compiler will optimize away the tail-recursion. */
+ /*
+ * since this function recurses, it could be driven to stack overflow.
+ * (though any decent compiler will optimize away the tail-recursion.
+ */
check_stack_depth();
- memset( qr->operandexist, 0, sizeof(bool)*qr->query->size );
+ memset(qr->operandexist, 0, sizeof(bool) * qr->query->size);
ext->p = 0x7fffffff;
ext->q = 0;
@@ -531,10 +534,10 @@ Cover(DocRepresentation *doc, int len, QueryRepresentation *qr, Extention *ext)
{
for (i = 0; i < ptr->nitem; i++)
{
- if(ptr->item[i]->type == QI_VAL)
+ if (ptr->item[i]->type == QI_VAL)
QR_SET_OPERAND_EXISTS(qr, ptr->item[i]);
}
- if (TS_execute(GETQUERY(qr->query), (void*)qr, false, checkcondition_QueryOperand))
+ if (TS_execute(GETQUERY(qr->query), (void *) qr, false, checkcondition_QueryOperand))
{
if (ptr->pos > ext->q)
{
@@ -551,7 +554,7 @@ Cover(DocRepresentation *doc, int len, QueryRepresentation *qr, Extention *ext)
if (!found)
return false;
- memset( qr->operandexist, 0, sizeof(bool)*qr->query->size );
+ memset(qr->operandexist, 0, sizeof(bool) * qr->query->size);
ptr = doc + lastpos;
@@ -559,9 +562,9 @@ Cover(DocRepresentation *doc, int len, QueryRepresentation *qr, Extention *ext)
while (ptr >= doc + ext->pos)
{
for (i = 0; i < ptr->nitem; i++)
- if(ptr->item[i]->type == QI_VAL)
+ if (ptr->item[i]->type == QI_VAL)
QR_SET_OPERAND_EXISTS(qr, ptr->item[i]);
- if (TS_execute(GETQUERY(qr->query), (void*)qr, true, checkcondition_QueryOperand))
+ if (TS_execute(GETQUERY(qr->query), (void *) qr, true, checkcondition_QueryOperand))
{
if (ptr->pos < ext->p)
{
@@ -588,7 +591,7 @@ Cover(DocRepresentation *doc, int len, QueryRepresentation *qr, Extention *ext)
}
static DocRepresentation *
-get_docrep(TSVector txt, QueryRepresentation *qr, int *doclen)
+get_docrep(TSVector txt, QueryRepresentation * qr, int *doclen)
{
QueryItem *item = GETQUERY(qr->query);
WordEntry *entry;
@@ -610,10 +613,10 @@ get_docrep(TSVector txt, QueryRepresentation *qr, int *doclen)
if (item[i].type != QI_VAL)
continue;
-
+
curoperand = &item[i].operand;
-
- if(QR_GET_OPERAND_EXISTS(qr, &item[i]))
+
+ if (QR_GET_OPERAND_EXISTS(qr, &item[i]))
continue;
entry = find_wordentry(txt, qr->query, curoperand);
@@ -655,10 +658,13 @@ get_docrep(TSVector txt, QueryRepresentation *qr, int *doclen)
(item[k].type == QI_VAL &&
compareQueryOperand(&kptr, &iptr, operand) == 0))
{
- /* if k == i, we've already checked above that it's type == Q_VAL */
+ /*
+ * if k == i, we've already checked above that it's
+ * type == Q_VAL
+ */
doc[cur].item[doc[cur].nitem] = item + k;
doc[cur].nitem++;
- QR_SET_OPERAND_EXISTS( qr, item+k );
+ QR_SET_OPERAND_EXISTS(qr, item + k);
}
}
}
@@ -699,7 +705,7 @@ calc_rank_cd(float4 *arrdata, TSVector txt, TSQuery query, int method)
PrevExtPos = 0.0,
CurExtPos = 0.0;
int NExtent = 0;
- QueryRepresentation qr;
+ QueryRepresentation qr;
for (i = 0; i < lengthof(weights); i++)
@@ -713,12 +719,12 @@ calc_rank_cd(float4 *arrdata, TSVector txt, TSQuery query, int method)
}
qr.query = query;
- qr.operandexist = (bool*)palloc0(sizeof(bool) * query->size);
+ qr.operandexist = (bool *) palloc0(sizeof(bool) * query->size);
doc = get_docrep(txt, &qr, &doclen);
if (!doc)
{
- pfree( qr.operandexist );
+ pfree(qr.operandexist);
return 0.0;
}
@@ -782,7 +788,7 @@ calc_rank_cd(float4 *arrdata, TSVector txt, TSQuery query, int method)
pfree(doc);
- pfree( qr.operandexist );
+ pfree(qr.operandexist);
return (float4) Wdoc;
}