Changeset: 0a6235e74915 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0a6235e74915
Modified Files:
        gdk/gdk_cbp.c
        gdk/gdk_cbp.h
        monetdb5/mal/mal_authorize.c
        monetdb5/mal/mal_box.c
        monetdb5/mal/mal_recycle.c
        monetdb5/modules/atoms/str.c
        monetdb5/modules/atoms/url.c
        monetdb5/modules/atoms/url.h
        monetdb5/modules/kernel/aggr.mx
        monetdb5/modules/kernel/algebra.mx
        monetdb5/modules/kernel/array.mx
        monetdb5/modules/kernel/colcalc.mx
        monetdb5/modules/kernel/colcast.mx
        monetdb5/modules/kernel/colcolor.mx
        monetdb5/modules/kernel/colifthen.mx
        monetdb5/modules/kernel/colmmath.mx
        monetdb5/modules/kernel/colmtime.mx
        monetdb5/modules/kernel/colstr.mx
        monetdb5/modules/kernel/column.mx
        monetdb5/modules/kernel/group.mx
        monetdb5/modules/kernel/kprelude.mx
        monetdb5/modules/kernel/microbenchmark.c
        monetdb5/modules/kernel/status.mx
        monetdb5/modules/mal/attach.c
        monetdb5/modules/mal/cbp.c
        monetdb5/modules/mal/clients.c
        monetdb5/modules/mal/extensions.c
        monetdb5/modules/mal/factories.c
        monetdb5/modules/mal/groupby.c
        monetdb5/modules/mal/inout.c
        monetdb5/modules/mal/inspect.c
        monetdb5/modules/mal/mat.c
        monetdb5/modules/mal/mdb.c
        monetdb5/modules/mal/mkey.c
        monetdb5/modules/mal/pcrelib.c
        monetdb5/modules/mal/pqueue.mx
        monetdb5/modules/mal/remote.c
        monetdb5/modules/mal/replication.c
        monetdb5/modules/mal/tokenizer.c
        monetdb5/modules/mal/xmlcolumn.c
        monetdb5/modules/mal/zorder.c
        monetdb5/optimizer/opt_dictionary.c
        monetdb5/optimizer/opt_joinpath.c
        monetdb5/optimizer/opt_mapreduce.c
        monetdb5/optimizer/opt_pipes.c
        monetdb5/optimizer/opt_prejoin.c
Branch: headless
Log Message:

Interface to CBPkeepref/releasref
Simplified by moving details on cache location down.


diffs (truncated from 5973 to 300 lines):

diff --git a/gdk/gdk_cbp.c b/gdk/gdk_cbp.c
--- a/gdk/gdk_cbp.c
+++ b/gdk/gdk_cbp.c
@@ -1908,11 +1908,12 @@
  * the CBP management actions, such as garbage collecting the bats.
  * [first step, initiate code change]
  */
-void
-CBPkeepref(bat i)
+int
+CBPkeepref(COL *b)
 {
+       int i = b->batCacheid;
        if (i == bat_nil)
-               return;
+               return 0;
        assert(i > 0);
        if (CBPcheck(i, "CBPkeepref")) {
                int lock = locked_by ? MT_getpid() != locked_by : 1;
@@ -1921,12 +1922,14 @@
                assert(CBP_refs(i));
                decref(i, FALSE, FALSE, lock);
        }
+       return i;
 }
 
 void
-CBPreleaselref(bat i)
+CBPreleaselref(COL *b)
 {
        int lock = locked_by ? MT_getpid() != locked_by : 1;
+       int i = b->batCacheid;
 
        if (i == bat_nil)
                return;
@@ -1936,9 +1939,10 @@
 }
 
 void
-CBPreleaseref(bat i)
+CBPreleaseref(COL *b)
 {
        int lock = locked_by ? MT_getpid() != locked_by : 1;
+       int i = b->batCacheid;
 
        if (i == bat_nil)
                return;
diff --git a/gdk/gdk_cbp.h b/gdk/gdk_cbp.h
--- a/gdk/gdk_cbp.h
+++ b/gdk/gdk_cbp.h
@@ -74,9 +74,9 @@
 gdk_export int CBPrecover(void);
 gdk_export int CBPsync(int cnt, bat *subcommit);
 gdk_export int CBPincref(bat b, int logical);
-gdk_export void CBPkeepref(bat i);
-gdk_export void CBPreleaseref(bat i);
-gdk_export void CBPreleaselref(bat i);
+gdk_export int CBPkeepref(COL *b);
+gdk_export void CBPreleaseref(COL *b);
+gdk_export void CBPreleaselref(COL *b);
 gdk_export int CBPdecref(bat b, int logical);
 gdk_export void CBPshare(bat b);
 gdk_export void CBPunshare(bat b);
diff --git a/monetdb5/mal/mal_authorize.c b/monetdb5/mal/mal_authorize.c
--- a/monetdb5/mal/mal_authorize.c
+++ b/monetdb5/mal/mal_authorize.c
@@ -203,7 +203,7 @@
 
                /* destroy old bat */
                COLmode(b, TRANSIENT);
-               CBPreleaseref(b->batCacheid);
+               CBPreleaseref(b);
 
                /* commit the new situation */
                s[0] = 0;
@@ -429,7 +429,7 @@
                if (b->htype != TYPE_str) {
                        COLundo(user);
                        COLundo(pass);
-                       CBPreleaseref(b->batCacheid);
+                       CBPreleaseref(b);
                        throw(ILLARG, "addUser", INTERNAL_COL_HEAD);
                }
 
@@ -441,7 +441,7 @@
                                BUNins(scen, id, BUNhead(bi, p), TRUE);
                        }
                }
-               CBPreleaseref(b->batCacheid);
+               CBPreleaseref(b);
        }
 
        /* make the stuff persistent */
diff --git a/monetdb5/mal/mal_box.c b/monetdb5/mal/mal_box.c
--- a/monetdb5/mal/mal_box.c
+++ b/monetdb5/mal/mal_box.c
@@ -562,7 +562,7 @@
                if (malbox[i] != NULL) {
                        BUNappend(b, malbox[i]->name, FALSE);
                }
-       CBPkeepref(*bid = b->batCacheid);
+       *bid = CBPkeepref(b);
        return MAL_SUCCEED;
 }
 
@@ -673,7 +673,7 @@
                                        GDKfree(tt);
                                        COLsave(b);
                                } 
-                               CBPreleaseref(b->batCacheid);
+                               CBPreleaseref(b);
                        }
                } else {
                        tnme = getTypeName(getVarType(box->sym,i));
diff --git a/monetdb5/mal/mal_recycle.c b/monetdb5/mal/mal_recycle.c
--- a/monetdb5/mal/mal_recycle.c
+++ b/monetdb5/mal/mal_recycle.c
@@ -1489,7 +1489,6 @@
                        bn = COLselect_(bs, &qry->low, ovhgh, qry->li, hi);
                        if (b == NULL) {
                                b = bn;
-                       /*                      CBPkeepref(b->batCacheid); */
                        } else {
                                b = COLappend(b, bn, TRUE);
                                CBPunfix(bn->batCacheid);
@@ -1516,7 +1515,6 @@
                        bn = COLselect_(bs, ovlow, &qry->hgh, li, qry->hi);
                        if (b == NULL) {
                                b = bn;
-                       /*                      CBPkeepref(b->batCacheid); */
                        } else {
                                b = COLappend(b, bn, TRUE);
                                CBPunfix(bn->batCacheid);
@@ -1592,7 +1590,6 @@
        else 
                b = computePart(qry,sol,0,scnt-1,FALSE, b); 
 
-       /* CBPkeepref(b->batCacheid);  ?? */
        return b;
 }
 
@@ -2011,7 +2008,7 @@
                COLseqbase(bn, lval);
                ratio = (dbl)COLcount(bn)/(dbl)scnt;
                VALset(&s->stk[getArg(p,0)], TYPE_bat, &bn->batCacheid);
-               CBPkeepref( bn->batCacheid);
+               CBPkeepref( bn);
 
                recycleBlk->profiler[pc].counter++;
                recycleBlk->profiler[pc].clk = GDKusec();
diff --git a/monetdb5/modules/atoms/str.c b/monetdb5/modules/atoms/str.c
--- a/monetdb5/modules/atoms/str.c
+++ b/monetdb5/modules/atoms/str.c
@@ -82,7 +82,7 @@
  * These characteristics make UTF-8 an attractive format for upgrading an 
ASCII-oriented computer
  * program towards one that supports Unicode. That is why we use UTF-8 in 
Monet.
  * 
- * For Monet, UTF-8 mostly has no consequences, as strings stored in BATs are 
regarded as data,
+ * For Monet, UTF-8 mostly has no consequences, as strings stored in columns 
are regarded as data,
  * and it does not matter for the database kernel whether the zero-terminated 
byte sequence it is
  * processing has UTF-8 or Latin-1 semantics. This module is the only place 
where explicit string
  * functionality is located. We {\bf do} have to adapt the behavior of the MIL 
length(), search(),
@@ -99,7 +99,7 @@
  * complex casing: http://www.unicode.org/Public/UNIDATA/SpecialCasing.txt
  * \end{verbatim}
  * 
- * The Unicode case conversion implementation in Monet fills a mapping BAT of 
int,int combinations,
+ * The Unicode case conversion implementation in Monet fills a mapping column 
of int,int combinations,
  * in which we perform high-performance hash-lookup (all code inlined).
 */
 /* This table was generated from the Unicode 5.0.0 spec.
@@ -1165,25 +1165,27 @@
                *(A2)++ = 0x80 | ((A1) & 0x3F); \
        }
 
-static BAT *UTF8_toupperBat = NULL, *UTF8_tolowerBat;
+static COL *UTF8_toupperCol = NULL, *UTF8_tolowerCol;
 
 bat *
 strPrelude(void)
 {
-       if (!UTF8_toupperBat) {
+       if (!UTF8_toupperCol) {
                int i = UTF8_CONVERSIONS;
 
-               UTF8_toupperBat = BATnew(TYPE_int, TYPE_int, UTF8_CONVERSIONS);
-               if (UTF8_toupperBat == NULL)
+               UTF8_toupperCol = COLnew(TYPE_int, UTF8_CONVERSIONS);
+               UTF8_tolowerCol = COLnew(TYPE_int, UTF8_CONVERSIONS);
+               if (UTF8_toupperCol == NULL)
                        return NULL;
                while (--i >= 0) {
                        int lower = UTF8_lower_upper[i].lower;
                        int upper = UTF8_lower_upper[i].upper;
 
-                       BUNins(UTF8_toupperBat, &lower, &upper, FALSE);
+                       BUNappend(UTF8_toupperCol, &upper, FALSE);
+                       BUNappend(UTF8_tolowerCol, &lower, FALSE);
                }
-               UTF8_tolowerBat = BATmirror(UTF8_toupperBat);
-               COLname(UTF8_toupperBat, "monet_unicode_case");
+               COLname(UTF8_tolowerCol, "monet_unicode_case_lower");
+               COLname(UTF8_tolowerCol, "monet_unicode_case_upper");
        }
        return NULL;
 }
@@ -1191,8 +1193,10 @@
 str 
 strEpilogue(void)
 {
-       if (UTF8_toupperBat)
-               CBPunfix(UTF8_toupperBat->batCacheid);
+       if (UTF8_toupperCol){
+               CBPunfix(UTF8_toupperCol->batCacheid);
+               CBPunfix(UTF8_tolowerCol->batCacheid);
+       }
        return MAL_SUCCEED;
 }
 
@@ -1575,7 +1579,7 @@
 int
 strLower(str *res, str s)
 {
-       COLiter UTF8_tolowerBati = col_iterator(UTF8_tolowerBat);
+       COLiter UTF8_tolowerColi = col_iterator(UTF8_tolowerCol);
        size_t len = strlen(s);
        unsigned char *dst, *src = (unsigned char *) s, *end = (unsigned char 
*) (src + len);
 
@@ -1586,7 +1590,7 @@
                int c;
 
                UTF8_GETCHAR(c,src);
-               UTF8_CONV(c,UTF8_tolowerBati);
+               UTF8_CONV(c,UTF8_tolowerColi);
                if (dst + 6 > (unsigned char *) *res + len) {
                        /* not guaranteed to fit, so allocate more space;
                           also allocate enough for the rest of the source */
@@ -1604,7 +1608,7 @@
 int
 strUpper(str *res, str s)
 {
-       COLiter UTF8_toupperBati = col_iterator(UTF8_toupperBat);
+       COLiter UTF8_toupperColi = col_iterator(UTF8_toupperCol);
        size_t len = strlen(s);
        unsigned char *dst, *src = (unsigned char *) s, *end = (unsigned char 
*) (src + len);
 
@@ -1615,7 +1619,7 @@
                int c;
 
                UTF8_GETCHAR(c,src);
-               UTF8_CONV(c,UTF8_toupperBati);
+               UTF8_CONV(c,UTF8_toupperColi);
                if (dst + 6 > (unsigned char *) *res + len) {
                        /* not guaranteed to fit, so allocate more space;
                           also allocate enough for the rest of the source */
@@ -1854,11 +1858,11 @@
 }
 
 int
-strSplit(BAT **Res, str s, str sep)
+strSplit(COL **Res, str s, str sep)
 {
        size_t seplen = strlen(sep);
        char *d, *x;
-       BAT *res;
+       COL *res;
        oid n = oid_nil;
 
        if (seplen == 0) {
@@ -1867,7 +1871,7 @@
        x = d = GDKstrdup(s);
        if (d == NULL)
                return GDK_FAIL;
-       res = BATnew(TYPE_void, TYPE_str, BUFSIZ);
+       res = COLnew(TYPE_str, BUFSIZ);
        if (res == NULL) {
                GDKfree(x);
                return GDK_FAIL;
@@ -1880,7 +1884,7 @@
                        break;
        
                *e = 0;
-               BUNins(res, (ptr) &n, d, FALSE);
+               res = BUNappend(res, d, FALSE);
                d = e + seplen;
        }
 
@@ -1888,7 +1892,7 @@
           don't return an empty final string if the source ends with
           a separator (this is to accommodate Niels) */
        if (*d)
-               BUNins(res, (ptr) &n, d, FALSE);
+               res = BUNappend(res, d, FALSE);
 
        GDKfree(x);
        *Res = res;
@@ -1896,16 +1900,15 @@
 }
 
 int
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to