Changeset: 83b7e70e94e8 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=83b7e70e94e8
Modified Files:
monetdb5/modules/mal/pcre.c
monetdb5/modules/mal/pcre.mal
sql/scripts/09_like.sql
Branch: default
Log Message:
add missing like_join(s)
added (i)like_filter versions (same name for both select and join)
diffs (96 lines):
diff --git a/monetdb5/modules/mal/pcre.c b/monetdb5/modules/mal/pcre.c
--- a/monetdb5/modules/mal/pcre.c
+++ b/monetdb5/modules/mal/pcre.c
@@ -100,6 +100,8 @@ pcre_export str PCREselectDef(int *res,
pcre_export str PCREuselectDef(int *res, str *pattern, int *bid);
pcre_export str PCRElike_uselect_pcre(int *ret, int *b, str *pat, str *esc);
pcre_export str PCREilike_uselect_pcre(int *ret, int *b, str *pat, str *esc);
+pcre_export str PCRElike_join_pcre(int *ret, int *b, int *pat, str *esc);
+pcre_export str PCREilike_join_pcre(int *ret, int *b, int *pat, str *esc);
pcre_export str PCRElike_select_pcre(int *ret, int *b, str *pat, str *esc);
pcre_export str PCREilike_select_pcre(int *ret, int *b, str *pat, str *esc);
pcre_export str pcre_init(void);
@@ -1480,3 +1482,50 @@ PCREilike_select_pcre(int *ret, int *b,
{
return PCRElike_pcre(ret,b,pat,esc,FALSE,TRUE);
}
+
+static str
+PCRElike_join(int *ret, int *b, int *pat, str *esc, int case_sensitive)
+{
+ BUN p;
+ BAT *B = BATdescriptor(*b);
+ BAT *Bpat = BATdescriptor(*pat);
+ BAT *tr, *x, *res = BATnew(TYPE_oid, TYPE_oid, BATcount(B) *
BATcount(Bpat));
+ BATiter pati = bat_iterator(Bpat);
+
+ for(p = 0; p < BATcount(Bpat); p++) {
+ str ppat = (str)BUNtail(pati, p);
+ int r;
+ str err;
+
+ if (case_sensitive) {
+ if ((err = PCRElike_uselect_pcre( &r, b, &ppat, esc))
!= MAL_SUCCEED)
+ return err;
+ } else {
+ if ((err = PCREilike_uselect_pcre( &r, b, &ppat, esc))
!= MAL_SUCCEED)
+ return err;
+ }
+
+ tr = BATdescriptor(r);
+ x = BATconst(tr, TYPE_oid, BUNhead(pati, p));
+ BATins(res, x, TRUE);
+ BBPreleaseref(tr->batCacheid);
+ BBPreleaseref(x->batCacheid);
+ }
+ BBPreleaseref(B->batCacheid);
+ BBPreleaseref(Bpat->batCacheid);
+ *ret = res->batCacheid;
+ BBPkeepref(res->batCacheid);
+ return MAL_SUCCEED;
+}
+
+str
+PCRElike_join_pcre(int *ret, int *b, int *pat, str *esc)
+{
+ return PCRElike_join(ret, b, pat, esc, 1);
+}
+
+str
+PCREilike_join_pcre(int *ret, int *b, int *pat, str *esc)
+{
+ return PCRElike_join(ret, b, pat, esc, 0);
+}
diff --git a/monetdb5/modules/mal/pcre.mal b/monetdb5/modules/mal/pcre.mal
--- a/monetdb5/modules/mal/pcre.mal
+++ b/monetdb5/modules/mal/pcre.mal
@@ -49,9 +49,21 @@ comment "Select tuples based on the patt
command like_uselect(s:bat[:any_1,:str], pat:str, esc:str):bat[:any_1,:void]
address PCRElike_uselect_pcre;
+command like_filter(s:bat[:any_1,:str], pat:str, esc:str):bat[:any_1,:void]
+address PCRElike_uselect_pcre;
+
+command like_filter(s:bat[:any_1,:str], pat:bat[:any_2,:str],
esc:str):bat[:any_1,:any_2]
+address PCRElike_join_pcre;
+
command ilike_uselect(s:bat[:any_1,:str], pat:str, esc:str):bat[:any_1,:void]
address PCREilike_uselect_pcre;
+command ilike_filter(s:bat[:any_1,:str], pat:str, esc:str):bat[:any_1,:void]
+address PCREilike_uselect_pcre;
+
+command ilike_filter(s:bat[:any_1,:str], pat:bat[:any_2,:str],
esc:str):bat[:any_1,:any_2]
+address PCREilike_join_pcre;
+
command like_select(s:bat[:any_1,:str], pat:str, esc:str):bat[:any_1,:str]
address PCRElike_select_pcre;
diff --git a/sql/scripts/09_like.sql b/sql/scripts/09_like.sql
--- a/sql/scripts/09_like.sql
+++ b/sql/scripts/09_like.sql
@@ -1,2 +1,2 @@
-create filter function "like"(val string, pat string, esc string) external
name pcre.like_uselect;
-create filter function "ilike"(val string, pat string, esc string) external
name pcre.ilike_uselect;
+create filter function "like"(val string, pat string, esc string) external
name pcre.like_filter;
+create filter function "ilike"(val string, pat string, esc string) external
name pcre.ilike_filter;
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list