Changeset: 094857e0d7af for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=094857e0d7af
Modified Files:
        monetdb5/modules/mal/groupby.c
        monetdb5/modules/mal/pcrelib.c
        monetdb5/modules/mal/pcrelib.h
Branch: headless
Log Message:

A few more compile error free


diffs (279 lines):

diff --git a/monetdb5/modules/mal/groupby.c b/monetdb5/modules/mal/groupby.c
--- a/monetdb5/modules/mal/groupby.c
+++ b/monetdb5/modules/mal/groupby.c
@@ -92,7 +92,7 @@
        if ( a == NULL)
                return NULL;
        a->cols = (COL**) GDKzalloc(pci->argc * sizeof(COL*));
-       a->estimate = (BUN *) GDKzalloc(pci->argc * sizeof(BUN));
+       a->estimate = (oid *) GDKzalloc(pci->argc * sizeof(oid));
        a->iter = (COLiter *) GDKzalloc(pci->argc * sizeof(COLiter));
        if ( a->cols == NULL){
                GDKfree(a);
@@ -110,8 +110,10 @@
                sample = COLcount(b) < 2000 ? COLcount(b): 2000;
                bs = COLsample( b, sample);
                if (bs) {
-                       bh = COLhistogram(bs);
+                       COL *unique;
+                       bh = COLhistogram(bs, &unique);
                        a->estimate[a->last] = COLcount(bh);
+                       CBPreleaseref(unique);
                }
                if ( bs ) CBPreleaseref(bs);
                if ( bh ) CBPreleaseref(bh);
diff --git a/monetdb5/modules/mal/pcrelib.c b/monetdb5/modules/mal/pcrelib.c
--- a/monetdb5/modules/mal/pcrelib.c
+++ b/monetdb5/modules/mal/pcrelib.c
@@ -142,30 +142,22 @@
 static COL *
 re_uselect(RE *pattern, COL *strs, int ignore)
 {
-       COLiter strsi = col_iterator(strs);
        COL *r;
-       oid p, q, k=0;
+       oid o;
+       oid *nbase, k= 0;
 
        r = COLnew(TYPE_oid, COLcount(strs));
        
+       nbase= (oid*) COLbase(r);
        COLaccessBegin(strs,USE_HEAP,MMAP_SEQUENTIAL);
        if (ignore) {
-               COLloop(strs, p, q) {
-                       str s = BUNhead(strsi, p);
-       
-                       if (re_match_ignore(s, pattern)) 
-                               BUNfastins(r, &k);
-                       k++;
-               }
-       } else {
-               COLloop(strs, p, q) {
-                       str s = BUNhead(strsi, p);
-       
-                       if (re_match_no_ignore(s, pattern)) 
-                               BUNfastins(r, &k);
-                       k++;
-               }
-       }
+               COLforloop(strs, o)
+                       if (re_match_ignore( COLgetString(strs,o), pattern)) 
+                               nbase[k++] =o;
+       } else 
+               COLforloop(strs, o)
+                       if (re_match_no_ignore( COLgetString(strs,o), pattern)) 
+                               nbase[k++] = o;
        COLaccessEnd(strs,USE_HEAP,MMAP_SEQUENTIAL);
        r->nonil = strs->nonil;
        r->sorted = strs->sorted;
@@ -244,11 +236,10 @@
 str
 pcre_uselect(COL **res, str pattern, COL *strs, bit insensitive)
 {
-       COLiter strsi = col_iterator(strs);
        const char err[BUFSIZ], *err_p = err;
        int errpos = 0;
        COL *r;
-       oid p, q, k= 0;
+       oid o, *nbase, k= 0;
        pcre *re = NULL;
        pcre_extra *pe = NULL;
        int options = PCRE_UTF8 | PCRE_MULTILINE;
@@ -265,14 +256,14 @@
        if (err_p) 
                throw(MAL, "pcre_uselect", OPERATION_FAILED "pcre compile of 
pattern (%s) failed with\n'%s'.", pattern, err_p);
 
+       nbase= (oid*) COLbase(r);
        COLaccessBegin(strs,USE_HEAP,MMAP_SEQUENTIAL);
-       COLloop(strs, p, q) {
-               str s = BUNhead(strsi, p);
+       COLforloop(strs, o) {
+               str s = COLgetString(strs,o);
                int l = (int) strlen(s);
 
                if (pcre_exec(re, pe, s, l, 0, 0, NULL, 0) >= 0) 
-                       BUNfastins(r, &k);
-               k++;
+                       nbase[k++] = o;
        }
        COLaccessEnd(strs,USE_HEAP,MMAP_SEQUENTIAL);
        r->nonil = TRUE;
@@ -397,14 +388,13 @@
 str
 pcre_replace_bat(COL **res, COL *origin_strs, str pattern, str replacement, 
str flags)
 {
-       COLiter origin_strsi = col_iterator(origin_strs);
        const char err[BUFSIZ], *err_p = err, *err_p2 = err;
        int i, j, k, len, errpos = 0, offset = 0;
        int compile_options = PCRE_UTF8, exec_options = PCRE_NOTEMPTY;
        pcre *pcre_code = NULL;
        pcre_extra *extra;
        COL *tmpbat;
-       oid p, q;
+       oid o;
        int *ovector, ovecsize;
        int len_origin_str, len_replacement = (int) strlen(replacement);
        int capture_offsets[MAX_NR_CAPTURES * 2], ncaptures = 0, len_del = 0;
@@ -445,10 +435,10 @@
        
        tmpbat = COLnew(TYPE_str, COLcount(origin_strs));
        COLaccessBegin(origin_strs,USE_HEAP,MMAP_SEQUENTIAL);
-       COLloop(origin_strs, p, q) {
-               origin_str = BUNhead(origin_strsi, p);
+       COLforloop(origin_strs, o) {
+               i = ncaptures = len_del = offset = 0;
+               origin_str = COLgetString(origin_strs,o);
                len_origin_str = (int) strlen(origin_str);
-               i = ncaptures = len_del = offset = 0;
                do {
                        j = pcre_exec(pcre_code, extra, origin_str, 
len_origin_str, offset,
                                        exec_options, ovector, ovecsize);
@@ -496,10 +486,10 @@
                        strncpy(replaced_str+k, origin_str+capture_offsets[j], 
len);
                        k += len;
                        replaced_str[k] = '\0';
-                       BUNappend(tmpbat, replaced_str, FALSE);
+                       COLputString(tmpbat,o, replaced_str);
                        GDKfree(replaced_str);
                } else /* no captured substrings, copy the original string into 
new bat */
-                       BUNappend(tmpbat, origin_str, FALSE);
+                       COLputString(tmpbat,o, origin_str);
        }
        COLaccessEnd(origin_strs,USE_HEAP,MMAP_SEQUENTIAL);
 
@@ -613,7 +603,7 @@
                return 1;
 }
 
-BUN
+oid
 pcre_hash(pcre * b)
 {
        return *(sht *) b;
@@ -792,8 +782,8 @@
 PCREreplace_bat_wrap(int *res, int *bid, str *pat, str *repl, str *flags){
        COL *b,*bn = NULL;
        str msg;
-       if ((b = COLdescriptor(*bid)) == NULL)
-               throw(MAL, "pcre.replace", RUNTIME_OBJECT_MISSING);
+       if ((msg = getCOLdescriptor(&b,bid)) )
+               throwagain(MAL, "pcre.replace", msg);
 
        msg = pcre_replace_bat(&bn,b,*pat,*repl,*flags);
        if( msg == MAL_SUCCEED)
@@ -827,9 +817,8 @@
        COL *bn = NULL, *strs;
        str msg;
 
-       if ((strs = COLdescriptor(*bid)) == NULL) {
-               throw(MAL, "pcre.select", RUNTIME_OBJECT_MISSING);
-       }
+       if ((msg = getCOLdescriptor(&strs,bid)) )
+               throwagain(MAL, "pcre.select", msg);
 
        if ((msg = pcre_uselect(&bn, *pattern, strs, *ignore)) != MAL_SUCCEED) {
                CBPreleaseref(strs);
@@ -1009,58 +998,54 @@
        str res = PCREsql2pcre(&ppat, pat, esc);
 
        if (!res) {
-               COL *strs = COLdescriptor(*bid);
-               COLiter strsi;
+               COL *strs ;
                COL *r;
                bit *br;
-               BUN p, q, i = 0;
+               oid o;
+               str msg;
 
-               if (strs == NULL)
-                       throw(MAL, "colstr.like", OPERATION_FAILED);
+               if( (msg =getCOLdescriptor(&strs,bid)) )
+                       throwagain(MAL, "colstr.like", msg);
 
                r = COLnew(TYPE_bit, COLcount(strs));
-               br = (bit*)BUNfirst(r);
-               strsi = col_iterator(strs);
+               if ( r == NULL){
+                       CBPreleaseref(strs);
+                       throw(MAL,"str.like", MAL_MALLOC_FAIL);
+               }
+               br =  (bit*) COLbase(r);
 
                COLaccessBegin(strs,USE_HEAP,MMAP_SEQUENTIAL);
                if (strcmp(ppat, (char*)str_nil) == 0) {
-                       COLloop(strs, p, q) {
-                               str s = (str)BUNhead(strsi, p);
+                       COLforloop(strs, o) {
+                               str s = COLgetString(strs, o);
 
                                if (strcmp(s, *pat) == 0)
-                                       br[i] = TRUE;
+                                       br[o] = TRUE;
                                else 
-                                       br[i] = FALSE;
+                                       br[o] = FALSE;
                                if (*not)
-                                       br[i] = !br[i];
-                               i++;
+                                       br[o] = !br[o];
                        }
                } else {
                        if (*isens) {
-                               COLloop(strs, p, q) {
-                                       str s = (str)BUNhead(strsi, p);
-
-                                       res = PCREimatch(br + i, &s, &ppat);
-                                       i++;
+                               COLforloop(strs, o) {
+                                       str s = COLgetString(strs,o);
+                                       res = PCREimatch(br + o, &s, &ppat);
                                }
                        } else {
-                               COLloop(strs, p, q) {
-                                       str s = (str)BUNhead(strsi, p);
+                               COLforloop(strs, o) {
+                                       str s = COLgetString(strs,o);
 
-                                       res = PCREmatch(br + i, &s, &ppat);
-                                       i++;
+                                       res = PCREmatch(br + o, &s, &ppat);
                                }
                        }
                        if (*not) {
-                               i = 0;
-                               COLloop(strs, p, q) {
-                                       br[i] = !br[i];
-                                       i++;
-                               }
+                               COLforloop(strs, o)
+                                       br[o] = !br[o];
                        }
                }
                COLaccessEnd(strs,USE_HEAP,MMAP_SEQUENTIAL);
-               COLsetcount(r, i);
+               COLsetcount(r, o);
                COLkey(r,FALSE);
                COLsetreadonly(r); 
                *ret = CBPkeepref(r);
@@ -1211,7 +1196,7 @@
                                
                                if (bp == NULL)
                                        throw(MAL, "pcre.like", 
OPERATION_FAILED); /*operation?*/
-                               res = COLuselect(bp, *pat, *pat);
+                               res = COLselect(bp, *pat, *pat);
                                
                                *ret = CBPkeepref(res);
                                CBPreleaseref(bp);
diff --git a/monetdb5/modules/mal/pcrelib.h b/monetdb5/modules/mal/pcrelib.h
--- a/monetdb5/modules/mal/pcrelib.h
+++ b/monetdb5/modules/mal/pcrelib.h
@@ -53,7 +53,7 @@
 pcre_export int pcre_tostr(str *tostr, int *l, pcre * p);
 pcre_export int pcre_fromstr(str instr, int *l, pcre ** val);
 pcre_export int pcre_nequal(pcre * l, pcre * r);
-pcre_export BUN pcre_hash(pcre * b);
+pcre_export oid pcre_hash(pcre * b);
 pcre_export pcre * pcre_null(void);
 pcre_export void pcre_del(Heap *h, var_t *index);
 pcre_export int pcre_length(pcre * p);
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to