Changeset: 6f4f5dc11cd8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/6f4f5dc11cd8
Modified Files:
        monetdb5/modules/mal/pp_algebra.c
Branch: pp_hashjoin
Log Message:

Formatting a bit.


diffs (truncated from 3965 to 300 lines):

diff --git a/monetdb5/modules/mal/pp_algebra.c 
b/monetdb5/modules/mal/pp_algebra.c
--- a/monetdb5/modules/mal/pp_algebra.c
+++ b/monetdb5/modules/mal/pp_algebra.c
@@ -17,47 +17,47 @@
 #include "algebra.h"
 #include "calc.h"
 
-#define sum(a,b) a+b
-#define prod(a,b) a*b
+#define sum(a, b) (a + b)
+#define prod(a, b) (a * b)
 #ifndef min
-#define min(a,b) a<b?a:b
-#define max(a,b) a>b?a:b
+#define min(a,b) (a < b ? a : b)
+#define max(a,b) (a > b ? a : b)
 #endif
 
-#define uuid_min(a,b) ((cmp((void*)&a,(void*)&b)<0)?a:b)
-#define uuid_max(a,b) ((cmp((void*)&a,(void*)&b)>0)?a:b)
-
-#define inet4_min(a,b) ((cmp((void*)&a,(void*)&b)<0)?a:b)
-#define inet4_max(a,b) ((cmp((void*)&a,(void*)&b)>0)?a:b)
+#define uuid_min(a,b) ((cmp((void*)&a, (void*)&b) < 0) ? a : b)
+#define uuid_max(a,b) ((cmp((void*)&a, (void*)&b) > 0) ? a : b)
+
+#define inet4_min(a,b) ((cmp((void*)&a, (void*)&b) < 0) ? a : b)
+#define inet4_max(a,b) ((cmp((void*)&a, (void*)&b) > 0) ? a : b)
 
 #define getArgReference_date(stk, pci, nr) (date*)getArgReference(stk, pci, nr)
 #define getArgReference_inet4(stk, pci, nr) (inet4*)getArgReference(stk, pci, 
nr)
 #define getArgReference_daytime(stk, pci, nr) (daytime*)getArgReference(stk, 
pci, nr)
 #define getArgReference_timestamp(stk, pci, nr) 
(timestamp*)getArgReference(stk, pci, nr)
 
-#define aggr(T,f)                                                              
                                \
-       if (type == TYPE_##T) {                                                 
                        \
-               T val = *getArgReference_##T(stk, pci, 1);                      
        \
-               if (!is_##T##_nil(val) && BATcount(b)) {                        
        \
-                       T *t = Tloc(b, 0);                                      
                                \
-                       if (is_##T##_nil(t[0])) {                               
                        \
-                               t[0] = val;                                     
                                        \
-                       } else                                                  
                                        \
-                               t[0] = f(t[0], val);                            
                        \
-                       MT_lock_set(&b->theaplock);                             
                        \
-                       b->tnil = false;                                        
                                \
-                       b->tnonil = true;                                       
                                \
-                       MT_lock_unset(&b->theaplock);                           
                \
-               } else if (BATcount(b) == 0) {                                  
                \
-                       if (no_nil)                                             
                                        \
-                               val = 0;                                        
                                        \
-                       if (BUNappend(b, &val, true) != GDK_SUCCEED)            
\
-                               err = createException(MAL, "lockedaggr." #f,    
\
-                                       SQLSTATE(HY013) MAL_MALLOC_FAIL);       
                \
-               }                                                               
                                                \
+#define aggr(T, f)                                                             
                                                \
+       if (type == TYPE_##T) {                                                 
                                        \
+               T val = *getArgReference_##T(stk, pci, 1);                      
                        \
+               if (!is_##T##_nil(val) && BATcount(b)) {                        
                        \
+                       T *t = Tloc(b, 0);                                      
                                                \
+                       if (is_##T##_nil(t[0])) {                               
                                        \
+                               t[0] = val;                                     
                                                        \
+                       } else                                                  
                                                        \
+                               t[0] = f(t[0], val);                            
                                        \
+                       MT_lock_set(&b->theaplock);                             
                                        \
+                       b->tnil = false;                                        
                                                \
+                       b->tnonil = true;                                       
                                                \
+                       MT_lock_unset(&b->theaplock);                           
                                \
+               } else if (BATcount(b) == 0) {                                  
                                \
+                       if (no_nil)                                             
                                                        \
+                               val = 0;                                        
                                                        \
+                       if (BUNappend(b, &val, true) != GDK_SUCCEED)            
                \
+                               err = createException(MAL, "lockedaggr." #f,    
                \
+                                                                         
SQLSTATE(HY013) MAL_MALLOC_FAIL);     \
+               }                                                               
                                                                \
        }
 
-#define faggr(T,f)                                                             
                                                \
+#define faggr(T, f)                                                            
                                                \
        if (type == TYPE_##T) {                                                 
                                        \
                T val = *getArgReference_TYPE(stk, pci, 1, T);                  
                \
                int (*cmp)(const void *v1,const void *v2) = ATOMcompare(type);  
\
@@ -76,7 +76,7 @@
                                val = 0;                                        
                                                        \
                        if (BUNappend(b, &val, true) != GDK_SUCCEED)            
                \
                                err = createException(MAL, "lockedaggr." #f,    
                \
-                                       SQLSTATE(HY013) MAL_MALLOC_FAIL);       
                                \
+                                                                         
SQLSTATE(HY013) MAL_MALLOC_FAIL);     \
                }                                                               
                                                                \
        }
 
@@ -90,11 +90,11 @@ LOCKEDAGGRsum1_(Client cntxt, MalBlkPtr 
 
        if (
 #ifdef HAVE_HGE
-                       type != TYPE_hge &&
+               type != TYPE_hge &&
 #endif
-                       type != TYPE_lng && type != TYPE_int && type != 
TYPE_sht && type != TYPE_bte &&
-                       type != TYPE_flt && type != TYPE_dbl)
-                       return createException(SQL, "lockedaggr.sum", "Wrong 
input type (%d)", type);
+               type != TYPE_lng && type != TYPE_int && type != TYPE_sht && 
type != TYPE_bte &&
+               type != TYPE_flt && type != TYPE_dbl)
+               return createException(SQL, "lockedaggr.sum", "Wrong input type 
(%d)", type);
 
        pipeline_lock(p);
 
@@ -121,24 +121,24 @@ LOCKEDAGGRsum1_(Client cntxt, MalBlkPtr 
                                BBPunfix(b->batCacheid);
                }
        } else {
-                       ptr p = (ptr)ATOMnilptr(type);
+               ptr p = (ptr)ATOMnilptr(type);
 #ifdef HAVE_HGE
-                       hge val = 0;
+               hge val = 0;
 #else
-                       lng val = 0;
+               lng val = 0;
 #endif
-                       if (no_nil)
-                               p = &val;
-                       BAT *b = COLnew(0, type, 1, TRANSIENT);
-                       if (!b || BUNappend(b, p, true) != GDK_SUCCEED)
-                               err = createException(MAL, "lockedaggr.sum", 
"Result is not initialized");
-                       if (!err) {
-                               *res = b->batCacheid;
-                               BATnegateprops(b);
-                               BBPkeepref(b);
-                       } else if (b) {
-                               BBPunfix(b->batCacheid);
-                       }
+               if (no_nil)
+                       p = &val;
+               BAT *b = COLnew(0, type, 1, TRANSIENT);
+               if (!b || BUNappend(b, p, true) != GDK_SUCCEED)
+                       err = createException(MAL, "lockedaggr.sum", "Result is 
not initialized");
+               if (!err) {
+                       *res = b->batCacheid;
+                       BATnegateprops(b);
+                       BBPkeepref(b);
+               } else if (b) {
+                       BBPunfix(b->batCacheid);
+               }
        }
        pipeline_unlock(p);
        if (err)
@@ -159,25 +159,25 @@ LOCKEDAGGRsum_no_nil1(Client cntxt, MalB
        return LOCKEDAGGRsum1_(cntxt, mb, stk, pci, true);
 }
 
-#define paggr(T,OT,f)                                                          
                        \
-       if (type == TYPE_##T && b->ttype == TYPE_##OT) {                        
\
-               T val = *getArgReference_##T(stk, pci, 1);                      
        \
-               if (!is_##T##_nil(val) && BATcount(b)) {                        
        \
-                       OT *t = Tloc(b, 0);                                     
                                \
-                       if (is_##OT##_nil(t[0])) {                              
                        \
-                               t[0] = val;                                     
                                        \
-                       } else                                                  
                                        \
-                               t[0] = f(t[0], val);                            
                        \
-                       MT_lock_set(&b->theaplock);                             
                        \
-                       b->tnil = false;                                        
                                \
-                       b->tnonil = true;                                       
                                \
-                       MT_lock_unset(&b->theaplock);                           
                \
-               } else if (BATcount(b) == 0) {                                  
                \
-                       OT ov = val;                                            
                                \
-                       if (BUNappend(b, &ov, true) != GDK_SUCCEED)             
        \
-                               err = createException(MAL, "lockedaggr." #f,    
\
-                                       SQLSTATE(HY013) MAL_MALLOC_FAIL);       
                \
-               }                                                               
                                                \
+#define paggr(T, OT, f)                                                        
                                                \
+       if (type == TYPE_##T && b->ttype == TYPE_##OT) {                        
                \
+               T val = *getArgReference_##T(stk, pci, 1);                      
                        \
+               if (!is_##T##_nil(val) && BATcount(b)) {                        
                        \
+                       OT *t = Tloc(b, 0);                                     
                                                \
+                       if (is_##OT##_nil(t[0])) {                              
                                        \
+                               t[0] = val;                                     
                                                        \
+                       } else                                                  
                                                        \
+                               t[0] = f(t[0], val);                            
                                        \
+                       MT_lock_set(&b->theaplock);                             
                                        \
+                       b->tnil = false;                                        
                                                \
+                       b->tnonil = true;                                       
                                                \
+                       MT_lock_unset(&b->theaplock);                           
                                \
+               } else if (BATcount(b) == 0) {                                  
                                \
+                       OT ov = val;                                            
                                                \
+                       if (BUNappend(b, &ov, true) != GDK_SUCCEED)             
                        \
+                               err = createException(MAL, "lockedaggr." #f,    
                \
+                                                                         
SQLSTATE(HY013) MAL_MALLOC_FAIL);     \
+               }                                                               
                                                                \
        }
 
 static str
@@ -190,11 +190,11 @@ LOCKEDAGGRprod(Client cntxt, MalBlkPtr m
 
        if (
 #ifdef HAVE_HGE
-                       type != TYPE_hge &&
+               type != TYPE_hge &&
 #endif
-                       type != TYPE_lng && type != TYPE_int && type != 
TYPE_sht && type != TYPE_bte &&
-                       type != TYPE_flt && type != TYPE_dbl)
-                       return createException(SQL, "lockedaggr.prod", "Wrong 
input type (%d)", type);
+               type != TYPE_lng && type != TYPE_int && type != TYPE_sht && 
type != TYPE_bte &&
+               type != TYPE_flt && type != TYPE_dbl)
+               return createException(SQL, "lockedaggr.prod", "Wrong input 
type (%d)", type);
 
        pipeline_lock(p);
        if (!is_bat_nil(*res)) {
@@ -229,7 +229,7 @@ LOCKEDAGGRprod(Client cntxt, MalBlkPtr m
                                BBPunfix(b->batCacheid);
                }
        } else {
-                       err = createException(SQL, "lockedaggr.prod", "Result 
is not initialized");
+               err = createException(SQL, "lockedaggr.prod", "Result is not 
initialized");
        }
        pipeline_unlock(p);
        if (err)
@@ -240,7 +240,7 @@ LOCKEDAGGRprod(Client cntxt, MalBlkPtr m
 
 #define avg_aggr(T)                                                            
                                                \
        if (type == TYPE_##T) {                                                 
                                        \
-               T val = *getArgReference_##T(stk, pci, pci->retc);              
        \
+               T val = *getArgReference_##T(stk, pci, pci->retc);              
                \
                lng cnt = *getArgReference_lng(stk, pci, pci->retc + 1);        
        \
                if (cnt > 0 && !is_##T##_nil(val) && BATcount(b)) {             
                \
                        T *t = Tloc(b, 0);                                      
                                                \
@@ -250,7 +250,7 @@ LOCKEDAGGRprod(Client cntxt, MalBlkPtr m
                                tcnt[0] = cnt;                                  
                                                \
                        } else {                                                
                                                        \
                                dbl tt = (dbl) (tcnt[0] + cnt);                 
                                \
-                               t[0] = (T) ((t[0]*((dbl)tcnt[0]/tt)) + 
(val*((dbl)cnt/tt))); \
+                               t[0] = (T) ((t[0]*((dbl)tcnt[0] / tt)) + (val * 
((dbl)cnt / tt))); \
                                tcnt[0] += cnt;                                 
                                                \
                        }                                                       
                                                                \
                        MT_lock_set(&b->theaplock);                             
                                        \
@@ -260,7 +260,7 @@ LOCKEDAGGRprod(Client cntxt, MalBlkPtr m
                } else if (cnt > 0 && BATcount(b) == 0) {                       
                        \
                        if (BUNappend(b, &val, true) != GDK_SUCCEED) {          
                \
                                err = createException(MAL, "lockedaggr.avg",    
                \
-                                       SQLSTATE(HY013) MAL_MALLOC_FAIL);       
                                \
+                                                                         
SQLSTATE(HY013) MAL_MALLOC_FAIL);     \
                                goto error;                                     
                                                        \
                        }                                                       
                                                                \
                }                                                               
                                                                \
@@ -298,12 +298,12 @@ mulmod(lng a, lng b, lng c)
 #endif
 
 #ifdef TRUNCATE_NUMBERS
-#define fix_avg(T, a, r, n)                                                    
        \
-       do {                                                                    
                        \
-               if (!is_##T##_nil(a) && r > 0 && a < 0) {               \
-                       a++;                                                    
                        \
-                       r -= n;                                                 
                        \
-               }                                                               
                                \
+#define fix_avg(T, a, r, n)                                                    
\
+       do {                                                                    
                \
+               if (!is_##T##_nil(a) && r > 0 && a < 0) {       \
+                       a++;                                                    
                \
+                       r -= n;                                                 
                \
+               }                                                               
                        \
        } while (0)
 #else
 #define fix_avg(T, a, r, n)                                                    
                        \
@@ -347,192 +347,192 @@ mulmod(lng a, lng b, lng c)
  * -1 and 1), so (a*b)%c is the remainder.
  */
 #ifdef HAVE___INT128
-#define avg_aggr_comb(T, a1, r1, n1, a2, r2, n2)                               
                                \
-       do {                                                                    
                                                                        \
-               if (is_##T##_nil(a2)) {                                         
                                                        \
-                       if (!is_lng_nil(r2)) {                                  
                                                        \
-                               a2 = a1;                                        
                                                                        \
-                               r2 = r1;                                        
                                                                        \
-                               n2 = n1;                                        
                                                                        \
-                       }                                                       
                                                                                
\
-               } else if (!is_##T##_nil(a1)) {                                 
                                                \
-                       lng N1 = is_lng_nil(n1) ? 0 : n1;                       
                                                \
-                       lng N2 = is_lng_nil(n2) ? 0 : n2;                       
                                                \
-                       lng n = N1 + N2;                                        
                                                                \
-                       T a;                                                    
                                                                        \
-                       lng r;                                                  
                                                                        \
-                       if (n == 0) {                                           
                                                                \
-                               a = 0;                                          
                                                                        \
-                               r = 0;                                          
                                                                        \
-                       } else {                                                
                                                                        \
-                               a = (T) ((a1 / n) * N1 + ((a1 % n) * (__int128) 
N1) / n +               \
-                                                (a2 / n) * N2 + ((a2 % n) * 
(__int128) N2) / n +               \
-                                                (r1 + r2) / n);                
                                                                \
-                               r = mulmod(a1, N1, n) + mulmod(a2, N2, n) + (r1 
+ r2) % n;              \
-                               while (r >= n) {                                
                                                                \
-                                       r -= n;                                 
                                                                        \
-                                       a++;                                    
                                                                        \
-                               }                                               
                                                                                
\
-                               while (r < 0) {                                 
                                                                \
-                                       r += n;                                 
                                                                        \
-                                       a--;                                    
                                                                        \
-                               }                                               
                                                                                
\
-                               fix_avg(T, a, r, n);                            
                                                        \
-                       }                                                       
                                                                                
\
-                       a2 = a;                                                 
                                                                        \
-                       r2 = r;                                                 
                                                                        \
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to