Update of /cvsroot/monetdb/MonetDB5/src/modules/kernel
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv28669/src/modules/kernel

Modified Files:
        group.mx 
Log Message:
CTsubhisto returned a bat of type idxentry,int but accessed only the
oid (hcur) of the idxentry struct. Therefor it changed the type (hack)
into TYPE_oid. This gave problems in the batcache (it returned a
bat with types of incorrect size). 
Now the idxentry type is no longer used (removed) but simply 2 bats.
The waisted space is freed at the end of the subhisto function.

this fixes the failing xtables test 


Index: group.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/modules/kernel/group.mx,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -d -r1.97 -r1.98
--- group.mx    25 Oct 2007 19:17:34 -0000      1.97
+++ group.mx    7 Nov 2007 21:18:36 -0000       1.98
@@ -238,7 +238,6 @@
 #include "group.h"
 #include "algebra.h"
 static int TYPE_mapentry;
-static int TYPE_idxentry;
 
 
 int
@@ -321,13 +320,6 @@
 #define tst_derive_unclustered(eq,p,t) (e->hcur == hcur && eq(p, tcur, t))
 #define tst_derive_clustered(eq,p,t)   ((samecluster = e->hcur == hcur) && 
eq(p, tcur, t))
 
-/* NOTE: the first two fields of idxentry_t and mapentry_t MUST be the
-   same */
-typedef struct {
-       oid hcur;               /* old group id */
-       hash_t link;            /* hash link */
-} idxentry_t;
-
 typedef struct {
        oid hcur;               /* old group id */
        hash_t link;            /* hash link */
@@ -926,7 +918,12 @@
        size_t size = BATcount(dom);
        hash_t yy, mask, *hash = NULL;
        BUN r, p, q;
-       BAT *bn = BATnew(TYPE_idxentry, TYPE_int, size);
+       BAT *bn = BATnew(TYPE_oid, TYPE_int, size);
+       BAT *lnk = BATnew(TYPE_oid, TYPE_void, size);
+       int *hcnt = (int*)Tloc(bn, BUNfirst(bn));
+       oid *hcur = (oid*)Hloc(bn, BUNfirst(bn));
+       oid *link = (oid*)Hloc(lnk, BUNfirst(lnk));
+       oid *hdom = (oid*)Hloc(dom, 0);
 
        if (bn == NULL)
                return GDK_FAIL;
@@ -947,24 +944,21 @@
        mask--;
 
        /* insert all values in the hash table, and in bn with count zero */
-       r = BUNfirst(bn);
+       r = 0;
        yy = 0;
        BATloop(dom, p, q) {
-               oid v = *(oid *) Hloc(dom, p);
+               oid v = hdom[p];
                hash_t c = v & mask;
 
-               ((idxentry_t *) Hloc(bn, r))->hcur = v;
-               ((idxentry_t *) Hloc(bn, r))->link = hash[c];
-               *(int *) Tloc(bn, r) = 0;
+               hcur[r] = v;
+               link[r] = hash[c];
+               hcnt[r] = 0;
                r++;
                hash[c] = yy;
                yy++;
        }
        BATsetcount(bn, r);
        bn->tsorted = 0;
-       bn->htype = BATmirror(bn)->ttype = TYPE_oid;
-       /* assert(offsetof(idxentry_t,hcur) == 0);
-       ALIGNsetH(bn, dom); */
 
        /* add the counts for this selection using the hash table */
        BATloop(grp, p, q) {
@@ -972,10 +966,10 @@
                        oid v = *(oid *) Tloc(grp, p);
                        hash_t c = v & mask;
 
-                       for (yy = hash[c]; yy != HASH_MAX; yy = ((idxentry_t *) 
Hloc(bn, r))->link) {
+                       for (yy = hash[c]; yy != HASH_MAX; yy = link[r]) {
                                r = yy;
-                               if (((idxentry_t *) Hloc(bn, r))->hcur == v) {
-                                       *(int *) Tloc(bn, r) += 1;
+                               if (hcur[r] == v) {
+                                       hcnt[r]++;
                                        break;
                                }
                        }
@@ -984,6 +978,7 @@
 
        }
        GDKfree(hash);
+       BBPreclaim(lnk);
        if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);
        *ret = bn;
        return GDK_SUCCEED;
@@ -1223,7 +1218,6 @@
 {
        /* printf("#init group\n"); */
        TYPE_mapentry = malAtomFixed(sizeof(mapentry_t), sizeof(oid), 
"mapentry");
-       TYPE_idxentry = malAtomFixed(sizeof(idxentry_t), sizeof(oid), 
"idxentry");
        return MAL_SUCCEED;
 }
 


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins

Reply via email to