Changeset: f6e85ef6315d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f6e85ef6315d
Modified Files:
monetdb5/optimizer/opt_iot.c
sql/backends/monet5/iot/basket.c
sql/backends/monet5/iot/basket.mal
Branch: iot
Log Message:
Clear the stream table
diffs (89 lines):
diff --git a/monetdb5/optimizer/opt_iot.c b/monetdb5/optimizer/opt_iot.c
--- a/monetdb5/optimizer/opt_iot.c
+++ b/monetdb5/optimizer/opt_iot.c
@@ -73,7 +73,7 @@ OPTiotImplementation(Client cntxt, MalBl
if( strcmp(schemas[j], schemas[j+1])==0 &&
strcmp(tables[j],tables[j+1]) ==0)
break;
mvc[j] = getArg(p,0);
- done[j]= done[j]== 0 || getFunctionId(p)== registerRef;
+ done[j]= done[j] || getFunctionId(p)== registerRef;
if( j == btop)
btop++;
}
@@ -97,7 +97,7 @@ OPTiotImplementation(Client cntxt, MalBl
OPTDEBUGiot {
mnstr_printf(cntxt->fdout, "#iot optimizer started\n");
printFunction(cntxt->fdout, mb, stk, LIST_MAL_DEBUG);
- }// else
+ }
(void) stk;
alias = (int *) GDKzalloc(mb->vtop * 2 * sizeof(int));
@@ -205,7 +205,7 @@ OPTiotImplementation(Client cntxt, MalBl
pushInstruction(mb,old[i]);
OPTDEBUGiot {
- mnstr_printf(cntxt->fdout, "#iot optimizer intermediate\n");
+ mnstr_printf(cntxt->fdout, "#iot optimizer final\n");
printFunction(cntxt->fdout, mb, stk, LIST_MAL_DEBUG);
}
GDKfree(alias);
diff --git a/sql/backends/monet5/iot/basket.c b/sql/backends/monet5/iot/basket.c
--- a/sql/backends/monet5/iot/basket.c
+++ b/sql/backends/monet5/iot/basket.c
@@ -120,7 +120,7 @@ BSKTnewbasket(sql_schema *s, sql_table *
baskets[idx].count++;
}
// collect the column names
- baskets[idx].cols = (str*) GDKzalloc(sizeof(str) *
baskets[idx].count+1);
+ baskets[idx].cols = (str*) GDKzalloc(sizeof(str) *
(baskets[idx].count+1));
for (i=0, o = t->columns.set->h; o; o = o->next){
sql_column *col = o->data;
baskets[idx].cols[i++]= col->base.name;
@@ -499,6 +499,9 @@ BSKTclear(Client cntxt, MalBlkPtr mb, Ma
str tname = *getArgReference_str(stk, pci, 2);
sql_schema *s;
sql_table *t;
+ sql_column *c;
+ int i, idx;
+ BAT *b;
*res = 0;
if ((msg = getSQLContext(cntxt, mb, &m, NULL)) != NULL)
@@ -510,8 +513,23 @@ BSKTclear(Client cntxt, MalBlkPtr mb, Ma
throw(SQL, "basket.clear", "Schema missing");
t = mvc_bind_table(m, s, tname);
if ( t == NULL)
- throw(SQL,"basket.clear","Stream table %s.%s not accessible for
append\n",sname,tname);
+ throw(SQL,"basket.clear","Stream table %s.%s not accessible for
clearing\n",sname,tname);
+ idx = BSKTlocate(sname,tname);
+ if( idx <= 0)
+ throw(SQL,"basket.clear","Stream table %s.%s not registered
\n",sname,tname);
// do actual work
+ MT_lock_set(&iotLock);
+ for( i=0; baskets[idx].cols[i]; i++){
+ c= mvc_bind_column(m, t, baskets[idx].cols[i]);
+ if( c){
+ b = store_funcs.bind_col(m->session->tr,c,RDONLY);
+ if(b){
+ BATsetcount(b,0);
+ BBPunfix(b->batCacheid);
+ }
+ }
+ }
+ MT_lock_unset(&iotLock);
return MAL_SUCCEED;
}
diff --git a/sql/backends/monet5/iot/basket.mal
b/sql/backends/monet5/iot/basket.mal
--- a/sql/backends/monet5/iot/basket.mal
+++ b/sql/backends/monet5/iot/basket.mal
@@ -53,7 +53,7 @@ pattern update(sch:str,tbl:str, cols:bat
address BSKTupdate
comment "Dump the new tuples into the basket";
-command clear_table(sch:str,tbl:str):wrd
+pattern clear_table(sch:str,tbl:str):wrd
address BSKTclear
comment "Remove the basket";
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list