Skip to content

Commit fbb1ae9

Browse files
committed
reformat (~50%), recheck for warnings
1 parent 7c30ae1 commit fbb1ae9

File tree

2 files changed

+42
-31
lines changed

2 files changed

+42
-31
lines changed

src/backend/utils/adt/tsquery_op.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ tsquery_phrase_distance(PG_FUNCTION_ARGS)
116116
TSQuery query;
117117
int32 distance = PG_GETARG_INT32(2);
118118

119-
if (distance<0 || distance>MAXENTRYPOS)
119+
if (distance < 0 || distance > MAXENTRYPOS)
120120
ereport(ERROR,
121121
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
122122
errmsg("distance in phrase operator should be non-negative and less than %d",
@@ -132,7 +132,7 @@ tsquery_phrase_distance(PG_FUNCTION_ARGS)
132132
PG_RETURN_POINTER(a);
133133
}
134134

135-
res = join_tsqueries(a, b, OP_PHRASE, (uint16)distance );
135+
res = join_tsqueries(a, b, OP_PHRASE, (uint16) distance);
136136

137137
query = QTN2QT(res);
138138

@@ -420,7 +420,7 @@ tsquery_setweight(PG_FUNCTION_ARGS)
420420

421421
while(item - GETQUERY(out) < out->size)
422422
{
423-
if ( item->type == QI_VAL )
423+
if (item->type == QI_VAL)
424424
item->qoperand.weight |= (1 << w);
425425

426426
item++;

src/backend/utils/adt/tsrank.c

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,10 @@ calc_rank(const float *w, TSVector t, TSQuery q, int32 method)
364364
return 0.0;
365365

366366
/* XXX: What about NOT? */
367-
res = (item->type == QI_OPR && (item->qoperator.oper == OP_AND || item->qoperator.oper == OP_PHRASE)) ?
368-
calc_rank_and(w, t, q) : calc_rank_or(w, t, q);
367+
res = (item->type == QI_OPR && (item->qoperator.oper == OP_AND ||
368+
item->qoperator.oper == OP_PHRASE)) ?
369+
calc_rank_and(w, t, q) :
370+
calc_rank_or(w, t, q);
369371

370372
if (res < 0)
371373
res = 1e-20f;
@@ -532,13 +534,13 @@ compareDocR(const void *va, const void *vb)
532534
}
533535

534536
#define MAXQROPOS MAXENTRYPOS
535-
typedef struct
537+
typedef struct
536538
{
537539
bool operandexist;
538540
bool reverseinsert; /* indicates order to insert,
539541
true means descending order */
540542
uint32 npos;
541-
WordEntryPos pos[ MAXQROPOS ];
543+
WordEntryPos pos[MAXQROPOS];
542544
} QueryRepresentationOperand;
543545

544546
typedef struct
@@ -547,13 +549,14 @@ typedef struct
547549
QueryRepresentationOperand *operandData;
548550
} QueryRepresentation;
549551

550-
#define QR_GET_OPERAND_DATA(q, v) ( (q)->operandData + (((QueryItem*)(v)) - GETQUERY((q)->query)) )
552+
#define QR_GET_OPERAND_DATA(q, v) \
553+
( (q)->operandData + (((QueryItem*)(v)) - GETQUERY((q)->query)) )
551554

552555
static bool
553556
checkcondition_QueryOperand(void *checkval, QueryOperand *val, ExecPhraseData *data)
554557
{
555-
QueryRepresentation *qr = (QueryRepresentation *) checkval;
556-
QueryRepresentationOperand *opData = QR_GET_OPERAND_DATA(qr, val);
558+
QueryRepresentation *qr = (QueryRepresentation *) checkval;
559+
QueryRepresentationOperand *opData = QR_GET_OPERAND_DATA(qr, val);
557560

558561
if (!opData->operandexist)
559562
return false;
@@ -562,7 +565,7 @@ checkcondition_QueryOperand(void *checkval, QueryOperand *val, ExecPhraseData *d
562565
{
563566
data->npos = opData->npos;
564567
data->pos = opData->pos;
565-
if ( opData->reverseinsert )
568+
if (opData->reverseinsert)
566569
data->pos += MAXQROPOS - opData->npos;
567570
}
568571

@@ -581,9 +584,9 @@ typedef struct
581584
static void
582585
resetQueryRepresentation(QueryRepresentation *qr, bool reverseinsert)
583586
{
584-
int i;
587+
int i;
585588

586-
for(i=0; i<qr->query->size; i++)
589+
for(i = 0; i < qr->query->size; i++)
587590
{
588591
qr->operandData[i].operandexist = false;
589592
qr->operandData[i].reverseinsert = reverseinsert;
@@ -607,19 +610,25 @@ fillQueryRepresentationData(QueryRepresentation *qr, DocRepresentation *entry)
607610

608611
opData->operandexist = true;
609612

610-
if ( opData->npos == 0 )
613+
if (opData->npos == 0)
611614
{
612615
lastPos = (opData->reverseinsert) ? (MAXQROPOS - 1) : 0;
613-
opData->pos[ lastPos ] = entry->pos;
616+
opData->pos[lastPos] = entry->pos;
614617
opData->npos++;
615618
continue;
616619
}
617-
618-
lastPos = (opData->reverseinsert) ? (MAXQROPOS - opData->npos) : (opData->npos - 1);
619-
if ( WEP_GETPOS(opData->pos[ lastPos ]) != WEP_GETPOS(entry->pos) )
620+
621+
lastPos = opData->reverseinsert ?
622+
(MAXQROPOS - opData->npos) :
623+
(opData->npos - 1);
624+
625+
if (WEP_GETPOS(opData->pos[lastPos]) != WEP_GETPOS(entry->pos))
620626
{
621-
lastPos = (opData->reverseinsert) ? (MAXQROPOS - 1 - opData->npos) : (opData->npos);
622-
opData->pos[ lastPos ] = entry->pos;
627+
lastPos = opData->reverseinsert ?
628+
(MAXQROPOS - 1 - opData->npos) :
629+
(opData->npos);
630+
631+
opData->pos[lastPos] = entry->pos;
623632
opData->npos++;
624633
}
625634
}
@@ -628,9 +637,9 @@ fillQueryRepresentationData(QueryRepresentation *qr, DocRepresentation *entry)
628637
static bool
629638
Cover(DocRepresentation *doc, int len, QueryRepresentation *qr, CoverExt *ext)
630639
{
631-
DocRepresentation *ptr;
632-
int lastpos = ext->pos;
633-
bool found = false;
640+
DocRepresentation *ptr;
641+
int lastpos = ext->pos;
642+
bool found = false;
634643

635644
/*
636645
* since this function recurses, it could be driven to stack overflow.
@@ -777,7 +786,7 @@ get_docrep(TSVector txt, QueryRepresentation *qr, int *doclen)
777786

778787
if (cur > 0)
779788
{
780-
DocRepresentation *rptr = doc+1,
789+
DocRepresentation *rptr = doc + 1,
781790
*wptr = doc,
782791
storage;
783792

@@ -790,23 +799,24 @@ get_docrep(TSVector txt, QueryRepresentation *qr, int *doclen)
790799
* Join QueryItem per WordEntry and it's position
791800
*/
792801
storage.pos = doc->pos;
793-
storage.data.query.items = palloc(sizeof(QueryItem*) * qr->query->size);
802+
storage.data.query.items = palloc(sizeof(QueryItem *) * qr->query->size);
794803
storage.data.query.items[0] = doc->data.map.item;
795804
storage.data.query.nitem = 1;
796805

797-
while( rptr - doc < cur )
806+
while (rptr - doc < cur)
798807
{
799-
if ( rptr->pos == (rptr-1)->pos && rptr->data.map.entry == (rptr-1)->data.map.entry )
808+
if (rptr->pos == (rptr-1)->pos &&
809+
rptr->data.map.entry == (rptr-1)->data.map.entry)
800810
{
801-
storage.data.query.items[ storage.data.query.nitem ] = rptr->data.map.item;
811+
storage.data.query.items[storage.data.query.nitem] = rptr->data.map.item;
802812
storage.data.query.nitem++;
803813
}
804814
else
805815
{
806816
*wptr = storage;
807817
wptr++;
808818
storage.pos = rptr->pos;
809-
storage.data.query.items = palloc(sizeof(QueryItem*) * qr->query->size);
819+
storage.data.query.items = palloc(sizeof(QueryItem *) * qr->query->size);
810820
storage.data.query.items[0] = rptr->data.map.item;
811821
storage.data.query.nitem = 1;
812822
}
@@ -853,7 +863,8 @@ calc_rank_cd(const float4 *arrdata, TSVector txt, TSQuery query, int method)
853863
}
854864

855865
qr.query = query;
856-
qr.operandData = (QueryRepresentationOperand *) palloc0(sizeof(QueryRepresentationOperand) * query->size);
866+
qr.operandData = (QueryRepresentationOperand *)
867+
palloc0(sizeof(QueryRepresentationOperand) * query->size);
857868

858869
doc = get_docrep(txt, &qr, &doclen);
859870
if (!doc)
@@ -872,7 +883,7 @@ calc_rank_cd(const float4 *arrdata, TSVector txt, TSQuery query, int method)
872883

873884
while (ptr <= ext.end)
874885
{
875-
InvSum += invws[ WEP_GETWEIGHT(ptr->pos) ];
886+
InvSum += invws[WEP_GETWEIGHT(ptr->pos)];
876887
ptr++;
877888
}
878889

0 commit comments

Comments
 (0)