Changeset: 3a928bfe717b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3a928bfe717b
Modified Files:
        MonetDB.spec
        gdk/gdk_group.c
        gdk/gdk_heap.c
        gdk/gdk_posix.c
Branch: default
Log Message:

Merge with Feb2013 branch.


diffs (truncated from 425 to 300 lines):

diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -478,8 +478,10 @@ fi
 Summary: MonetDB5 SQL server modules
 Group: Applications/Databases
 Requires: MonetDB5-server = %{version}-%{release}
+%if %{?rhel:0}%{!?rhel:1}
 # for systemd-tmpfiles
 Requires: systemd-units
+%endif
 Obsoletes: MonetDB-SQL-devel
 Obsoletes: %{name}-SQL
 
@@ -492,16 +494,24 @@ accelerators.  It also has an SQL fronte
 This package contains the SQL frontend for MonetDB5.  If you want to
 use SQL with MonetDB, you will need to install this package.
 
+%if %{?rhel:0}%{!?rhel:1}
 %post SQL-server5
 systemd-tmpfiles --create %{_sysconfdir}/tmpfiles.d/monetdbd.conf
+%endif
 
 %files SQL-server5
 %defattr(-,root,root)
 %{_bindir}/monetdb
 %{_bindir}/monetdbd
 %dir %attr(775,monetdb,monetdb) %{_localstatedir}/log/monetdb
+%if %{?rhel:0}%{!?rhel:1}
 # Fedora 15 and newer
 %{_sysconfdir}/tmpfiles.d/monetdbd.conf
+%else
+# RedHat Enterprise Linux
+%dir %attr(775,monetdb,monetdb) %{_localstatedir}/run/monetdb
+%exclude %{_sysconfdir}/tmpfiles.d/monetdbd.conf
+%endif
 %config(noreplace) %{_localstatedir}/monetdb5/dbfarm/.merovingian_properties
 %{_libdir}/monetdb5/autoload/*_sql.mal
 %{_libdir}/monetdb5/lib_sql.so
diff --git a/gdk/gdk_group.c b/gdk/gdk_group.c
--- a/gdk/gdk_group.c
+++ b/gdk/gdk_group.c
@@ -106,13 +106,21 @@
                                     hb != BUN_NONE &&                  \
                                      grps[hb - r] == grps[p - r];      \
                                     hb = hs->link[hb]) {               \
+                                       assert(hs->link[hb] == BUN_NONE \
+                                              || hs->link[hb] < hb);   \
                                        if (w[p] == w[hb]) {            \
-                                               ngrps[p - r] = ngrps[hb - r]; \
+                                               oid grp = ngrps[hb - r]; \
+                                               ngrps[p - r] = grp;     \
                                                if (histo)              \
-                                                       cnts[ngrps[hb - r]]++; \
+                                                       cnts[grp]++;    \
+                                               if (gn->tsorted &&      \
+                                                   grp != ngrp - 1)    \
+                                                       gn->tsorted = 0; \
                                                break;                  \
                                        }                               \
                                }                                       \
+                               if (grps[hb - r] != grps[p - r])        \
+                                       hb = BUN_NONE;                  \
                        } else if (grps) {                              \
                                BUN hv = hash_##TYPE(hs, &w[p]);        \
                                BUN hg = hash_oid(hs, &grps[p-r]);      \
@@ -122,9 +130,13 @@
                                     hb = hs->link[hb]) {               \
                                        if (grps[hb - r] == grps[p - r] && \
                                            w[p] == w[hb]) {            \
-                                               ngrps[p - r] = ngrps[hb - r]; \
+                                               oid grp = ngrps[hb - r]; \
+                                               ngrps[p - r] = grp;     \
                                                if (histo)              \
-                                                       cnts[ngrps[hb - r]]++; \
+                                                       cnts[grp]++;    \
+                                               if (gn->tsorted &&      \
+                                                   grp != ngrp - 1)    \
+                                                       gn->tsorted = 0; \
                                                break;                  \
                                        }                               \
                                }                                       \
@@ -134,15 +146,18 @@
                                     hb != BUN_NONE;                    \
                                     hb = hs->link[hb]) {               \
                                        if (w[p] == w[hb]) {            \
-                                               ngrps[p - r] = ngrps[hb - r]; \
+                                               oid grp = ngrps[hb - r]; \
+                                               ngrps[p - r] = grp;     \
                                                if (histo)              \
-                                                       cnts[ngrps[hb - r]]++; \
+                                                       cnts[grp]++;    \
+                                               if (gn->tsorted &&      \
+                                                   grp != ngrp - 1)    \
+                                                       gn->tsorted = 0; \
                                                break;                  \
                                        }                               \
                                }                                       \
                        }                                               \
-                       if (hb == BUN_NONE ||                           \
-                           (gc && grps[hb - r] != grps[p - r])) {      \
+                       if (hb == BUN_NONE) {                           \
                                GRPnotfound();                          \
                                /* enter new group into hash table */   \
                                hs->link[p] = hs->hash[prb];            \
@@ -413,7 +428,8 @@ BATgroup_internal(BAT **groups, BAT **ex
                                                ngrps[p - r] = grp;
                                                if (histo)
                                                        cnts[grp]++;
-                                               if (grp != ngrp - 1)
+                                               if (gn->tsorted &&
+                                                   grp != ngrp - 1)
                                                        gn->tsorted = 0;
                                                break;
                                        }
@@ -448,6 +464,7 @@ BATgroup_internal(BAT **groups, BAT **ex
                                  h ? BATgetId(h) : "NULL", h ? BATcount(h) : 0,
                                  subsorted, gc ? " (g clustered)" : "");
                hs = b->T->hash;
+               gn->tsorted = 1; /* be optimistic */
                for (r = BUNfirst(b), p = r, q = r + BATcount(b); p < q; p++) {
                        v = BUNtail(bi, p);
                        /* this loop is similar, but not equal, to
@@ -461,28 +478,43 @@ BATgroup_internal(BAT **groups, BAT **ex
                         * backwards through BAT */
                        for (hb = hs->hash[HASHprobe(hs, v)];
                             hb != BUN_NONE && hb >= p;
-                            hb = hs->link[hb])
+                            hb = hs->link[hb]) {
+                               assert(hs->link[hb] == BUN_NONE
+                                      || hs->link[hb] < hb);
+                       }
                                ;
                        if (gc) {
                                for (;
                                     hb != BUN_NONE && grps[hb - r] == grps[p - 
r];
                                     hb = hs->link[hb]) {
+                                       assert(hs->link[hb] == BUN_NONE
+                                              || hs->link[hb] < hb);
                                        if (cmp(v, BUNtail(bi, hb)) == 0) {
-                                               ngrps[p - r] = ngrps[hb - r];
+                                               oid grp = ngrps[hb - r];
+                                               ngrps[p - r] = grp;
                                                if (histo)
-                                                       cnts[ngrps[hb - r]]++;
+                                                       cnts[grp]++;
+                                               if (gn->tsorted &&
+                                                   grp != ngrp - 1)
+                                                       gn->tsorted = 0;
                                                break;
                                        }
                                }
+                               if (grps[hb - r] != grps[p - r])
+                                       hb = BUN_NONE;
                        } else if (grps) {
                                for (;
                                     hb != BUN_NONE;
                                     hb = hs->link[hb]) {
                                        if (grps[hb - r] == grps[p - r] &&
                                            cmp(v, BUNtail(bi, hb)) == 0) {
-                                               ngrps[p - r] = ngrps[hb - r];
+                                               oid grp = ngrps[hb - r];
+                                               ngrps[p - r] = grp;
                                                if (histo)
-                                                       cnts[ngrps[hb - r]]++;
+                                                       cnts[grp]++;
+                                               if (gn->tsorted &&
+                                                   grp != ngrp - 1)
+                                                       gn->tsorted = 0;
                                                break;
                                        }
                                }
@@ -491,18 +523,21 @@ BATgroup_internal(BAT **groups, BAT **ex
                                     hb != BUN_NONE;
                                     hb = hs->link[hb]) {
                                        if (cmp(v, BUNtail(bi, hb)) == 0) {
-                                               ngrps[p - r] = ngrps[hb - r];
+                                               oid grp = ngrps[hb - r];
+                                               ngrps[p - r] = grp;
                                                if (histo)
-                                                       cnts[ngrps[hb - r]]++;
+                                                       cnts[grp]++;
+                                               if (gn->tsorted &&
+                                                   grp != ngrp - 1)
+                                                       gn->tsorted = 0;
                                                break;
                                        }
                                }
                        }
-                       if (hb == BUN_NONE || (gc && grps[hb - r] != grps[p - 
r])) {
+                       if (hb == BUN_NONE) {
                                GRPnotfound();
                        }
                }
-               gn->tsorted = BATcount(gn) <= 1;
        } else {
                bit gc = g && (g->tsorted || g->trevsorted);
                const char *nme;
@@ -557,6 +592,7 @@ BATgroup_internal(BAT **groups, BAT **ex
                        goto error;
                }
 
+               gn->tsorted = 1; /* be optimistic */
                switch (ATOMstorage(hs->type)) {
                case TYPE_bte:
                        GRPhashloop(bte);
@@ -584,13 +620,21 @@ BATgroup_internal(BAT **groups, BAT **ex
                                        for (hb = hs->hash[prb];
                                             hb != BUN_NONE && grps[hb - r] == 
grps[p - r];
                                             hb = hs->link[hb]) {
+                                               assert(hs->link[hb] == BUN_NONE
+                                                      || hs->link[hb] < hb);
                                                if (cmp(v, BUNtail(bi, hb)) == 
0) {
-                                                       ngrps[p - r] = ngrps[hb 
- r];
+                                                       oid grp = ngrps[hb - r];
+                                                       ngrps[p - r] = grp;
                                                        if (histo)
-                                                               cnts[ngrps[hb - 
r]]++;
+                                                               cnts[grp]++;
+                                                       if (gn->tsorted &&
+                                                           grp != ngrp - 1)
+                                                               gn->tsorted = 0;
                                                        break;
                                                }
                                        }
+                                       if (grps[hb - r] != grps[p - r])
+                                               hb = BUN_NONE;
                                } else if (grps) {
                                        BUN hv = hash_any(hs, v);
                                        BUN hg = hash_oid(hs, &grps[p-r]);
@@ -600,9 +644,13 @@ BATgroup_internal(BAT **groups, BAT **ex
                                             hb = hs->link[hb]) {
                                                if (grps[hb - r] == grps[p - r] 
&&
                                                    cmp(v, BUNtail(bi, hb)) == 
0) {
-                                                       ngrps[p - r] = ngrps[hb 
- r];
+                                                       oid grp = ngrps[hb - r];
+                                                       ngrps[p - r] = grp;
                                                        if (histo)
-                                                               cnts[ngrps[hb - 
r]]++;
+                                                               cnts[grp]++;
+                                                       if (gn->tsorted &&
+                                                           grp != ngrp - 1)
+                                                               gn->tsorted = 0;
                                                        break;
                                                }
                                        }
@@ -612,14 +660,18 @@ BATgroup_internal(BAT **groups, BAT **ex
                                             hb != BUN_NONE;
                                             hb = hs->link[hb]) {
                                                if (cmp(v, BUNtail(bi, hb)) == 
0) {
-                                                       ngrps[p - r] = ngrps[hb 
- r];
+                                                       oid grp = ngrps[hb - r];
+                                                       ngrps[p - r] = grp;
                                                        if (histo)
-                                                               cnts[ngrps[hb - 
r]]++;
+                                                               cnts[grp]++;
+                                                       if (gn->tsorted &&
+                                                           grp != ngrp - 1)
+                                                               gn->tsorted = 0;
                                                        break;
                                                }
                                        }
                                }
-                               if (hb == BUN_NONE || (gc && grps[hb - r] != 
grps[p - r])) {
+                               if (hb == BUN_NONE) {
                                        GRPnotfound();
                                        /* enter new group into hash table */
                                        hs->link[p] = hs->hash[prb];
@@ -634,7 +686,6 @@ BATgroup_internal(BAT **groups, BAT **ex
                GDKfree(hp);
                GDKfree(hs);
                GDKfree(ext);
-               gn->tsorted = BATcount(gn) <= 1;
        }
        if (extents) {
                BATsetcount(en, (BUN) ngrp);
diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c
--- a/gdk/gdk_heap.c
+++ b/gdk/gdk_heap.c
@@ -113,17 +113,25 @@ HEAPcacheAdd(void *base, size_t maxsz, c
 
        MT_lock_set(&HEAPcacheLock, "HEAPcache_init");
        if (hc && free_file && fn && storage == STORE_MMAP && hc->used < 
hc->sz) {
-               if (hc->used < hc->sz) {
-                       heap_cache_e *e = hc->hc+hc->used;
+               heap_cache_e *e = hc->hc+hc->used;
 
-                       e->base = base;
-                       e->maxsz = maxsz;
-                       snprintf(e->fn, PATHLENGTH, "%d", hc->used);
-                       GDKunlink(HCDIR, e->fn, NULL);
-                       GDKmove(BATDIR, fn, NULL, HCDIR, e->fn, NULL);
+               e->base = base;
+               e->maxsz = maxsz;
+               snprintf(e->fn, PATHLENGTH, "%d", hc->used);
+               GDKunlink(HCDIR, e->fn, NULL);
+               added = 1;
+               if (GDKmove(BATDIR, fn, NULL, HCDIR, e->fn, NULL) < 0) {
+                       /* try to create the directory, if that was
+                        * the problem */
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to