OSDN Git Service

pgindent run.
authorMasahiko Sawada <sawada.mshk@gmail.com>
Fri, 6 Feb 2015 04:41:34 +0000 (13:41 +0900)
committerMasahiko Sawada <sawada.mshk@gmail.com>
Fri, 6 Feb 2015 05:30:30 +0000 (14:30 +0900)
This commit is inspried by the change of pg_trgm:
0a7832005792fa6dad171f9cadb8d587fe0dd800

Backpatch to all branches.

Beena Emerson

bigm.h
bigm_gin.c
bigm_op.c

diff --git a/bigm.h b/bigm.h
index 57b735d..8be6338 100644 (file)
--- a/bigm.h
+++ b/bigm.h
@@ -4,9 +4,9 @@
  * Portions Copyright (c) 2013-2015, NTT DATA Corporation
  *
  * Changelog:
- *   2013/01/09
- *   Support full text search using bigrams.
- *   Author: NTT DATA Corporation
+ *      2013/01/09
+ *      Support full text search using bigrams.
+ *      Author: NTT DATA Corporation
  *
  *-------------------------------------------------------------------------
  */
@@ -18,9 +18,9 @@
 #include "utils/builtins.h"
 
 /* GUC variable */
-extern bool            bigm_enable_recheck;
-extern int             bigm_gin_key_limit;
-extern double  bigm_similarity_limit;
+extern bool bigm_enable_recheck;
+extern int     bigm_gin_key_limit;
+extern double bigm_similarity_limit;
 
 /* options */
 #define LPADDING               1
@@ -32,14 +32,15 @@ extern double       bigm_similarity_limit;
 
 typedef struct
 {
-       bool    pmatch;         /* partial match is required? */
-       int             bytelen;        /* byte length of bi-gram string */
+       bool            pmatch;                 /* partial match is required? */
+       int                     bytelen;                /* byte length of bi-gram string */
+
        /*
-        * Bi-gram string; we assume here that the maximum bytes for
-        * a character are four.
+        * Bi-gram string; we assume here that the maximum bytes for a character
+        * are four.
         */
-       char    str[8];
-} bigm;
+       char            str[8];
+}      bigm;
 
 #define BIGMSIZE       sizeof(bigm)
 
@@ -60,13 +61,13 @@ typedef struct
 {
        int32           vl_len_;                /* varlena header (do not touch directly!) */
        char            data[1];
-} BIGM;
+}      BIGM;
 
 #define CALCGTSIZE(len) (VARHDRSZ + len * sizeof(bigm))
 #define GETARR(x)              ( (bigm *)( (char*)x + VARHDRSZ ) )
 #define ARRNELEM(x) ( ( VARSIZE(x) - VARHDRSZ )/sizeof(bigm) )
 
-extern BIGM       *generate_bigm(char *str, int slen);
-extern BIGM       *generate_wildcard_bigm(const char *str, int slen, bool *removeDups);
+extern BIGM *generate_bigm(char *str, int slen);
+extern BIGM *generate_wildcard_bigm(const char *str, int slen, bool *removeDups);
 
 #endif   /* __BIGM_H__ */
index 9858966..cf7caf8 100644 (file)
@@ -4,9 +4,9 @@
  * Portions Copyright (c) 2013-2015, NTT DATA Corporation
  *
  * Changelog:
- *   2013/01/09
- *   Support full text search using bigrams.
- *   Author: NTT DATA Corporation
+ *      2013/01/09
+ *      Support full text search using bigrams.
+ *      Author: NTT DATA Corporation
  *
  *-------------------------------------------------------------------------
  */
@@ -73,7 +73,8 @@ gin_extract_value_bigm(PG_FUNCTION_ARGS)
                ptr = GETARR(bgm);
                for (i = 0; i < bgmlen; i++)
                {
-                       text            *item = cstring_to_text_with_len(ptr->str, ptr->bytelen);
+                       text       *item = cstring_to_text_with_len(ptr->str, ptr->bytelen);
+
                        entries[i] = PointerGetDatum(item);
                        ptr++;
                }
@@ -89,8 +90,9 @@ gin_extract_query_bigm(PG_FUNCTION_ARGS)
        int32      *nentries = (int32 *) PG_GETARG_POINTER(1);
        StrategyNumber strategy = PG_GETARG_UINT16(2);
 
-       bool   **pmatch = (bool **) PG_GETARG_POINTER(3);
-       Pointer   **extra_data = (Pointer **) PG_GETARG_POINTER(4);
+       bool      **pmatch = (bool **) PG_GETARG_POINTER(3);
+       Pointer   **extra_data = (Pointer **) PG_GETARG_POINTER(4);
+
        /* bool   **nullFlags = (bool **) PG_GETARG_POINTER(5); */
        int32      *searchMode = (int32 *) PG_GETARG_POINTER(6);
        Datum      *entries = NULL;
@@ -104,9 +106,9 @@ gin_extract_query_bigm(PG_FUNCTION_ARGS)
        {
                case LikeStrategyNumber:
                {
-                       char    *str = VARDATA(val);
-                       int             slen = VARSIZE(val) - VARHDRSZ;
-                       bool    *recheck;
+                       char       *str = VARDATA(val);
+                       int                     slen = VARSIZE(val) - VARHDRSZ;
+                       bool       *recheck;
 
                        /*
                         * For wildcard search we extract all the bigrams that every
@@ -116,17 +118,18 @@ gin_extract_query_bigm(PG_FUNCTION_ARGS)
                        bgmlen = ARRNELEM(bgm);
 
                        /*
-                        * Check whether the heap tuple fetched by index search needs to be
-                        * rechecked against the query. If the search word consists of one
-                        * or two characters and doesn't contain any space character, we can
-                        * guarantee that the index test would be exact. That is, the heap
-                        * tuple does match the query, so it doesn't need to be rechecked.
+                        * Check whether the heap tuple fetched by index search needs to
+                        * be rechecked against the query. If the search word consists of
+                        * one or two characters and doesn't contain any space character,
+                        * we can guarantee that the index test would be exact. That is,
+                        * the heap tuple does match the query, so it doesn't need to be
+                        * rechecked.
                         */
                        *extra_data = (Pointer *) palloc(sizeof(bool));
                        recheck = (bool *) *extra_data;
                        if (bgmlen == 1 && !removeDups)
                        {
-                               const char      *sp;
+                               const char *sp;
 
                                *recheck = false;
                                for (sp = str; (sp - str) < slen;)
@@ -166,7 +169,7 @@ gin_extract_query_bigm(PG_FUNCTION_ARGS)
                ptr = GETARR(bgm);
                for (i = 0; i < *nentries; i++)
                {
-                       text            *item;
+                       text       *item;
 
                        if (ptr->pmatch)
                        {
@@ -198,7 +201,7 @@ gin_bigm_consistent(PG_FUNCTION_ARGS)
        /* text    *query = PG_GETARG_TEXT_P(2); */
        int32           nkeys = PG_GETARG_INT32(3);
 
-       Pointer   *extra_data = (Pointer *) PG_GETARG_POINTER(4);
+       Pointer    *extra_data = (Pointer *) PG_GETARG_POINTER(4);
        bool       *recheck = (bool *) PG_GETARG_POINTER(5);
        bool            res;
        int32           i;
@@ -207,11 +210,11 @@ gin_bigm_consistent(PG_FUNCTION_ARGS)
        switch (strategy)
        {
                case LikeStrategyNumber:
+
                        /*
                         * Don't recheck the heap tuple against the query if either
-                        * pg_bigm.enable_recheck is disabled or the search word is
-                        * the special one so that the index can return the exact
-                        * result.
+                        * pg_bigm.enable_recheck is disabled or the search word is the
+                        * special one so that the index can return the exact result.
                         */
                        Assert(extra_data != NULL);
                        *recheck = bigm_enable_recheck &&
@@ -259,13 +262,13 @@ gin_bigm_consistent(PG_FUNCTION_ARGS)
 Datum
 gin_bigm_compare_partial(PG_FUNCTION_ARGS)
 {
-       text    *arg1 = PG_GETARG_TEXT_PP(0);
-       text    *arg2 = PG_GETARG_TEXT_PP(1);
-       char    *a1p;
-       char    *a2p;
-       int             mblen1;
-       int             mblen2;
-       int             res;
+       text       *arg1 = PG_GETARG_TEXT_PP(0);
+       text       *arg2 = PG_GETARG_TEXT_PP(1);
+       char       *a1p;
+       char       *a2p;
+       int                     mblen1;
+       int                     mblen2;
+       int                     res;
 
        a1p = VARDATA_ANY(arg1);
        a2p = VARDATA_ANY(arg2);
@@ -308,8 +311,8 @@ pg_gin_pending_stats(PG_FUNCTION_ARGS)
        index_close(indexRel, AccessShareLock);
 
        /*
-        * Construct a tuple descriptor for the result row. This must
-        * match this function's pg_bigm--x.x.sql entry.
+        * Construct a tuple descriptor for the result row. This must match this
+        * function's pg_bigm--x.x.sql entry.
         */
        tupdesc = CreateTemplateTupleDesc(2, false);
        TupleDescInitEntry(tupdesc, (AttrNumber) 1,
index 6b1c1a9..49d628b 100644 (file)
--- a/bigm_op.c
+++ b/bigm_op.c
@@ -4,9 +4,9 @@
  * Portions Copyright (c) 2013-2015, NTT DATA Corporation
  *
  * Changelog:
- *   2013/01/09
- *   Support full text search using bigrams.
- *   Author: NTT DATA Corporation
+ *      2013/01/09
+ *      Support full text search using bigrams.
+ *      Author: NTT DATA Corporation
  *
  *-------------------------------------------------------------------------
  */
 PG_MODULE_MAGIC;
 
 /* Last update date of pg_bigm */
-#define        BIGM_LAST_UPDATE        "2013.11.22"
+#define BIGM_LAST_UPDATE       "2013.11.22"
 
 /* GUC variable */
-bool   bigm_enable_recheck = false;
-int            bigm_gin_key_limit = 0;
-double bigm_similarity_limit = 0.3;
-char   *bigm_last_update = NULL;
+bool           bigm_enable_recheck = false;
+int                    bigm_gin_key_limit = 0;
+double         bigm_similarity_limit = 0.3;
+char      *bigm_last_update = NULL;
 
 PG_FUNCTION_INFO_V1(show_bigm);
 PG_FUNCTION_INFO_V1(bigmtextcmp);
@@ -119,8 +119,8 @@ _PG_fini(void)
 static int
 comp_bigm(const void *a, const void *b, void *arg)
 {
-       int             res;
-       bool    *haveDups = (bool *) arg;
+       int                     res;
+       bool       *haveDups = (bool *) arg;
 
        res = CMPBIGM(a, b);
 
@@ -179,7 +179,7 @@ find_word(char *str, int lenstr, char **endword, int *charlen)
        return beginword;
 }
 
-/* 
+/*
  * The function is named compact_bigram to maintain consistency with pg_trgm,
  * though it does not reduce multibyte characters to hash values like in
  * compact_trigram.
@@ -281,7 +281,7 @@ generate_bigm(char *str, int slen)
                 * count bigrams
                 */
                bptr = make_bigrams(bptr, buf, bytelen + LPADDING + RPADDING,
-                                                        charlen + LPADDING + RPADDING);
+                                                       charlen + LPADDING + RPADDING);
        }
 
        pfree(buf);
@@ -294,7 +294,7 @@ generate_bigm(char *str, int slen)
         */
        if (len > 1)
        {
-               bool    haveDups = false;
+               bool            haveDups = false;
 
                qsort_arg((void *) GETARR(bgm), len, sizeof(bigm), comp_bigm, (void *) &haveDups);
                if (haveDups)
@@ -328,8 +328,8 @@ get_wildcard_part(const char *str, int lenstr,
        const char *beginword = str;
        const char *endword;
        char       *s = buf;
-       bool        in_leading_wildcard_meta = false;
-       bool        in_trailing_wildcard_meta = false;
+       bool            in_leading_wildcard_meta = false;
+       bool            in_trailing_wildcard_meta = false;
        bool            in_escape = false;
        int                     clen;
 
@@ -406,8 +406,8 @@ get_wildcard_part(const char *str, int lenstr,
                        else
                        {
                                /*
-                                * Back up endword to the escape character when stopping at
-                                * an escaped char, so that subsequent get_wildcard_part will
+                                * Back up endword to the escape character when stopping at an
+                                * escaped char, so that subsequent get_wildcard_part will
                                 * restart from the escape character.  We assume here that
                                 * escape chars are single-byte.
                                 */
@@ -514,7 +514,7 @@ generate_wildcard_bigm(const char *str, int slen, bool *removeDups)
         */
        if (len > 1)
        {
-               bool    haveDups = false;
+               bool            haveDups = false;
 
                qsort_arg((void *) GETARR(bgm), len, sizeof(bigm), comp_bigm, (void *) &haveDups);
                if (haveDups)
@@ -545,6 +545,7 @@ show_bigm(PG_FUNCTION_ARGS)
        for (i = 0, ptr = GETARR(bgm); i < ARRNELEM(bgm); i++, ptr++)
        {
                text       *item = cstring_to_text_with_len(ptr->str, ptr->bytelen);
+
                d[i] = PointerGetDatum(item);
        }
 
@@ -588,7 +589,7 @@ cnt_sml_bigm(BIGM *bgm1, BIGM *bgm2)
 
        while (ptr1 - GETARR(bgm1) < len1 && ptr2 - GETARR(bgm2) < len2)
        {
-               int             res = CMPBIGM(ptr1, ptr2);
+               int                     res = CMPBIGM(ptr1, ptr2);
 
                if (res < 0)
                        ptr1++;
@@ -708,12 +709,12 @@ bigmstrcmp(char *arg1, int len1, char *arg2, int len2)
 Datum
 bigmtextcmp(PG_FUNCTION_ARGS)
 {
-       text    *arg1 = PG_GETARG_TEXT_PP(0);
-       text    *arg2 = PG_GETARG_TEXT_PP(1);
-       char    *a1p = VARDATA_ANY(arg1);
-       char    *a2p = VARDATA_ANY(arg2);
-       int             len1 = VARSIZE_ANY_EXHDR(arg1);
-       int             len2 = VARSIZE_ANY_EXHDR(arg2);
+       text       *arg1 = PG_GETARG_TEXT_PP(0);
+       text       *arg2 = PG_GETARG_TEXT_PP(1);
+       char       *a1p = VARDATA_ANY(arg1);
+       char       *a2p = VARDATA_ANY(arg2);
+       int                     len1 = VARSIZE_ANY_EXHDR(arg1);
+       int                     len2 = VARSIZE_ANY_EXHDR(arg2);
 
        PG_RETURN_INT32(bigmstrcmp(a1p, len1, a2p, len2));
 }