Changeset: 5a194b5b72de for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5a194b5b72de
Modified Files:
        gdk/gdk_analytic_bounds.c
        gdk/gdk_analytic_func.c
Branch: window-tunning
Log Message:

Move diff function into bounds translation unit


diffs (266 lines):

diff --git a/gdk/gdk_analytic_bounds.c b/gdk/gdk_analytic_bounds.c
--- a/gdk/gdk_analytic_bounds.c
+++ b/gdk/gdk_analytic_bounds.c
@@ -11,6 +11,129 @@
 #include "gdk_analytic.h"
 #include "gdk_calc_private.h"
 
+#define ANALYTICAL_DIFF_IMP(TPE)                               \
+       do {                                                    \
+               TPE *restrict bp = (TPE*)Tloc(b, 0), prev = bp[0];              
\
+               if (np) {                                       \
+                       for (; i < cnt; i++) {  \
+                               TPE next = bp[i]; \
+                               if (next != prev) {             \
+                                       rb[i] = TRUE;           \
+                                       prev = next;            \
+                               } else {        \
+                                       rb[i] = np[i];                  \
+                               }                       \
+                       }                                       \
+               } else {                                        \
+                       for (; i < cnt; i++) {          \
+                               TPE next = bp[i]; \
+                               if (next == prev) {             \
+                                       rb[i] = FALSE;          \
+                               } else {                        \
+                                       rb[i] = TRUE;           \
+                                       prev = next;            \
+                               }                               \
+                       }                               \
+               }                               \
+       } while (0)
+
+/* We use NaN for floating point null values, which always output false on 
equality tests */
+#define ANALYTICAL_DIFF_FLOAT_IMP(TPE)                                 \
+       do {                                                            \
+               TPE *restrict bp = (TPE*)Tloc(b, 0), prev = bp[0];              
\
+               if (np) {                                               \
+                       for (; i < cnt; i++) {          \
+                               TPE next = bp[i]; \
+                               if (next != prev && (!is_##TPE##_nil(next) || 
!is_##TPE##_nil(prev))) { \
+                                       rb[i] = TRUE;                   \
+                                       prev = next;                    \
+                               } else {        \
+                                       rb[i] = np[i];                  \
+                               }                       \
+                       }                                               \
+               } else {                                                \
+                       for (; i < cnt; i++) {                  \
+                               TPE next = bp[i]; \
+                               if (next == prev || (is_##TPE##_nil(next) && 
is_##TPE##_nil(prev))) { \
+                                       rb[i] = FALSE;                  \
+                               } else {                                \
+                                       rb[i] = TRUE;                   \
+                                       prev = next;            \
+                               }                               \
+                       }                               \
+               }                               \
+       } while (0)
+
+gdk_return
+GDKanalyticaldiff(BAT *r, BAT *b, BAT *p, int tpe)
+{
+       BUN i = 0, cnt = BATcount(b);
+       bit *restrict rb = (bit *) Tloc(r, 0), *restrict np = p ? (bit *) 
Tloc(p, 0) : NULL;
+
+       switch (ATOMbasetype(tpe)) {
+       case TYPE_bte:
+               ANALYTICAL_DIFF_IMP(bte);
+               break;
+       case TYPE_sht:
+               ANALYTICAL_DIFF_IMP(sht);
+               break;
+       case TYPE_int:
+               ANALYTICAL_DIFF_IMP(int);
+               break;
+       case TYPE_lng:
+               ANALYTICAL_DIFF_IMP(lng);
+               break;
+#ifdef HAVE_HGE
+       case TYPE_hge:
+               ANALYTICAL_DIFF_IMP(hge);
+               break;
+#endif
+       case TYPE_flt: {
+               if (b->tnonil) {
+                       ANALYTICAL_DIFF_IMP(flt);
+               } else { /* Because of NaN values, use this path */
+                       ANALYTICAL_DIFF_FLOAT_IMP(flt);
+               }
+       } break;
+       case TYPE_dbl: {
+               if (b->tnonil) {
+                       ANALYTICAL_DIFF_IMP(dbl);
+               } else { /* Because of NaN values, use this path */
+                       ANALYTICAL_DIFF_FLOAT_IMP(dbl);
+               }
+       } break;
+       default:{
+               BATiter it = bat_iterator(b);
+               ptr v = BUNtail(it, 0), next;
+               int (*atomcmp) (const void *, const void *) = ATOMcompare(tpe);
+               if (np) {
+                       for (i = 0; i < cnt; i++) {
+                               rb[i] = np[i];
+                               next = BUNtail(it, i);
+                               if (atomcmp(v, next) != 0) {
+                                       rb[i] = TRUE;
+                                       v = next;
+                               }
+                       }
+               } else {
+                       for (i = 0; i < cnt; i++) {
+                               next = BUNtail(it, i);
+                               if (atomcmp(v, next) != 0) {
+                                       rb[i] = TRUE;
+                                       v = next;
+                               } else {
+                                       rb[i] = FALSE;
+                               }
+                       }
+               }
+       }
+       }
+       BATsetcount(r, (BUN) cnt);
+       r->tnonil = true;
+       r->tnil = false;
+       return GDK_SUCCEED;
+}
+
 #define ANALYTICAL_WINDOW_BOUNDS_ROWS_PRECEDING(LIMIT)                 \
        do {                                                            \
                lng calc1, calc2;                                       \
diff --git a/gdk/gdk_analytic_func.c b/gdk/gdk_analytic_func.c
--- a/gdk/gdk_analytic_func.c
+++ b/gdk/gdk_analytic_func.c
@@ -11,129 +11,6 @@
 #include "gdk_analytic.h"
 #include "gdk_calc_private.h"
 
-#define ANALYTICAL_DIFF_IMP(TPE)                               \
-       do {                                                    \
-               TPE *restrict bp = (TPE*)Tloc(b, 0), prev = bp[0];              
\
-               if (np) {                                       \
-                       for (; i < cnt; i++) {  \
-                               TPE next = bp[i]; \
-                               if (next != prev) {             \
-                                       rb[i] = TRUE;           \
-                                       prev = next;            \
-                               } else {        \
-                                       rb[i] = np[i];                  \
-                               }                       \
-                       }                                       \
-               } else {                                        \
-                       for (; i < cnt; i++) {          \
-                               TPE next = bp[i]; \
-                               if (next == prev) {             \
-                                       rb[i] = FALSE;          \
-                               } else {                        \
-                                       rb[i] = TRUE;           \
-                                       prev = next;            \
-                               }                               \
-                       }                               \
-               }                               \
-       } while (0)
-
-/* We use NaN for floating point null values, which always output false on 
equality tests */
-#define ANALYTICAL_DIFF_FLOAT_IMP(TPE)                                 \
-       do {                                                            \
-               TPE *restrict bp = (TPE*)Tloc(b, 0), prev = bp[0];              
\
-               if (np) {                                               \
-                       for (; i < cnt; i++) {          \
-                               TPE next = bp[i]; \
-                               if (next != prev && (!is_##TPE##_nil(next) || 
!is_##TPE##_nil(prev))) { \
-                                       rb[i] = TRUE;                   \
-                                       prev = next;                    \
-                               } else {        \
-                                       rb[i] = np[i];                  \
-                               }                       \
-                       }                                               \
-               } else {                                                \
-                       for (; i < cnt; i++) {                  \
-                               TPE next = bp[i]; \
-                               if (next == prev || (is_##TPE##_nil(next) && 
is_##TPE##_nil(prev))) { \
-                                       rb[i] = FALSE;                  \
-                               } else {                                \
-                                       rb[i] = TRUE;                   \
-                                       prev = next;            \
-                               }                               \
-                       }                               \
-               }                               \
-       } while (0)
-
-gdk_return
-GDKanalyticaldiff(BAT *r, BAT *b, BAT *p, int tpe)
-{
-       BUN i = 0, cnt = BATcount(b);
-       bit *restrict rb = (bit *) Tloc(r, 0), *restrict np = p ? (bit *) 
Tloc(p, 0) : NULL;
-
-       switch (ATOMbasetype(tpe)) {
-       case TYPE_bte:
-               ANALYTICAL_DIFF_IMP(bte);
-               break;
-       case TYPE_sht:
-               ANALYTICAL_DIFF_IMP(sht);
-               break;
-       case TYPE_int:
-               ANALYTICAL_DIFF_IMP(int);
-               break;
-       case TYPE_lng:
-               ANALYTICAL_DIFF_IMP(lng);
-               break;
-#ifdef HAVE_HGE
-       case TYPE_hge:
-               ANALYTICAL_DIFF_IMP(hge);
-               break;
-#endif
-       case TYPE_flt: {
-               if (b->tnonil) {
-                       ANALYTICAL_DIFF_IMP(flt);
-               } else { /* Because of NaN values, use this path */
-                       ANALYTICAL_DIFF_FLOAT_IMP(flt);
-               }
-       } break;
-       case TYPE_dbl: {
-               if (b->tnonil) {
-                       ANALYTICAL_DIFF_IMP(dbl);
-               } else { /* Because of NaN values, use this path */
-                       ANALYTICAL_DIFF_FLOAT_IMP(dbl);
-               }
-       } break;
-       default:{
-               BATiter it = bat_iterator(b);
-               ptr v = BUNtail(it, 0), next;
-               int (*atomcmp) (const void *, const void *) = ATOMcompare(tpe);
-               if (np) {
-                       for (i = 0; i < cnt; i++) {
-                               rb[i] = np[i];
-                               next = BUNtail(it, i);
-                               if (atomcmp(v, next) != 0) {
-                                       rb[i] = TRUE;
-                                       v = next;
-                               }
-                       }
-               } else {
-                       for (i = 0; i < cnt; i++) {
-                               next = BUNtail(it, i);
-                               if (atomcmp(v, next) != 0) {
-                                       rb[i] = TRUE;
-                                       v = next;
-                               } else {
-                                       rb[i] = FALSE;
-                               }
-                       }
-               }
-       }
-       }
-       BATsetcount(r, (BUN) cnt);
-       r->tnonil = true;
-       r->tnil = false;
-       return GDK_SUCCEED;
-}
-
 #define NTILE_CALC(TPE, NEXT_VALUE, LNG_HGE, UPCAST)   \
        do {                                    \
                for (TPE i = 0; rb < rp; i++, rb++) {   \
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to