Changeset: 722f42e91482 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=722f42e91482
Modified Files:
        monetdb5/modules/mal/mal_weld.c
        sql/backends/monet5/rel_weld.c
Branch: rel-weld
Log Message:

Type inference doesn't work on mergers, so use i64 for the array of string 
indexes


diffs (169 lines):

diff --git a/monetdb5/modules/mal/mal_weld.c b/monetdb5/modules/mal/mal_weld.c
--- a/monetdb5/modules/mal/mal_weld.c
+++ b/monetdb5/modules/mal/mal_weld.c
@@ -107,6 +107,7 @@ static str getWeldUTypeFromWidth(int wid
                return "u64";
 }
 
+/*
 static int getMalTypeFromWidth(int width) {
        if (width == 1)
                return TYPE_bte;
@@ -117,6 +118,7 @@ static int getMalTypeFromWidth(int width
        else
                return TYPE_lng;
 }
+*/
 
 void dumpWeldProgram(str program, FILE *f) {
        int i, j, tabs = 0, print_tabs = 0, print_before = 1;
@@ -317,12 +319,13 @@ WeldRun(Client cntxt, MalBlkPtr mb, MalS
                                                                  getArg(pci, 
j));
                                                if (in->tvheap->base == 
strbase) {
                                                        
BBPshare(in->tvheap->parentid);
-                                                       b = COLnew(0, 
getMalTypeFromWidth(in->twidth), size, TRANSIENT);
+                                                       b = COLnew(0, TYPE_lng, 
size, TRANSIENT);
                                                        b->tsorted = 
b->trevsorted = 0;
                                                        b->tvheap = in->tvheap;
                                                        b->ttype = in->ttype;
                                                        b->tsorted = 
in->tsorted;
                                                        b->tvarsized = 1;
+                                                       memcpy(b->theap.base, 
base, size * BATatoms[TYPE_lng].size);
                                                        break;
                                                }
                                        }
@@ -330,8 +333,8 @@ WeldRun(Client cntxt, MalBlkPtr mb, MalS
                        } else {
                                b = COLnew(0, getBatType(type), size, 
TRANSIENT);
                                b->tsorted = b->trevsorted = 0;
+                               memcpy(b->theap.base, base, size * b->twidth);
                        }
-                       memcpy(b->theap.base, base, size * b->twidth);
                        BATsetcount(b, size);
                        BBPkeepref(b->batCacheid);
                        *getArgReference_bat(stk, pci, i) = b->batCacheid;
diff --git a/sql/backends/monet5/rel_weld.c b/sql/backends/monet5/rel_weld.c
--- a/sql/backends/monet5/rel_weld.c
+++ b/sql/backends/monet5/rel_weld.c
@@ -543,7 +543,7 @@ base_table_produce(backend *be, sql_rel 
                        wprintf(wstate, ", ");
                }
                if (exp_subtype(exp)->type->localtype == TYPE_str) {
-                       /* Save the vheap and stroffset names */
+                       /* Save the vheap name */
                        sprintf(wstate->global_init + 
strlen(wstate->global_init), "let %s_strcol = in%dstr;",
                                        get_col_name(wstate->sa, exp, ANY), 
col->nr);
                        sprintf(wstate->global_init + 
strlen(wstate->global_init), "let %s_stroffset = in%dstroffset;",
@@ -565,9 +565,9 @@ base_table_produce(backend *be, sql_rel 
                        sprintf(struct_mbr, "n%d.$%d", wstate->num_loops, 
count);
                }
                if (exp_subtype(exp)->type->localtype == TYPE_str) {
-                       wprintf(wstate, "let %s = strslice(%s_strcol, i64(%s) + 
%s_stroffset);",
-                                                  col_name, col_name, 
struct_mbr, col_name);
-                       wprintf(wstate, "let %s_stridx = %s;", col_name, 
struct_mbr);
+                       wprintf(wstate, "let %s_stridx = i64(%s) + 
%s_stroffset;", col_name, struct_mbr, col_name);
+                       wprintf(wstate, "let %s = strslice(%s_strcol, 
%s_stridx);",
+                                                  col_name, col_name, 
col_name);
                } else {
                        wprintf(wstate, "let %s = %s;", col_name, struct_mbr);
                }
@@ -649,7 +649,7 @@ project_produce(backend *be, sql_rel *re
                for (en = appender_col_types->h; en; en = en->next) {
                        int type = ((sql_type*)en->data)->localtype;
                        if (type == TYPE_str) {
-                               len += sprintf(new_builder + len, "?");
+                               len += sprintf(new_builder + len, "i64");
                        } else {
                                len += sprintf(new_builder + len, "%s", 
getWeldType(type));
                        }
@@ -685,11 +685,9 @@ project_produce(backend *be, sql_rel *re
                        str old_col_name = get_col_name(wstate->sa, exp, REL);
                        wprintf(wstate, "let %s = %s;", col_name, old_col_name);
                        wprintf(wstate, "let %s_stridx = %s_stridx;", col_name, 
old_col_name);
-                       /* Save the vheap and stroffset names */
+                       /* Save the vheap name */
                        sprintf(wstate->global_init + 
strlen(wstate->global_init), "let %s_strcol = %s_strcol;",
                                        col_name, old_col_name);
-                       sprintf(wstate->global_init + 
strlen(wstate->global_init), "let %s_stroffset = %s_stroffset;",
-                                       col_name, old_col_name);
                } else {
                        wprintf(wstate, "let %s = ", col_name);
                        exp_to_weld(be, wstate, exp);
@@ -730,8 +728,8 @@ project_produce(backend *be, sql_rel *re
                        node *col_list_node = list_find(appender_cols, 
col_name, (fcmp)strcmp);
                        int idx = list_position(appender_cols, 
col_list_node->data);
                        if (exp_subtype(exp)->type->localtype == TYPE_str) {
-                               wprintf(wstate, "let %s = strslice(%s_strcol, 
i64(n.$%d) + %s_stroffset);",
-                                       col_name, col_name, idx, col_name);
+                               wprintf(wstate, "let %s = strslice(%s_strcol, 
n.$%d);",
+                                       col_name, col_name, idx);
                        } else {
                                wprintf(wstate, "let %s = n.$%d;", col_name, 
idx);
                        }
@@ -768,8 +766,8 @@ project_produce(backend *be, sql_rel *re
                        exp = en->data;
                        col_name = get_col_name(wstate->sa, exp, ALIAS);
                        if (exp_subtype(exp)->type->localtype == TYPE_str) {
-                               wprintf(wstate, "let %s = strslice(%s_strcol, 
i64(%s) + %s_stroffset);",
-                                               col_name, col_name, struct_mbr, 
col_name);
+                               wprintf(wstate, "let %s = strslice(%s_strcol, 
%s);",
+                                               col_name, col_name, struct_mbr);
                                wprintf(wstate, "let %s_stridx = %s;", 
col_name, struct_mbr);
                        } else {
                                wprintf(wstate, "let %s = %s;", col_name, 
struct_mbr);
@@ -837,7 +835,7 @@ groupby_produce(backend *be, sql_rel *re
                        exp = en->data;
                        int type = exp_subtype(exp)->type->localtype;
                        if (type == TYPE_str) {
-                               len += sprintf(new_builder + len, "?");
+                               len += sprintf(new_builder + len, "i64");
                        } else {
                                len += sprintf(new_builder + len, "%s", 
getWeldType(type));
                        }
@@ -1000,15 +998,13 @@ groupby_produce(backend *be, sql_rel *re
                        }
                }
                if (exp_subtype(exp)->type->localtype == TYPE_str) {
-                       wprintf(wstate, "let %s = strslice(%s_strcol, i64(%s) + 
%s_stroffset);", 
-                                                  col_name, col_name, 
struct_mbr, col_name);
+                       wprintf(wstate, "let %s = strslice(%s_strcol, %s);", 
+                                                  col_name, col_name, 
struct_mbr);
                        wprintf(wstate, "let %s_stridx = %s;", col_name, 
struct_mbr);
                        /* Global string col renaming */
                        str old_col_name = get_col_name(wstate->sa, exp, REL);
                        sprintf(wstate->global_init + 
strlen(wstate->global_init), "let %s_strcol = %s_strcol;",
                                        col_name, old_col_name);
-                       sprintf(wstate->global_init + 
strlen(wstate->global_init), "let %s_stroffset = %s_stroffset;",
-                                       col_name, old_col_name);
                } else {
                        wprintf(wstate, "let %s = %s;", col_name, struct_mbr);
                }
@@ -1097,7 +1093,7 @@ join_produce(backend *be, sql_rel *rel, 
                exp = en->data;
                int type = exp_subtype(exp)->type->localtype;
                if (type == TYPE_str) {
-                       len += sprintf(new_builder + len, "?");
+                       len += sprintf(new_builder + len, "i64");
                } else {
                        len += sprintf(new_builder + len, "%s", 
getWeldType(type));
                }
@@ -1202,8 +1198,8 @@ join_produce(backend *be, sql_rel *rel, 
                exp = en->data;
                col_name = list_fetch(right_cols, count);
                if (exp_subtype(exp)->type->localtype == TYPE_str) {
-                       wprintf(wstate, "let %s = strslice(%s_strcol, i64(%s) + 
%s_stroffset);", 
-                                                  col_name, col_name, 
struct_mbr, col_name);
+                       wprintf(wstate, "let %s = strslice(%s_strcol, %s);", 
+                                                  col_name, col_name, 
struct_mbr);
                        wprintf(wstate, "let %s_stridx = %s;", col_name, 
struct_mbr);
                } else {
                        wprintf(wstate, "let %s = %s;", col_name, struct_mbr);
@@ -1324,7 +1320,7 @@ root_produce(backend *be, sql_rel *rel)
                        int type = exp_subtype(en->data)->type->localtype;
                        if (type == TYPE_str) {
                                /* We'll append just the offset in vheap, we 
don't know the type yet */
-                               len += sprintf(builder + len, "appender[?]");
+                               len += sprintf(builder + len, "appender[i64]");
                        } else {
                                len += sprintf(builder + len, "appender[%s]", 
getWeldType(type));
                        }
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to