Changeset: 9ce5dcff5a8d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9ce5dcff5a8d
Modified Files:
        sql/backends/monet5/datacell/Tests/datacell00.sql
        sql/backends/monet5/datacell/Tests/poc.sql
        sql/backends/monet5/datacell/datacell.mx
        sql/backends/monet5/datacell/sensor.mx
Branch: default
Log Message:

A few minor adjustments.
A few limitations in the current SQL implementation makes it hard
to access the datacell specific routines right away.


diffs (227 lines):

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
@@ -1,11 +1,11 @@
 #set up the minimal test environment for datacell
 
 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);
+create table datacell.X( id string, tag timestamp, payload int);
+create table datacell.Y( id string, tag timestamp, payload int, msdelay int);
 
 -- the continoues query
-create procedure datacell.tranport()
+create procedure datacell.transport()
 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;
diff --git a/sql/backends/monet5/datacell/Tests/poc.sql 
b/sql/backends/monet5/datacell/Tests/poc.sql
--- a/sql/backends/monet5/datacell/Tests/poc.sql
+++ b/sql/backends/monet5/datacell/Tests/poc.sql
@@ -6,7 +6,7 @@
 create schema datacell;
 set optimizer='datacell_pipe';
 
-create table datacell.basket_X(
+create table datacell.sysIn(
     id integer auto_increment,
     tag timestamp default now(),
     payload integer
@@ -14,49 +14,49 @@
 
 -- to be used by continous queries
 -- could be generated from the table definition.
-create function datacell.basket_X()
+create function datacell.sysIn()
 returns table (id integer, tag timestamp, payload integer)
 begin
-       return select * from datacell.basket_X;
+       return select * from datacell.sysIn;
 end;
 
-select * from datacell.basket_X();
+select * from datacell.sysIn();
 
 -- to be used by receptor thread
-create function datacell.receptor_X()
+create function datacell.receptor_sysIn()
 returns boolean
 begin
-       insert into datacell.basket_X(payload) values ( 1);
+       insert into datacell.sysIn(payload) values ( 1);
        return true;
 end;
 
-call register_basket('datacell.basket_x');
-call register_receptor('datacell.receptor_x','localhost:50100');
-call start_receptor('datacell.receptor_x');
+call datacell.basket('datacell','sysIn');
+call datacell.receptor('datacell','sysIn','localhost','50500');
+call datacell.start('datacell','sysIn');
 
-create table datacell.basket_Y( etag timestamp, like datacell.basket_X);
+create table datacell.sysOut( etag timestamp, like datacell.sysIn);
 
 -- the continues query is registered and started
-create procedure datacell.query_X_Y()
+create procedure datacell.query_sysIn_sysOut()
 begin
-       insert into datacell.basket_Y select now(), *  from datacell.basket_X() 
;
+       insert into datacell.sysOut select now(), *  from datacell.sysIn() ;
 end;
-call register_query('datacell.query_X_Y');
-call start_query('datacell.query_X_Y');
+call register_query('datacell.query_sysIn_sysOut');
+call start_query('datacell.query_sysIn_sysOut');
 
-create function datacell.basket_Y()
+create function datacell.sysOut()
 returns table (id integer)
 begin
-       return select * from datacell.basket_Y;
+       return select * from datacell.sysOut;
 end;
 
 -- sent it over the wire.
-create function datacell.emitter_Y()
+create function datacell.emitter_sysOut()
 returns boolean;
 begin
-       select * from datacell.basket_Y();
+       select * from datacell.sysOut();
        return true;
 end;
-call register_basket('basket_y');
-call register_emitter('emitter_y','localhost:50101');
-call start_emitter('emitter_y');
+call datacell.basket('datacell','sysOut');
+call datacell.emitter('datacell','sysOut','localhost:50101');
+call datacell.start('datacell','sysOut');
diff --git a/sql/backends/monet5/datacell/datacell.mx 
b/sql/backends/monet5/datacell/datacell.mx
--- a/sql/backends/monet5/datacell/datacell.mx
+++ b/sql/backends/monet5/datacell/datacell.mx
@@ -184,14 +184,22 @@
        return msg;
 }
 
+/* locate the MAL representation of this operation and extract the flow */
+/* If the operation is not available yet, it should be compiled from its
+   definition retained in the SQL catalog */
 str
 DCquery(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
-       (void) cntxt;
+       str modnme = *(str*) getArgReference(stk,pci,1);
+       str fcnnme = *(str*) getArgReference(stk,pci,2);
+       Symbol s;
+
        (void) mb;
-       (void) stk;
-       (void) pci;
-       return MAL_SUCCEED;
+       s = findSymbol(cntxt->nspace, putName(modnme, strlen(modnme)), 
putName(fcnnme, strlen(fcnnme)));
+       if ( s == NULL) {
+               /* fetch and compile its definition */
+       }
+       throw(SQL,"datacell.query","Procedure code does not exist");
 }
 
 /*
diff --git a/sql/backends/monet5/datacell/sensor.mx 
b/sql/backends/monet5/datacell/sensor.mx
--- a/sql/backends/monet5/datacell/sensor.mx
+++ b/sql/backends/monet5/datacell/sensor.mx
@@ -89,7 +89,8 @@
 static int batchsize = 1;
 static int sequence = -1;
 static int columns = 1;
-static int stamp = 1; /*if (timestamp!=0) sensor sends also the tsmp */
+static int autoincrement = 1;  /* if id != 0 then we increment and sent it 
along */
+static int timestamp = 1; /*if (timestamp!=0) sensor sends also the tsmp */
 static char *host = "localhost";
 static int port = 50500;
 static int trace = 0;
@@ -109,6 +110,7 @@
        mnstr_printf(SEout, "--port=<portnr>, default=50500 \n");
        mnstr_printf(SEout, "--sensor=<name> \n");
        mnstr_printf(SEout, "--protocol=<name> udp or tcp(default) \n");
+       mnstr_printf(SEout, "--autoincrement=<number>, default=0 \n");
        mnstr_printf(SEout, "--timestamp, default=off\n");
        mnstr_printf(SEout, "--columns=<number>, default=1\n");
        mnstr_printf(SEout, "--sequence=<sequence length>, (-1=forever,>0), 
default=1\n");
@@ -158,12 +160,13 @@
        char hostname[1024];
        Sensor se = NULL;
        static SOCKET sockfd;
-       static struct option long_options[15] = {
+       static struct option long_options[16] = {
+               { "autoincrement", 0, 0, 'a' },
                { "batch", 1, 0, 'b' },
                { "columns", 1, 0, 'c' },
                { "client", 0, 0, 'c' },
                { "port", 1, 0, 'p' },
-               { "timestamp", 1, 0, 't' },
+               { "timestamp", 0, 0, 't' },
                { "sequence", 1, 0, 's' },
                { "sensor", 1, 0, 's' },
                { "server", 0, 0, 's' },
@@ -182,7 +185,7 @@
        }
        for (;; ) {
                int option_index = 0;
-               int c = getopt_long(argc, argv, "b:c:p:s:d:f:h:t:?:0",
+               int c = getopt_long(argc, argv, "b:i:c:p:s:d:f:h:t:?:0",
                        long_options, &option_index);
                if (c == -1)
                        break;
@@ -213,9 +216,16 @@
                                exit(0);
                        }
                        break;
+               case 'a':
+                       autoincrement = optarg? atol(optarg): 0;
+                       if (autoincrement < 0) {
+                               mnstr_printf(SEout, "Illegal autoincrement 
%d\n", autoincrement);
+                               exit(0);
+                       }
+                       break;
                case 't':
                        if (strcmp(long_options[option_index].name, 
"timestamp") == 0) {
-                               stamp = optarg? atol(optarg): 0;
+                               timestamp = 1;
                                break;
                        }
                        if (strcmp(long_options[option_index].name, "trace") == 
0) {
@@ -301,7 +311,8 @@
                mnstr_printf(SEout, "--port=%d\n", port);
                mnstr_printf(SEout, "--sensor=%s\n", sensor);
                mnstr_printf(SEout, "--columns=%d\n", columns);
-               mnstr_printf(SEout, "--timestamp=%d\n", stamp);
+               mnstr_printf(SEout, "--autoincrement=%d\n", autoincrement);
+               mnstr_printf(SEout, "--timestamp=%d\n", timestamp);
                mnstr_printf(SEout, "--sequence=%d\n", sequence);
                mnstr_printf(SEout, "--batch=%d\n", batchsize);
                mnstr_printf(SEout, "--delay=%d\n", delay);
@@ -454,7 +465,12 @@
                           the wall-clock microstamp. This reduces the number of
                           additional columns to be produced by 1 */
                        tlen = 0;
-                       if (stamp) {
+                       if (autoincrement) {
+                               snprintf(tuple + tlen, maxtuple - tlen, "%d", 
autoincrement);
+                               tlen += (int)strlen(tuple + tlen);
+                               autoincrement++;
+                       }
+                       if (timestamp) {
                                currenttsmp = GDKusec();
 
                                snprintf(tuple + tlen, maxtuple - tlen, "%lld", 
currenttsmp);
@@ -466,7 +482,7 @@
                                }
                        }
 
-                       for (i = stamp ? 1 : 0; i < columns; i++) {
+                       for (i = (timestamp ? 1 : 0) + (autoincrement?1:0); i < 
columns; i++) {
                                if (i)
                                        snprintf(tuple + tlen, maxtuple - tlen, 
",%d", rand());
                                else
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to