Re-indent GiST macros
authorPeter Geoghegan <[email protected]>
Mon, 10 Mar 2014 01:09:45 +0000 (18:09 -0700)
committerPeter Geoghegan <[email protected]>
Mon, 10 Mar 2014 01:09:45 +0000 (18:09 -0700)
src/backend/utils/adt/jsonb_gin.c
src/backend/utils/adt/jsonb_gist.c

index 7a26a6628708ddf6c548de93182d93b2d0469734..3c53d47ae9e3888346aa096709530f53329db305 100644 (file)
@@ -70,9 +70,9 @@ gin_extract_jsonb(PG_FUNCTION_ARGS)
        {
            case WJB_KEY:
                /*
-                * An element of an array is serialized as a key for our
-                * purposes.  This is necessary because array elements are also
-                * keys.
+                * Serialize keys and elements as one.  This is necessary
+                * because array elements must be indexed as keys for the
+                * benefit of JsonbContainsStrategyNumber.
                 */
            case WJB_ELEM:
                entries[i++] = PointerGetDatum(makeitemFromValue(&v, KEYELEMFLAG));
@@ -105,7 +105,7 @@ gin_extract_jsonb_query(PG_FUNCTION_ARGS)
            DatumGetPointer(DirectFunctionCall2(gin_extract_jsonb,
                                                PG_GETARG_DATUM(0),
                                                PointerGetDatum(nentries)));
-       /* ... except that "contains {}" requires a full index scan */
+       /* ...except for "contains {}", which requires a full index scan */
        if (entries == NULL)
            *searchMode = GIN_SEARCH_MODE_ALL;
    }
@@ -180,8 +180,9 @@ gin_consistent_jsonb(PG_FUNCTION_ARGS)
    {
        /*
         * Index doesn't have information about correspondence of keys and
-        * values, so we must recheck.  However, if all of the keys are not
-        * present, we can fail immediately.
+        * values, so invariably we recheck.  However, if all of the keys are
+        * not present, that's sufficient reason to return false and finish
+        * immediately.
         */
        *recheck = true;
        for (i = 0; i < nkeys; i++)
@@ -246,9 +247,10 @@ gin_consistent_jsonb_hash(PG_FUNCTION_ARGS)
    if (strategy == JsonbContainsStrategyNumber)
    {
        /*
-        * Index doesn't have information about correspondence of keys and
-        * values, so we must recheck.  However, if not all of the keys are
-        * present, we can fail immediately.
+        * jsonb_hash_ops index doesn't have information about correspondence
+        * of keys and values, so invariably we recheck.  However, if all of
+        * the keys are not present, that's sufficient reason to return false
+        * and finish immediately.
         */
        *recheck = true;
        for (i = 0; i < nkeys; i++)
@@ -298,7 +300,7 @@ gin_extract_jsonb_hash(PG_FUNCTION_ARGS)
 
    /*
     * Calculate hashes of all key_1.key_2. ... .key_n.value paths as entries.
-    * Order of array elements doesn't matter so array keys are empty in path.
+    * Order of array elements doesn't matter, so array keys are empty in path.
     * For faster calculation of hashes, use a stack of precalculated hashes of
     * prefixes.
     */
index 26356a12d3283a02e720f927289895f4ad469e74..7bf9841c6053a5e235172096ef789fb9768db512 100644 (file)
@@ -22,7 +22,7 @@
 
 /* bigint defines */
 #define BITBYTE            8
-#define SIGLENINT          4           /* >122 => key will toast, so very slow! */
+#define SIGLENINT          4           /* > 122 => key be will toasted */
 #define SIGLEN         (sizeof(int)*SIGLENINT)
 #define SIGLENBIT      (SIGLEN*BITBYTE)
 
@@ -38,20 +38,19 @@ typedef char *BITVECP;
            for(i=0;i<SIGLENBIT;i++)
 
 /* Beware of multiple evaluation of arguments to these macros! */
-#define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) )
-#define GETBITBYTE(x,i) ( (*((char*)(x)) >> (i)) & 0x01 )
-#define CLRBIT(x,i)   GETBYTE(x,i) &= ~( 0x01 << ( (i) % BITBYTE ) )
-#define SETBIT(x,i)   GETBYTE(x,i) |=  ( 0x01 << ( (i) % BITBYTE ) )
-#define GETBIT(x,i) ( (GETBYTE(x,i) >> ( (i) % BITBYTE )) & 0x01 )
-#define HASHVAL(val) (((unsigned int)(val)) % SIGLENBIT)
-#define HASH(sign, val) SETBIT((sign), HASHVAL(val))
-
-#define ALLISTRUE      0x04
-#define ISALLTRUE(x)   ( ((GISTTYPE*)x)->flag & ALLISTRUE )
-#define GTHDRSIZE      (VARHDRSZ + sizeof(int32))
-#define CALCGTSIZE(flag) ( GTHDRSIZE+(((flag) & ALLISTRUE) ? 0 : SIGLEN) )
-#define GETSIGN(x)     ( (BITVECP)( (char*)x+GTHDRSIZE ) )
-
+#define GETBYTE(x,i)       (*((BITVECP)(x) + (int)( (i) / BITBYTE )))
+#define GETBITBYTE(x,i)        ((*((char*)(x)) >> (i)) & 0x01)
+#define CLRBIT(x,i)        GETBYTE(x,i) &= ~( 0x01 << ( (i) % BITBYTE ))
+#define SETBIT(x,i)        GETBYTE(x,i) |=  ( 0x01 << ( (i) % BITBYTE ))
+#define GETBIT(x,i)        ((GETBYTE(x,i) >> ( (i) % BITBYTE )) & 0x01)
+#define HASHVAL(val)       (((unsigned int)(val)) % SIGLENBIT)
+#define HASH(sign, val)        SETBIT((sign), HASHVAL(val))
+
+#define ALLISTRUE          0x04
+#define ISALLTRUE(x)       (((GISTTYPE*)x)->flag & ALLISTRUE)
+#define GTHDRSIZE          (VARHDRSZ + sizeof(int32))
+#define CALCGTSIZE(flag)   (GTHDRSIZE+(((flag) & ALLISTRUE) ? 0 : SIGLEN))
+#define GETSIGN(x)         ((BITVECP)( (char*)x+GTHDRSIZE))
 #define SUMBIT(val) (      \
    GETBITBYTE((val),0) + \
    GETBITBYTE((val),1) + \
@@ -63,8 +62,8 @@ typedef char *BITVECP;
    GETBITBYTE((val),7)   \
 )
 
-#define GETENTRY(vec,pos) ((GISTTYPE *) DatumGetPointer((vec)->vector[(pos)].key))
-#define WISH_F(a,b,c) (double)( -(double)(((a)-(b))*((a)-(b))*((a)-(b)))*(c) )
+#define GETENTRY(vec,pos)  ((GISTTYPE *) DatumGetPointer((vec)->vector[(pos)].key))
+#define WISH_F(a,b,c)      ((double) ( -(double)(((a)-(b))*((a)-(b))*((a)-(b)))*(c)))
 
 typedef struct
 {
@@ -575,8 +574,9 @@ crc32_JsonbValue(JsonbValue * v, uint32 r)
    {
        case WJB_KEY:
            /*
-            * An element of an array is serialized as a key for our purposes.
-            * This is necessary because array elements are also keys.
+            * Serialize keys and elements as one.  This is necessary because
+            * array elements must be indexed as keys for the benefit of
+            * JsonbContainsStrategyNumber.
             */
        case WJB_ELEM:
            flag = KEYELEMFLAG;