Changeset: 8e1ae62339da for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8e1ae62339da
Modified Files:
        sql/backends/monet5/sql_gencode.c
Branch: RIntegration-default
Log Message:

There is life!


diffs (116 lines):

diff --git a/sql/backends/monet5/sql_gencode.c 
b/sql/backends/monet5/sql_gencode.c
--- a/sql/backends/monet5/sql_gencode.c
+++ b/sql/backends/monet5/sql_gencode.c
@@ -90,6 +90,21 @@ constantAtom(backend *sql, MalBlkPtr mb,
        return idx;
 }
 
+static InstrPtr
+pushPtr(MalBlkPtr mb, InstrPtr q, ptr val)
+{
+       int _t;
+       ValRecord cst;
+
+       if (q == NULL)
+               return NULL;
+       cst.vtype= TYPE_ptr;
+       cst.val.pval = val;
+       cst.len = 0;
+       _t = defConstant(mb, TYPE_ptr, &cst);
+       return pushArgument(mb, q, _t);
+}
+
 static int
 argumentZero(MalBlkPtr mb, int tpe)
 {
@@ -1226,13 +1241,21 @@ static int
                                if (get_cmp(s) == cmp_filter) {
                                        node *n;
                                        char *mod, *fimp;
+                                       sql_func *f = s->op4.funcval->func;
 
                                        if (backend_create_subfunc(sql, 
s->op4.funcval, NULL) < 0)
                                                return -1;
-                                       mod = 
sql_func_mod(s->op4.funcval->func);
-                                       fimp = 
sql_func_imp(s->op4.funcval->func);
 
+                                       mod = sql_func_mod(f);
+                                       fimp = sql_func_imp(f);
                                        q = newStmt(mb, mod, 
convertOperator(fimp));
+                                       // push pointer to the SQL structure 
into the MAL call
+                                       // allows getting argument names for 
example
+                                        if (LANG_EXT(f->lang))
+                                                q = pushPtr(mb, q, f);
+                                        // f->query contains the R code to be 
run
+                                        if (f->lang == FUNC_LANG_R)
+                                                q = pushStr(mb, q, f->query);
                                        q = pushArgument(mb, q, l);
                                        if (sub > 0)
                                                q = pushArgument(mb, q, sub);
@@ -1856,6 +1879,10 @@ static int
                        } else {
                                fimp = convertOperator(fimp);
                                q = newStmt(mb, mod, fimp);
+                               if (LANG_EXT(f->func->lang))
+                                       q = pushPtr(mb, q, f->func);
+                               if (f->func->lang == FUNC_LANG_R)
+                                       q = pushStr(mb, q, f->func->query);
                        }
                        /* first dynamic output of copy* functions */
                        if (f->func->type == F_UNION) 
@@ -2777,9 +2804,27 @@ monet5_resolve_function(ptr M, sql_func 
 */
 }
 
-/* TODO handle aggr */
-int
-backend_create_func(backend *be, sql_func *f, list *restypes, list *ops)
+static int
+backend_create_r_func(backend *be, sql_func *f)
+{
+       (void)be;
+       switch(f->type) {
+       case  F_AGGR:
+               f->mod = "rapi";
+               f->imp = "eval_aggr";
+               break;
+       case  F_PROC: /* no output */
+       case  F_FUNC:
+       default: /* ie also F_FILT and F_UNION for now */
+               f->mod = "rapi";
+               f->imp = "eval";
+               break;
+       }
+       return 0;
+}
+
+static int
+backend_create_sql_func(backend *be, sql_func *f, list *restypes, list *ops)
 {
        mvc *m = be->mvc;
        sql_schema *schema = m->session->schema;
@@ -2902,6 +2947,24 @@ backend_create_func(backend *be, sql_fun
        return 0;
 }
 
+/* TODO handle aggr */
+int
+backend_create_func(backend *be, sql_func *f, list *restypes, list *ops)
+{
+       switch(f->lang) {
+       case FUNC_LANG_INT:
+       case FUNC_LANG_MAL:
+       case FUNC_LANG_SQL:
+               return backend_create_sql_func(be, f, restypes, ops);
+       case FUNC_LANG_R:
+               return backend_create_r_func(be, f);
+       case FUNC_LANG_C:
+       case FUNC_LANG_J:
+       default:
+               return -1;
+       }
+}
+
 static int
 backend_create_subfunc(backend *be, sql_subfunc *f, list *ops)
 {
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to