Changeset: bc735e604622 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=bc735e604622
Modified Files:
        sql/backends/monet5/iot/50_iot.sql
        sql/backends/monet5/iot/Tests/iot02.sql
        sql/backends/monet5/iot/basket.c
        sql/backends/monet5/iot/petrinet.c
        sql/backends/monet5/iot/petrinet.h
Branch: iot
Log Message:

Cleanup tumbling


diffs (147 lines):

diff --git a/sql/backends/monet5/iot/50_iot.sql 
b/sql/backends/monet5/iot/50_iot.sql
--- a/sql/backends/monet5/iot/50_iot.sql
+++ b/sql/backends/monet5/iot/50_iot.sql
@@ -42,7 +42,7 @@ create procedure iot.pause("schema" stri
 create procedure iot.pause()
        external name iot.pause;
 
-create procedure iot.wait(cycles integer)
+create procedure iot.wait(ms integer)
        external name iot.wait;
 
 create procedure iot.stop()
diff --git a/sql/backends/monet5/iot/Tests/iot02.sql 
b/sql/backends/monet5/iot/Tests/iot02.sql
--- a/sql/backends/monet5/iot/Tests/iot02.sql
+++ b/sql/backends/monet5/iot/Tests/iot02.sql
@@ -13,7 +13,7 @@ begin
        insert into result1 select * from stmp2 where val <12;
        insert into result2 select * from stmp2 where val >12;
 end;
-call iot.query('iot','cq02');
+call iot.query('iot','cq02',4);
 call iot.pause('iot','cq02');
 
 insert into stmp2 values('2005-09-23 12:34:26.000',1,11.0);
@@ -25,14 +25,13 @@ call iot.resume('iot','cq02');
 
 -- wait for 5 seconds for handler
 
+call iot.wait(5000);
+call iot.pause();
 select 'RESULT';
---call iot.cycles('iot','cq02',4);
-call iot.wait(2000);
 select * from stmp2;
 select * from result1;
 select * from result2;
 
-call iot.pause();
 select * from iot.errors();
 drop procedure cq02;
 drop table stmp2;
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
@@ -660,11 +660,11 @@ BSKTexport(Client cntxt, MalBlkPtr mb, M
 }
 
 /* remove tuples from a basket according to the sliding policy */
-#define ColumnShift(B,TPE, CNT) { \
+#define ColumnShift(B,TPE) { \
        TPE *first= (TPE*) Tloc(B, 0);\
-       TPE *n = first+CNT;\
+       TPE *n = first + (stride == -1 ? BATcount(b): (BUN) stride);\
        TPE *last=  (TPE*) Tloc(B, BUNlast(B));\
-       for( ; n < last; n++, first++)\
+       for(cnt=0 ; n < last; cnt++, n++, first++)\
                *first=*n;\
 }
 
@@ -684,41 +684,38 @@ BSKTtumbleInternal(Client cntxt, str sch
        for(i=0; i< MAXCOLS && baskets[bskt].cols[i]; i++){
                b = baskets[bskt].bats[i];
                assert( b );
-               if( stride != -1)
-                       cnt = (BUN) stride;
-               else
-                       cnt= BATcount(b);
 
                switch(ATOMstorage(b->ttype)){
-               case TYPE_bit:ColumnShift(b,bit,cnt); break;
-               case TYPE_bte:ColumnShift(b,bte,cnt); break;
-               case TYPE_sht:ColumnShift(b,sht,cnt); break;
-               case TYPE_int:ColumnShift(b,int,cnt); break;
-               case TYPE_oid:ColumnShift(b,oid,cnt); break;
-               case TYPE_flt:ColumnShift(b,flt,cnt); break;
-               case TYPE_dbl:ColumnShift(b,dbl,cnt); break;
-               case TYPE_lng:ColumnShift(b,lng,cnt); break;
+               case TYPE_bit:ColumnShift(b,bit); break;
+               case TYPE_bte:ColumnShift(b,bte); break;
+               case TYPE_sht:ColumnShift(b,sht); break;
+               case TYPE_int:ColumnShift(b,int); break;
+               case TYPE_oid:ColumnShift(b,oid); break;
+               case TYPE_flt:ColumnShift(b,flt); break;
+               case TYPE_dbl:ColumnShift(b,dbl); break;
+               case TYPE_lng:ColumnShift(b,lng); break;
 #ifdef HAVE_HGE
-               case TYPE_hge:ColumnShift(b,hge,cnt); break;
+               case TYPE_hge:ColumnShift(b,hge); break;
 #endif
                case TYPE_str:
                        switch(b->twidth){
-                       case 1: ColumnShift(b,bte,cnt); break;
-                       case 2: ColumnShift(b,sht,cnt); break;
-                       case 4: ColumnShift(b,int,cnt); break;
-                       case 8: ColumnShift(b,lng,cnt); break;
+                       case 1: ColumnShift(b,bte); break;
+                       case 2: ColumnShift(b,sht); break;
+                       case 4: ColumnShift(b,int); break;
+                       case 8: ColumnShift(b,lng); break;
                        }
                                break;
-               default: break;
+               default: 
+                       throw(SQL, "iot.tumble", "Could not find the basket 
column storage %s.%s[%d]",sch,tbl,i);
                }
-               if( stride == -1)
-                       BATsetcount(b, 0);
-               else 
-               if( BATcount(b) >= cnt)
-                       BATsetcount(b, BATcount(b)-cnt);
-               if( BATcount(b) == 0){
+
+               mnstr_printf(BSKTout,"#Tumbled %s.%s[%d] "BUNFMT" 
elements\n",sch,tbl,i,cnt);
+               BATsetcount(b, cnt);
+               baskets[bskt].count = BATcount(b);
+               if( cnt == 0)
                        baskets[bskt].status = BSKTWAIT;
-               }
+               b->tnil = b->tnonil = 0;
+               b->tsorted = b->trevsorted = 0;
                BATsettrivprop(b);
        }
        return MAL_SUCCEED;
diff --git a/sql/backends/monet5/iot/petrinet.c 
b/sql/backends/monet5/iot/petrinet.c
--- a/sql/backends/monet5/iot/petrinet.c
+++ b/sql/backends/monet5/iot/petrinet.c
@@ -772,7 +772,7 @@ PNscheduler(void *dummy)
 #ifdef DEBUG_PETRINET
        mnstr_printf(GDKout, "#petrinet.scheduler stopped\n");
 #endif
-       //MCcloseClient(cntxt);
+       MCcloseClient(cntxt);
        pnstatus = PNINIT;
        (void) dummy;
 }
diff --git a/sql/backends/monet5/iot/petrinet.h 
b/sql/backends/monet5/iot/petrinet.h
--- a/sql/backends/monet5/iot/petrinet.h
+++ b/sql/backends/monet5/iot/petrinet.h
@@ -24,7 +24,7 @@
 #include "iot.h"
 #include "basket.h"
 
-//#define _DEBUG_PETRINET_ 
+#define DEBUG_PETRINET
 
 #define PNINIT 0
 #define PNRUNNING 1       /* query is running */
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to