Changeset: 6956685baa42 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6956685baa42
Modified Files:
sql/backends/monet5/UDF/80_ssdb.sql
sql/backends/monet5/UDF/ssdb.c
sql/backends/monet5/UDF/ssdb.mal
Branch: ssdb
Log Message:
Some fixes to make the skeleton work
diffs (183 lines):
diff --git a/sql/backends/monet5/UDF/80_ssdb.sql
b/sql/backends/monet5/UDF/80_ssdb.sql
--- a/sql/backends/monet5/UDF/80_ssdb.sql
+++ b/sql/backends/monet5/UDF/80_ssdb.sql
@@ -26,20 +26,20 @@ All Rights Reserved.
-- tin: name of the input table, with columns (obsid int, ord int, x int, y
int)
-- tout: name of the output table, with columns (obsid int)
CREATE PROCEDURE intersects (
- tin CHAR(16), tout CHAR(16), xstart INT, ystart INT, xlen INT, ylen INT)
+ tin CHAR(128), tout CHAR(128), xstart INT, ystart INT, xlen INT, ylen
INT)
EXTERNAL NAME ssdb.intersects;
-- Cooks one pixels value (tin.val) for each image in the input table 'tin'
-- according to the description in the SS-DB paper.
-- tin: name of the input table, with columns (imageid int, x int, y int, val
int)
-- tout: name of the output table, with columns (obsid INT, imageid INT, time
INT, cyclem INT, averageDist REAL, pixelSum BIGINT, centerx INT, centery INT,
boxxstart INT, boxystart INT, boxxend INT, boxyend INT)
-CREATE PROCEDURE cooking (tin CHAR(16), tout CHAR(16), threshold int)
+CREATE PROCEDURE cooking (tin CHAR(128), tout CHAR(128), threshold int)
EXTERNAL NAME ssdb.cooking;
-- Regrid each image in the input table 'tin' according to the definition of
Q3.
-- tin: name of the input table, with columns (imageid int, x int, y int, val
int)
-- tout: name of the output table, with columns (imageid int, x int, y int,
avgval real)
-CREATE PROCEDURE regrid (tin CHAR(16), tout CHAR(16))
+CREATE PROCEDURE regrid (tin CHAR(128), tout CHAR(128))
EXTERNAL NAME ssdb.regrid;
-- Group the pixels in the input table 'tin' into tiles and return the centers
@@ -51,6 +51,6 @@ EXTERNAL NAME ssdb.regrid;
-- tout: name of the output table, with columns (x int, y int, cnt int), i.e.,
-- the center{x,y} of the tiles and the density
CREATE PROCEDURE density (
- tin CHAR(16), tout CHAR(16), tilesize INT, threshold INT)
+ tin CHAR(128), tout CHAR(128), tilesize INT, threshold INT)
EXTERNAL NAME ssdb.density;
diff --git a/sql/backends/monet5/UDF/ssdb.c b/sql/backends/monet5/UDF/ssdb.c
--- a/sql/backends/monet5/UDF/ssdb.c
+++ b/sql/backends/monet5/UDF/ssdb.c
@@ -20,6 +20,7 @@
/* monetdb_config.h must be the first include in each .c file */
#include "monetdb_config.h"
#include "sql.h"
+#include "sql_semantic.h"
#include "ssdb.h"
static sql_table *
@@ -41,14 +42,22 @@ _bind_bat(mvc *sql, sql_table *t, char *
BAT *b = NULL;
sql_column *c = mvc_bind_column(sql, t, cname);
+ /* FIXME: which bat do we get? Do we need to merge base bat with insert
bat? */
if(c)
b = store_funcs.bind_col(sql->session->tr, c, access);
+ if (b && (b->ttype != localtype))
+ return sql_error(sql, 02, "Cooking(): column '%s.%s' has type
%d, expedted %d", t->base.name, cname, b->ttype, localtype);
return b;
}
str
SSDBintersects(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{ /* intersects(tin:str, tout:str, xstart:int, ystart:int, xlen:int,
ylen:int):void */
+ (void) cntxt;
+ (void) mb;
+ (void) stk;
+ (void) pci;
+
return MAL_SUCCEED;
}
@@ -60,11 +69,11 @@ SSDBcooking(Client cntxt, MalBlkPtr mb,
/* tin ((imageid int, x int, y int, val int) */
BAT *imageid_in = NULL, *x = NULL, *y = NULL, *val = NULL;
/* tout (obsid INT, imageid INT, time INT, cyclem INT,
- * averageDist REAL, pixelSum BIGINT, centerx INT,
+ * averagedist REAL, pixelsum BIGINT, centerx INT,
* centery INT, boxxstart INT, boxystart INT, boxxend INT,
* boxyend INT) */
BAT *obsid = NULL, *imageid_out = NULL, *time = NULL, *cyclem = NULL,
- *averageDist = NULL, *pixelSum = NULL, *centerx = NULL,
+ *averagedist = NULL, *pixelsum = NULL, *centerx = NULL,
*centery = NULL, *boxxstart = NULL, *boxystart = NULL, *boxxend
= NULL,
*boxyend = NULL;
str msg = getSQLContext(cntxt, mb, &sql, NULL);
@@ -72,10 +81,16 @@ SSDBcooking(Client cntxt, MalBlkPtr mb,
str tout_name = *(str *) getArgReference(stk, pci, 1 + pci->retc);
int threshold = *(int *) getArgReference(stk, pci, 2 + pci->retc);
- assert(pci->argc - pci->retc == 3 && msg && tin && tout && threshold);
-
if (msg)
return msg;
+ if (pci->argc - pci->retc != 3)
+ return sql_message("COOKING(): 3 parameters expected, got %d",
pci->argc - pci->retc);
+ if (!tin_name)
+ return sql_message("COOKING(): missing name of the input
table");
+ if (!tout_name)
+ return sql_message("COOKING(): missing name of the output
table");
+ if (threshold <= 0)
+ return sql_message("COOKING(): 'threshold' must be a positive
integer");
if(!(tin = _bind_table(sql, tin_name)))
return sql_message("42S02!COOKING(): no such table '%s'",
tin_name);
@@ -100,10 +115,10 @@ SSDBcooking(Client cntxt, MalBlkPtr mb,
return sql_message("42S02!COOKING(): no such column '%s.%s'",
tout_name, "time");
if(!(cyclem = _bind_bat(sql, tout, "cyclem", TYPE_int, RD_INS)))
return sql_message("42S02!COOKING(): no such column '%s.%s'",
tout_name, "cyclem");
- if(!(averageDist = _bind_bat(sql, tout, "averageDist", TYPE_dbl,
RD_INS)))
- return sql_message("42S02!COOKING(): no such column '%s.%s'",
tout_name, "averageDist");
- if(!(pixelSum = _bind_bat(sql, tout, "pixelSum", TYPE_lng, RD_INS)))
- return sql_message("42S02!COOKING(): no such column '%s.%s'",
tout_name, "pixelSum");
+ if(!(averagedist = _bind_bat(sql, tout, "averagedist", TYPE_dbl,
RD_INS)))
+ return sql_message("42S02!COOKING(): no such column '%s.%s'",
tout_name, "averagedist");
+ if(!(pixelsum = _bind_bat(sql, tout, "pixelsum", TYPE_lng, RD_INS)))
+ return sql_message("42S02!COOKING(): no such column '%s.%s'",
tout_name, "pixelsum");
if(!(centerx = _bind_bat(sql, tout, "centerx", TYPE_int, RD_INS)))
return sql_message("42S02!COOKING(): no such column '%s.%s'",
tout_name, "centerx");
if(!(centery = _bind_bat(sql, tout, "centery", TYPE_int, RD_INS)))
@@ -118,18 +133,44 @@ SSDBcooking(Client cntxt, MalBlkPtr mb,
return sql_message("42S02!COOKING(): no such column '%s.%s'",
tout_name, "boxyend");
+ BBPunfix(imageid_in->batCacheid);
+ BBPunfix(x->batCacheid);
+ BBPunfix(y->batCacheid);
+ BBPunfix(val->batCacheid);
+ BBPunfix(obsid->batCacheid);
+ BBPunfix(imageid_out->batCacheid);
+ BBPunfix(time->batCacheid);
+ BBPunfix(cyclem->batCacheid);
+ BBPunfix(averagedist->batCacheid);
+ BBPunfix(pixelsum->batCacheid);
+ BBPunfix(centerx->batCacheid);
+ BBPunfix(centery->batCacheid);
+ BBPunfix(boxxstart->batCacheid);
+ BBPunfix(boxystart->batCacheid);
+ BBPunfix(boxxend->batCacheid);
+ BBPunfix(boxyend->batCacheid);
return MAL_SUCCEED;
}
str
SSDBregrid(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{ /* regrid(tin:str, tout:str):void */
+ (void) cntxt;
+ (void) mb;
+ (void) stk;
+ (void) pci;
+
return MAL_SUCCEED;
}
str
SSDBdensity(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{ /* density(tin:str, tout:str, tilesize:int, threshold:int):void */
+ (void) cntxt;
+ (void) mb;
+ (void) stk;
+ (void) pci;
+
return MAL_SUCCEED;
}
diff --git a/sql/backends/monet5/UDF/ssdb.mal b/sql/backends/monet5/UDF/ssdb.mal
--- a/sql/backends/monet5/UDF/ssdb.mal
+++ b/sql/backends/monet5/UDF/ssdb.mal
@@ -23,14 +23,14 @@ address SSDBintersects
comment "Find the polygons in the table 'tin' that intersect with the bounding
box. Store the IDs of the qualified polygons in the table 'tout'";
pattern cooking(tin:str, tout:str, threshold:int):void
-address SSDB
+address SSDBcooking
comment "Cooks all images in the table 'tin' using 'threshold' into
observations and store them in the table 'tout'";
pattern regrid(tin:str, tout:str):void
-address SSDB
+address SSDBregrid
comment "Regrids all images in the table 'tin' and store results in the table
'tout'";
pattern density(tin:str, tout:str, tilesize:int, threshold:int):void
-address SSDB
+address SSDBdensity
comment "Find tiles which density is larger than 'threshold' and store the
center{x,y} and density of the tiles in the table 'tout'";
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list