Changeset: e7aebe03257d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e7aebe03257d
Modified Files:
        clients/mapiclient/tomograph.c
        clients/python2/monetdb/sql/connections.py
        clients/python2/monetdb/sql/cursors.py
        clients/python3/monetdb/sql/connections.py
        clients/python3/monetdb/sql/cursors.py
        gdk/gdk_group.c
        gdk/gdk_heap.c
        gdk/gdk_logger.c
        gdk/gdk_private.h
        gdk/gdk_storage.c
        gdk/gdk_utils.c
        monetdb5/mal/mal.c
        monetdb5/mal/mal.h
        monetdb5/mal/mal_interpreter.c
        monetdb5/optimizer/opt_dataflow.c
        monetdb5/optimizer/opt_dataflow.h
        sql/backends/monet5/datacell/50_datacell.sql
        sql/backends/monet5/datacell/actuator.c
        sql/backends/monet5/datacell/datacell.c
        sql/backends/monet5/datacell/opt_datacell.c
        sql/backends/monet5/datacell/opt_datacell.h
        sql/backends/monet5/datacell/sensor.c
        sql/backends/monet5/sql.mx
        sql/backends/monet5/sql_optimizer.c
        sql/backends/monet5/sql_optimizer.h
        sql/backends/monet5/sql_result.c
        sql/backends/monet5/sql_scenario.c
        sql/common/sql_string.c
        sql/include/sql_catalog.h
        sql/storage/bat/bat_storage.c
        sql/storage/bat/bat_storage.h
        sql/storage/bat/bat_utils.c
        sql/storage/bat/bat_utils.h
        sql/storage/restrict/restrict_storage.c
        sql/storage/store.c
        sql/test/leaks/Tests/check0.stable.out
        sql/test/leaks/Tests/temp2.stable.out
        sql/test/leaks/Tests/temp3.stable.out
Branch: default
Log Message:

Merge with Feb2013 branch.


diffs (truncated from 3224 to 300 lines):

diff --git a/clients/mapiclient/tomograph.c b/clients/mapiclient/tomograph.c
--- a/clients/mapiclient/tomograph.c
+++ b/clients/mapiclient/tomograph.c
@@ -1004,7 +1004,7 @@ static void fprintf_time ( FILE *f, lng 
  * showing the units specified via TME */
 static void fprintf_tm ( FILE *f, lng time, int TME )
 {
-       int tail = 0, digits = 1;
+       int tail = 0, digits = 1, scale = 1;
        const char *fmt = NULL;
 
        if (TME & TME_DD && (tail || time >= US_DD)) {
@@ -1031,30 +1031,40 @@ static void fprintf_tm ( FILE *f, lng ti
        if (TME & TME_SS && (tail || time >= US_SS)) {
                fmt = tail ? "%02d%s" : "%d%s";
                fprintf(f, fmt, (int) (time / US_SS), (TME & TME_MS) ? "." : 
"s");
-               if (time / US_SS > 99)
+               if (time / US_SS > 99) {
+                       digits = 1;
+                       scale = 100;
+               } else if (time / US_SS > 9) {
                        digits = 2;
-               else
+                       scale = 10;
+               } else {
                        digits = 3;
+                       scale = 1;
+               }
                time %= US_SS;
                TME &= TME_MS;
                tail = 1;
        }
        if (TME & TME_MS && (tail || time >= US_MS)) {
                fmt = tail ? "%0*d%s" : "%*d%s";
-               fprintf(f, fmt, digits, (int) (time / US_MS), (TME & TME_US) ? 
"." : tail ? "s" : "ms");
-               if (time / US_MS > 99)
+               fprintf(f, fmt, digits, (int) (time / US_MS / scale), (TME & 
TME_US) ? "." : tail ? "s" : "ms");
+               if (time / US_MS > 99) {
                        digits = 1;
-               else if (time / US_MS > 9)
+                       scale = 100;
+               } else if (time / US_MS > 9) {
                        digits = 2;
-               else
+                       scale = 10;
+               } else {
                        digits = 3;
+                       scale = 1;
+               }
                time %= US_MS;
                TME &= TME_US;
                tail = 1;
        }
        if (TME & TME_US) {
                fmt = tail ? "%0*d%s" : "%*d%s";
-               fprintf(f, fmt, digits, (int) time, tail ? "ms" : "us");
+               fprintf(f, fmt, digits, (int) (time / scale), tail ? "ms" : 
"us");
        }
 }
 
diff --git a/clients/python2/monetdb/sql/connections.py 
b/clients/python2/monetdb/sql/connections.py
--- a/clients/python2/monetdb/sql/connections.py
+++ b/clients/python2/monetdb/sql/connections.py
@@ -49,6 +49,7 @@ class Connection(object):
             password=password, database=database, language="sql")
         self.set_autocommit(autocommit)
         self.set_sizeheader(True)
+        self.set_replysize(100)
 
     def close(self):
         """ Close the connection. The connection will be unusable from this
@@ -81,6 +82,9 @@ class Connection(object):
         self.command("Xsizeheader %s" % int(sizeheader))
         self.sizeheader = sizeheader
 
+    def set_replysize(self, replysize):
+        self.command("Xreply_size %s" % int(replysize))
+        self.replysize = replysize
 
     def commit(self):
         """
diff --git a/clients/python2/monetdb/sql/cursors.py 
b/clients/python2/monetdb/sql/cursors.py
--- a/clients/python2/monetdb/sql/cursors.py
+++ b/clients/python2/monetdb/sql/cursors.py
@@ -39,7 +39,7 @@ class Cursor(object):
 
         """This read/write attribute specifies the number of rows to
         fetch at a time with .fetchmany()"""
-        self.arraysize = 100
+        self.arraysize = connection.replysize
 
 
         """This read-only attribute specifies the number of rows that
@@ -164,7 +164,8 @@ class Cursor(object):
         operation = unicode(operation).encode('utf-8')
 
         # set the number of rows to fetch
-        self.connection.command('Xreply_size %s' % self.arraysize)
+        if self.arraysize != self.connection.replysize:
+            self.connection.set_replysize(self.arraysize)
 
         if operation == self.operation:
             #same operation, DBAPI mentioned something about reuse
diff --git a/clients/python3/monetdb/sql/connections.py 
b/clients/python3/monetdb/sql/connections.py
--- a/clients/python3/monetdb/sql/connections.py
+++ b/clients/python3/monetdb/sql/connections.py
@@ -50,6 +50,7 @@ class Connection(object):
             password=password, database=database, language="sql")
         self.set_autocommit(autocommit)
         self.set_sizeheader(True)
+        self.set_replysize(100)
 
     def close(self):
         """ Close the connection. The connection will be unusable from this
@@ -82,6 +83,9 @@ class Connection(object):
         self.command("Xsizeheader %s" % int(sizeheader))
         self.sizeheader = sizeheader
 
+    def set_replysize(self, replysize):
+        self.command("Xreply_size %s" % int(replysize))
+        self.replysize = replysize
 
     def commit(self):
         """
diff --git a/clients/python3/monetdb/sql/cursors.py 
b/clients/python3/monetdb/sql/cursors.py
--- a/clients/python3/monetdb/sql/cursors.py
+++ b/clients/python3/monetdb/sql/cursors.py
@@ -40,7 +40,7 @@ class Cursor(object):
 
         """This read/write attribute specifies the number of rows to
         fetch at a time with .fetchmany()"""
-        self.arraysize = 100
+        self.arraysize = connection.replysize
 
 
         """This read-only attribute specifies the number of rows that
@@ -165,7 +165,8 @@ class Cursor(object):
         #operation = str(operation).encode('utf-8')
 
         # set the number of rows to fetch
-        self.connection.command('Xreply_size %s' % self.arraysize)
+        if self.arraysize != self.connection.replysize:
+            self.connection.set_replysize(self.arraysize)
 
         if operation == self.operation:
             #same operation, DBAPI mentioned something about reuse
diff --git a/gdk/gdk_group.c b/gdk/gdk_group.c
--- a/gdk/gdk_group.c
+++ b/gdk/gdk_group.c
@@ -70,33 +70,83 @@
  * At the MAL level, the multigroup function would perform the dynamic
  * optimization.
  */
+#define GRPnotfound()                                                  \
+       do {                                                            \
+               /* no equal found: start new group */                   \
+               if (ngrp == maxgrps) {                                  \
+                       /* we need to extend extents and histo bats, */ \
+                       /* do it at most once */                        \
+                       maxgrps = BATcount(b);                          \
+                       if (extents) {                                  \
+                               BATsetcount(en, ngrp);                  \
+                               en = BATextend(en, maxgrps);            \
+                               exts = (oid *) Tloc(en, BUNfirst(en));  \
+                       }                                               \
+                       if (histo) {                                    \
+                               BATsetcount(hn, ngrp);                  \
+                               hn = BATextend(hn, maxgrps);            \
+                               cnts = (wrd *) Tloc(hn, BUNfirst(hn));  \
+                       }                                               \
+               }                                                       \
+               if (extents)                                            \
+                       exts[ngrp] = b->hseqbase + (oid) (p - r);       \
+               if (histo)                                              \
+                       cnts[ngrp] = 1;                                 \
+               ngrps[p - r] = ngrp;                                    \
+               ngrp++;                                                 \
+       } while (0)
+
 #define GRPhashloop(TYPE)                                              \
        do {                                                            \
-               v = BUNtail(bi, p);                                     \
-               if (grps) {                                             \
-                       prb = hash_##TYPE(hs, v) ^ hash_oid(hs, &grps[p-r]); \
-                       for (hb = hs->hash[prb];                        \
-                            hb != BUN_NONE;                            \
-                            hb = hs->link[hb]) {                       \
-                               if (grps[hb - r] == grps[p - r] &&      \
-                                   *(TYPE *) v == *(TYPE *) BUNtail(bi, hb)){ \
-                                       ngrps[p - r] = ngrps[hb - r];   \
-                                       if (histo)                      \
-                                               cnts[ngrps[hb - r]]++;  \
-                                       break;                          \
+               TYPE *w = (TYPE *) Tloc(b, 0);                          \
+               for (r = BUNfirst(b), p = r, q = r + BATcount(b); p < q; p++) { 
\
+                       if (gc) {                                       \
+                               prb = hash_##TYPE(hs, &w[p]);           \
+                               for (hb = hs->hash[prb];                \
+                                    hb != BUN_NONE &&                  \
+                                     grps[hb - r] == grps[p - r];      \
+                                    hb = hs->link[hb]) {               \
+                                       if (w[p] == w[hb]) {            \
+                                               ngrps[p - r] = ngrps[hb - r]; \
+                                               if (histo)              \
+                                                       cnts[ngrps[hb - r]]++; \
+                                               break;                  \
+                                       }                               \
+                               }                                       \
+                       } else if (grps) {                              \
+                               BUN hv = hash_##TYPE(hs, &w[p]);        \
+                               BUN hg = hash_oid(hs, &grps[p-r]);      \
+                               prb = ((hv << bits) ^ hg) & hs->mask;   \
+                               for (hb = hs->hash[prb];                \
+                                    hb != BUN_NONE;                    \
+                                    hb = hs->link[hb]) {               \
+                                       if (grps[hb - r] == grps[p - r] && \
+                                           w[p] == w[hb]) {            \
+                                               ngrps[p - r] = ngrps[hb - r]; \
+                                               if (histo)              \
+                                                       cnts[ngrps[hb - r]]++; \
+                                               break;                  \
+                                       }                               \
+                               }                                       \
+                       } else {                                        \
+                               prb = hash_##TYPE(hs, &w[p]);           \
+                               for (hb = hs->hash[prb];                \
+                                    hb != BUN_NONE;                    \
+                                    hb = hs->link[hb]) {               \
+                                       if (w[p] == w[hb]) {            \
+                                               ngrps[p - r] = ngrps[hb - r]; \
+                                               if (histo)              \
+                                                       cnts[ngrps[hb - r]]++; \
+                                               break;                  \
+                                       }                               \
                                }                                       \
                        }                                               \
-               } else {                                                \
-                       prb = hash_##TYPE(hs, v);                       \
-                       for (hb = hs->hash[prb];                        \
-                            hb != BUN_NONE;                            \
-                            hb = hs->link[hb]) {                       \
-                               if (*(TYPE *) v == *(TYPE *) BUNtail(bi, hb)){ \
-                                       ngrps[p - r] = ngrps[hb - r];   \
-                                       if (histo)                      \
-                                               cnts[ngrps[hb - r]]++;  \
-                                       break;                          \
-                               }                                       \
+                       if (hb == BUN_NONE ||                           \
+                           (gc && grps[hb - r] != grps[p - r])) {      \
+                               GRPnotfound();                          \
+                               /* enter new group into hash table */   \
+                               hs->link[p] = hs->hash[prb];            \
+                               hs->hash[prb] = p;                      \
                        }                                               \
                }                                                       \
        } while (0)
@@ -303,47 +353,27 @@ BATgroup_internal(BAT **groups, BAT **ex
                if (grps)
                        prev = *grps++;
                pv = BUNtail(bi, BUNfirst(b));
-               *ngrps++ = ngrp;
+               ngrps[0] = ngrp;
+               ngrp++;
                if (extents)
-                       *exts++ = b->hseqbase;
+                       exts[0] = b->hseqbase;
                if (histo)
-                       *cnts = 1;
+                       cnts[0] = 1;
                for (r = BUNfirst(b), p = r + 1, q = r + BATcount(b);
                     p < q;
                     p++) {
                        v = BUNtail(bi, p);
                        if ((grps && *grps != prev) || cmp(pv, v) != 0) {
-                               ngrp++;
-                               if (ngrp == maxgrps) {
-                                       /* we need to extend extents
-                                        * and histo bats, do it
-                                        * once */
-                                       maxgrps = BATcount(b);
-                                       if (extents) {
-                                               BATsetcount(en, ngrp);
-                                               en = BATextend(en, maxgrps);
-                                               exts = (oid *) Tloc(en, 
BUNfirst(en) + ngrp);
-                                       }
-                                       if (histo) {
-                                               BATsetcount(hn, ngrp);
-                                               hn = BATextend(hn, maxgrps);
-                                               cnts = (wrd *) Tloc(hn, 
BUNfirst(hn) + ngrp - 1);
-                                       }
-                               }
-                               if (extents)
-                                       *exts++ = b->hseqbase + (oid) (p - r);
+                               GRPnotfound();
+                       } else {
+                               ngrps[p - r] = ngrp - 1;
                                if (histo)
-                                       *++cnts = 1;
-                       } else if (histo) {
-                               *cnts += 1;
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to