From 57cafe79823dcd3653cf5e19cbdf58300cb1576c Mon Sep 17 00:00:00 2001 From: Teodor Sigaev Date: Tue, 11 Sep 2007 08:46:29 +0000 Subject: Refactor from Heikki Linnakangas : * Defined new struct WordEntryPosVector that holds a uint16 length and a variable size array of WordEntries. This replaces the previous convention of a variable size uint16 array, with the first element implying the length. WordEntryPosVector has the same layout in memory, but is more readable in source code. The POSDATAPTR and POSDATALEN macros are still used, though it would now be more readable to access the fields in WordEntryPosVector directly. * Removed needfree field from DocRepresentation. It was always set to false. * Miscellaneous other commenting and refactoring --- src/backend/utils/adt/tsginidx.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/backend/utils/adt/tsginidx.c') diff --git a/src/backend/utils/adt/tsginidx.c b/src/backend/utils/adt/tsginidx.c index 974a1b7ae4e..ba4a10313cb 100644 --- a/src/backend/utils/adt/tsginidx.c +++ b/src/backend/utils/adt/tsginidx.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/tsginidx.c,v 1.3 2007/09/07 16:03:40 teodor Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/tsginidx.c,v 1.4 2007/09/11 08:46:29 teodor Exp $ * *------------------------------------------------------------------------- */ @@ -25,13 +25,12 @@ gin_extract_tsvector(PG_FUNCTION_ARGS) int32 *nentries = (int32 *) PG_GETARG_POINTER(1); Datum *entries = NULL; - *nentries = 0; + *nentries = vector->size; if (vector->size > 0) { int i; WordEntry *we = ARRPTR(vector); - *nentries = (uint32) vector->size; entries = (Datum *) palloc(sizeof(Datum) * vector->size); for (i = 0; i < vector->size; i++) @@ -134,11 +133,19 @@ gin_ts_consistent(PG_FUNCTION_ARGS) if (query->size > 0) { - int4 i, + int i, j = 0; QueryItem *item; GinChkVal gcv; + /* + * check-parameter array has one entry for each value (operand) in the + * query. We expand that array into mapped_check, so that there's one + * entry in mapped_check for every node in the query, including + * operators, to allow quick lookups in checkcondition_gin. Only the + * entries corresponding operands are actually used. + */ + gcv.frst = item = GETQUERY(query); gcv.mapped_check = (bool *) palloc(sizeof(bool) * query->size); -- cgit v1.2.3