Changeset: f7f2ad3a05d2 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f7f2ad3a05d2
Modified Files:
        sql/backends/monet5/datacell/50_datacell.sql
        sql/backends/monet5/datacell/Tests/datacell00.sql
        sql/backends/monet5/datacell/Tests/emitter00.mal
        sql/backends/monet5/datacell/Tests/petrinet00.mal
        sql/backends/monet5/datacell/Tests/receptor00.mal
        sql/backends/monet5/datacell/datacell.mx
        sql/backends/monet5/datacell/petrinet.mx
Branch: default
Log Message:

Petrinet admin adjusted
The petrinet scheduler now is focussed on tables as well.
Ready for getting the first complete path working again.


diffs (truncated from 566 to 300 lines):

diff --git a/sql/backends/monet5/datacell/50_datacell.sql 
b/sql/backends/monet5/datacell/50_datacell.sql
--- a/sql/backends/monet5/datacell/50_datacell.sql
+++ b/sql/backends/monet5/datacell/50_datacell.sql
@@ -38,3 +38,12 @@
 
 create procedure datacell.drop (sch string, tbl string)
     external name datacell.drop;
+
+create procedure datacell.query(sch string, proc string)
+       extern name datacell.query;
+
+create procedure datacell.run()
+       extern name datacell.run;
+
+create procedure datacell.stop()
+       extern name datacell.stop;
diff --git a/sql/backends/monet5/datacell/Tests/datacell00.sql 
b/sql/backends/monet5/datacell/Tests/datacell00.sql
--- a/sql/backends/monet5/datacell/Tests/datacell00.sql
+++ b/sql/backends/monet5/datacell/Tests/datacell00.sql
@@ -3,3 +3,10 @@
 create schema datacell;
 create table datacell.X( id int, tag timestamp, payload int);
 create table datacell.Y( id int, tag timestamp, payload int, msdelay int);
+
+-- the continoues query
+create procedure datacell.tranport()
+begin
+       -- insert into datacell.Y select *, cast(now() as milliseconds) -  
cast(tag as milliseconds) from datacell.X;
+        insert into datacell.Y select *, 1 from datacell.X;
+end;
diff --git a/sql/backends/monet5/datacell/Tests/emitter00.mal 
b/sql/backends/monet5/datacell/Tests/emitter00.mal
--- a/sql/backends/monet5/datacell/Tests/emitter00.mal
+++ b/sql/backends/monet5/datacell/Tests/emitter00.mal
@@ -5,6 +5,7 @@
 
 sql.init();
 
+basket.register("datacell","y");
 emitter.start("datacell","y","localhost",50502,"active");
 io.print("emitter working");
 alarm.sleep(5);
@@ -19,6 +20,7 @@
 emitter.drop("datacell","y");
 
 # The SQL equivalents
+# call datacell.basket('datacell','y);
 # call datacell.emitter('datacell','y','localhost',50502,'active');
 # call datacell.pause('datacell','y');
 # call datacell.resume('datacell','y');
diff --git a/sql/backends/monet5/datacell/Tests/petrinet00.mal 
b/sql/backends/monet5/datacell/Tests/petrinet00.mal
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/datacell/Tests/petrinet00.mal
@@ -0,0 +1,25 @@
+#The test is based on the definition the datacell baskets x and y
+# run datacell00.sql first
+
+sql.init();
+
+basket.register("datacell","x");
+basket.register("datacell","y");
+
+petrinet.register("datacell","transform", 0);
+petrinet.start();
+io.print("petrinet scheduler started");
+
+receptor.start("datacell","x","localhost",50501,"passive");
+io.print("receptor started");
+
+emitter.start("datacell","y","localhost",50502,"active");
+io.print("actuator started");
+
+alarm.sleep(25);
+petrinet.stop();
+receptor.drop("datacell","x");
+emitter.drop("datacell","x");
+
+# The SQL equivalents
+# call datacell.initialize();
diff --git a/sql/backends/monet5/datacell/Tests/receptor00.mal 
b/sql/backends/monet5/datacell/Tests/receptor00.mal
--- a/sql/backends/monet5/datacell/Tests/receptor00.mal
+++ b/sql/backends/monet5/datacell/Tests/receptor00.mal
@@ -5,6 +5,7 @@
 
 sql.init();
 
+basket.register("datacell","x");
 receptor.start("datacell","x","localhost",50501,"passive");
 io.print("receptor working");
 alarm.sleep(5);
@@ -19,6 +20,7 @@
 receptor.drop("datacell","x");
 
 # The SQL equivalents
+# call datacell.basket('datacell','x);
 # call datacell.receptor('datacell','x','localhost',50501,'passive');
 # call datacell.pause('datacell','x');
 # call datacell.resume('datacell','x');
diff --git a/sql/backends/monet5/datacell/datacell.mx 
b/sql/backends/monet5/datacell/datacell.mx
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/datacell/datacell.mx
@@ -0,0 +1,208 @@
+# The contents of this file are subject to the MonetDB Public License
+# Version 1.1 (the "License"); you may not use this file except in
+# compliance with the License. You may obtain a copy of the License at
+# http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html
+#
+# Software distributed under the License is distributed on an "AS IS"
+# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+# License for the specific language governing rights and limitations
+# under the License.
+#
+# The Original Code is the MonetDB Database System.
+#
+# The Initial Developer of the Original Code is CWI.
+# Portions created by CWI are Copyright (C) 1997-2008 CWI.
+# All Rights Reserved.
+
+@f datacell
+The interface from SQL passes through here.
+
+@mal
+module datacell;
+
+pattern basket(schema:str,tab:str):void
+address DCregister
+comment "Initialize a new basket based on a specific table definition in the 
datacell schema");
+
+command inventory():bat[:str,:bat]
+address DCinventory
+comment "Produce a tabular view of the datacell streaming components";
+
+command emitter(sch:str, tbl:str, host:str, port:int, protocol:str)
+address DCemitter
+comment "define a emitter based on a basket table. The emitter protocol is 
either active or passive.";
+
+command receptor(sch:str, tbl:str, host:str, port:int, protocol:str)
+address DCreceptor
+comment "Define a receptor based on a basket table. The receptor protocol is 
either active or passive.";
+
+pattern drop(schema:str,obj:str):void
+address DCdrop
+comment "Remove a basket, receptor or emitter";
+
+pattern pause(schema:str,obj:str):void
+address DCpause
+comment "Pause a receptor or emitter";
+
+pattern resume(schema:str,obj:str):void
+address DCresume
+comment "Pause a receptor or emitter";
+
+pattern query(schema:str,obj:str):void
+address DCquery
+comment "Add a new continuous query.";
+
+pattern run()
+address DCrun
+comment "(Re)start the petrinet scheduler.";
+
+pattern stop()
+address DCrun
+comment "Stop the petrinet scheduler.";
+@{
+@h
+#ifndef _DATACELLS_
+#define _DATACELLS_
+
+#include "monetdb_config.h"
+#include "mal.h"
+#include "mal_interpreter.h"
+#include "sql.h"
+#include "basket.h"
+
+#ifdef WIN32
+#ifndef LIBCONTAINERS
+#define datacell_export extern __declspec(dllimport)
+#else
+#define datacell_export extern __declspec(dllexport)
+#endif
+#else
+#define datacell_export extern
+#endif
+
+/* #define _DEBUG_DATACELL     debug this module */
+
+datacell_export str DCregister_all(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
+datacell_export str DCregister(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
+datacell_export str DCdrop(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
+datacell_export str DCpause(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
+datacell_export str DCresume(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
+datacell_export str DCquery(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
+datacell_export str DCrun(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
+datacell_export str DCstop(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
+datacell_export str DCinventory(int *ret);
+
+#endif
+@c
+#include "basket.h"
+#ifdef WIN32
+#include "winsock2.h"
+#endif
+
+str
+DCregister(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+       return BSKTregister(cntxt,mb,stk,pci);
+}
+
+str
+DCpause(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+       (void) cntxt;
+       (void) mb;
+       (void) stk;
+       (void) pci;
+       return MAL_SUCCEED;
+}
+
+str
+DCresume(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+       (void) cntxt;
+       (void) mb;
+       (void) stk;
+       (void) pci;
+       return MAL_SUCCEED;
+}
+
+/* initialize all components of the datacell schema */
+str
+DCregister_all(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+       sql_schema  *s;
+       sql_table   *t;
+       mvc *m = NULL;
+       str msg = getContext(cntxt, mb, &m, NULL);
+       sql_trans *tr = m->session->tr;
+       node *o;
+
+       (void)stk;
+       (void)pci;
+       s = mvc_bind_schema(m, schema_default);
+       if (s == NULL)
+               throw(SQL, "datacell.register", "Schema missing");
+       for (o = s->tables.set->h; msg == MAL_SUCCEED && o; o = o->next) {
+               t = o->data;
+
+               /* check double registration */
+               if (BSKTlocate(schema_default, t->base.name))
+                       throw(SQL, "datacell.register", "Basket defined 
twice.");
+               msg = BSKTnewbasket(s, t, tr);
+       }
+       return msg;
+}
+
+str
+DCinventory(int *ret)
+{
+       BAT *b, *bn;
+       int i;
+       str msg = MAL_SUCCEED;
+
+       b = BATnew(TYPE_str, TYPE_bat, 0);
+       if (b == NULL)
+               throw(SQL, "datacell.inventory", MAL_MALLOC_FAIL);
+       for (i = 0; msg == MAL_SUCCEED && i < bsktTop; i++) {
+               bn = BATdescriptor(BBPindex(baskets[i].name));
+               if (bn == NULL)
+                       msg = createException(SQL, "datacell.inventory", 
MAL_MALLOC_FAIL);
+               else {
+                       BUNins(b, baskets[i].name, &bn->batCacheid, FALSE);
+                       BBPreleaseref(bn->batCacheid);
+               }
+       }
+       *ret = b->batCacheid;
+       BBPkeepref(b->batCacheid);
+       return msg;
+}
+
+str
+DCquery(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+       (void) cntxt;
+       (void) mb;
+       (void) stk;
+       (void) pci;
+       return MAL_SUCCEED;
+}
+
+str
+DCrun(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+       (void) cntxt;
+       (void) mb;
+       (void) stk;
+       (void) pci;
+       return MAL_SUCCEED;
+}
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to