Changeset: 1355da7621d6 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1355da7621d6
Modified Files:
monetdb5/optimizer/opt_dict.c
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql_statement.c
Branch: dict
Log Message:
handle first select on dict column
diffs (110 lines):
diff --git a/monetdb5/optimizer/opt_dict.c b/monetdb5/optimizer/opt_dict.c
--- a/monetdb5/optimizer/opt_dict.c
+++ b/monetdb5/optimizer/opt_dict.c
@@ -9,6 +9,15 @@
#include "monetdb_config.h"
#include "opt_dict.h"
+static InstrPtr
+ReplaceWithNil(MalBlkPtr mb, InstrPtr p, int pos, int tpe)
+{
+ p = pushNil(mb, p, tpe); /* push at end */
+ getArg(p, pos) = getArg(p, p->argc-1);
+ p->argc--;
+ return p;
+}
+
str
OPTdictImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{
@@ -75,15 +84,43 @@ OPTdictImplementation(Client cntxt, MalB
pushInstruction(mb,r);
done = 1;
break;
- //} else if (getModuleId(p) == algebraRef &&
getFunctionId(p) == selectRef) {
+ } else if (getModuleId(p) == algebraRef &&
getFunctionId(p) == selectRef) {
/* pos = select(col, cand, l, h, ...)
with col = dict.decompress(o,u)
* tp = select(u, nil, l, h, ...)
- * tp2 = typeconver(tp) -> bte,sht,int
- * pos = semijoin(o, cand, tp2, nil) */
+ * tp2 = bte/sht/int(tp)
+ * pos = intersect(o, tp2, cand, nil) */
+
+ int cand = getArg(p, j+1);
+ InstrPtr r = copyInstruction(p);
+ getArg(r, j) = vardictvalue[k];
+ if (cand)
+ r = ReplaceWithNil(mb, r, j+1,
TYPE_bat); /* no candidate list */
+ pushInstruction(mb,r);
+
+ int tpe = getVarType(mb, varisdict[k]);
+ InstrPtr s = newInstructionArgs(mb,
batcalcRef, putName(ATOMname(getBatType(tpe))), 3);
+ getArg(s, 0) = newTmpVariable(mb, tpe);
+ addArgument(mb, s, getArg(r, 0));
+ s = pushNil(mb, s, TYPE_bat);
+ pushInstruction(mb,s);
+
+ InstrPtr t = newInstructionArgs(mb,
algebraRef, intersectRef, 5);
+ getArg(t, 0) = getArg(p, 0);
+ addArgument(mb, t, varisdict[k]);
+ addArgument(mb, t, getArg(s, 0));
+ addArgument(mb, t, cand);
+ t = pushNil(mb, t, TYPE_bat);
+ t = pushBit(mb, t, FALSE); /* nil
matches */
+ t = pushBit(mb, t, TRUE); /*
max_one */
+ t = pushNil(mb, t, TYPE_lng); /*
estimate */
+ pushInstruction(mb,t);
+
+ done = 1;
+ break;
} else {
/* need to decompress */
int tpe = getArgType(mb, p, j);
- InstrPtr r = newInstruction(mb,
dictRef, decompressRef);
+ InstrPtr r = newInstructionArgs(mb,
dictRef, decompressRef, 3);
getArg(r, 0) = newTmpVariable(mb, tpe);
r = addArgument(mb, r, varisdict[k]);
r = addArgument(mb, r, vardictvalue[k]);
diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -1573,13 +1573,13 @@ stmt_col( backend *be, sql_column *c, st
(!isNew(c) || !isNew(c->t) /* alter */) &&
(c->t->persistence == SQL_PERSIST || c->t->s) /*&&
!c->t->commit_action*/) {
stmt *u = stmt_bat(be, c, RD_UPD_ID, part);
+ if (c->storage_type) {
+ stmt *v = stmt_bat(be, c, RD_DICT, part);
+ sc = stmt_dict(be, sc, v);
+ }
sc = stmt_project_delta(be, sc, u);
if (del)
sc = stmt_project(be, del, sc);
- if (c->storage_type) {
- stmt *v = stmt_bat(be, c, RD_DICT, part);
- sc = stmt_dict(be, sc, v);
- }
} else if (del) { /* always handle the deletes */
sc = stmt_project(be, del, sc);
}
diff --git a/sql/backends/monet5/sql_statement.c
b/sql/backends/monet5/sql_statement.c
--- a/sql/backends/monet5/sql_statement.c
+++ b/sql/backends/monet5/sql_statement.c
@@ -558,6 +558,9 @@ stmt_bat(backend *be, sql_column *c, int
MalBlkPtr mb = be->mb;
InstrPtr q;
+ if (access == RD_DICT)
+ partition = 0;
+
/* for read access tid.project(col) */
if (!c->t->s && ATOMIC_PTR_GET(&c->t->data)) { /* declared table */
stmt *s = stmt_create(be->mvc->sa, st_bat);
@@ -579,7 +582,7 @@ stmt_bat(backend *be, sql_column *c, int
q = newStmtArgs(mb, sqlRef, bindRef, 9);
if (q == NULL)
return NULL;
- if (c->storage_type && access != RD_DICT) {
+ if (c->storage_type && access != RD_DICT && access != RD_UPD_ID) {
sql_trans *tr = be->mvc->session->tr;
sqlstore *store = tr->store;
BAT *b = store->storage_api.bind_col(tr, c, QUICK);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list