Changeset: ec15e556569c for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ec15e556569c Added Files: sql/backends/monet5/UDF/80_ssdb.mal sql/backends/monet5/UDF/80_ssdb.sql sql/backends/monet5/UDF/ssdb.c sql/backends/monet5/UDF/ssdb.h sql/backends/monet5/UDF/ssdb.mal Modified Files: sql/backends/monet5/UDF/Makefile.ag Branch: ssdb Log Message:
initialised the implementation for the UDFs needed by the SS-DB benchmark diffs (truncated from 353 to 300 lines): diff --git a/sql/backends/monet5/UDF/80_ssdb.mal b/sql/backends/monet5/UDF/80_ssdb.mal new file mode 100644 --- /dev/null +++ b/sql/backends/monet5/UDF/80_ssdb.mal @@ -0,0 +1,20 @@ +# 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://www.monetdb.org/Legal/MonetDBLicense +# +# 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-July 2008 CWI. +# Copyright August 2008-2012 MonetDB B.V. +# All Rights Reserved. + +# This announces the SSDB module to the MAL interpreter + +include ssdb; diff --git a/sql/backends/monet5/UDF/80_ssdb.sql b/sql/backends/monet5/UDF/80_ssdb.sql new file mode 100644 --- /dev/null +++ b/sql/backends/monet5/UDF/80_ssdb.sql @@ -0,0 +1,56 @@ +/* +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://www.monetdb.org/Legal/MonetDBLicense + +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-July 2008 CWI. +Copyright August 2008-2012 MonetDB B.V. +All Rights Reserved. +*/ + +-- This file defines the signatures of the UDFs needed to run the SS-DB +-- benchmark on MonetDB + +-- Determines for each polygon in the input table 'tin' if it intersects with +-- the bounding box by [(xstart, ystart), (xstart+xlen, ystart+ylen) +-- The ID of the intersecting polygons are stored in the output table 'tout' +-- 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) +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) +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)) +EXTERNAL NAME ssdb.regrid; + +-- Group the pixels in the input table 'tin' into tiles and return the centers +-- (x,y) and the number of observations, i.e., cnt, in those tiles, where +-- cnt > $threshold +-- See for more information the definition of Q6. +-- tin: name of the input table, with columns (x int, y int), i.e., the +-- center{x,y} of all observations. +-- 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) +EXTERNAL NAME ssdb.density; + diff --git a/sql/backends/monet5/UDF/Makefile.ag b/sql/backends/monet5/UDF/Makefile.ag --- a/sql/backends/monet5/UDF/Makefile.ag +++ b/sql/backends/monet5/UDF/Makefile.ag @@ -38,22 +38,30 @@ lib__udf = { ../../../../gdk/libbat } +lib__ssdb = { + MODULE + DIR = libdir/monetdb5 + SOURCES = ssdb.c ssdb.h + LIBS = ../../../../monetdb5/tools/libmonetdb5 \ + ../../../../gdk/libbat +} + headers_mal = { HEADERS = mal DIR = libdir/monetdb5 - SOURCES = udf.mal + SOURCES = udf.mal ssdb.mal } headers_sql = { HEADERS = sql DIR = libdir/monetdb5/createdb - SOURCES = 80_udf.sql + SOURCES = 80_udf.sql 80_ssdb.sql } headers_autoload = { HEADERS = mal DIR = libdir/monetdb5/autoload - SOURCES = 80_udf.mal + SOURCES = 80_udf.mal 80_ssdb.mal } EXTRA_DIST_DIR = Tests diff --git a/sql/backends/monet5/UDF/ssdb.c b/sql/backends/monet5/UDF/ssdb.c new file mode 100644 --- /dev/null +++ b/sql/backends/monet5/UDF/ssdb.c @@ -0,0 +1,135 @@ +/* + * 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://www.monetdb.org/Legal/MonetDBLicense + * + * 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-July 2008 CWI. + * Copyright August 2008-2012 MonetDB B.V. + * All Rights Reserved. + */ + +/* monetdb_config.h must be the first include in each .c file */ +#include "monetdb_config.h" +#include "sql.h" +#include "ssdb.h" + +static sql_table * +_bind_table(mvc *sql, char *tname) +{ + sql_table *t = mvc_bind_table(sql, cur_schema(sql), tname); + + if(!t) + t = mvc_bind_table(sql, mvc_bind_schema(sql, "sys"), tname); + if(!t) + t = mvc_bind_table(sql, tmp_schema(sql), tname); + + return t; +} + +static BAT * +_bind_bat(mvc *sql, sql_table *t, char *cname, int localtype, int access) +{ + BAT *b = NULL; + sql_column *c = mvc_bind_column(sql, t, cname); + + if(c) + b = store_funcs.bind_col(sql->session->tr, c, access); + 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 */ + return MAL_SUCCEED; +} + +str +SSDBcooking(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) +{ /* cooking(tin:str, tout:str, threshold:int):void */ + mvc *sql = NULL; + sql_table *tin = NULL, *tout = NULL; + /* 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, + * 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, + *centery = NULL, *boxxstart = NULL, *boxystart = NULL, *boxxend = NULL, + *boxyend = NULL; + str msg = getSQLContext(cntxt, mb, &sql, NULL); + str tin_name = *(str *) getArgReference(stk, pci, 0 + pci->retc); + 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(!(tin = _bind_table(sql, tin_name))) + return sql_message("42S02!COOKING(): no such table '%s'", tin_name); + if(!(tout = _bind_table(sql, tout_name))) + return sql_message("42S02!COOKING(): no such table '%s'", tout_name); + + /* get the BATs of all columns of the input table */ + if(!(imageid_in = _bind_bat(sql, tin, "imageid", TYPE_int, RDONLY))) + return sql_message("42S02!COOKING(): no such column '%s.%s'", tin_name, "imageid"); + if(!(x = _bind_bat(sql, tin, "x", TYPE_int, RDONLY))) + return sql_message("42S02!COOKING(): no such column '%s.%s'", tin_name, "x"); + if(!(y = _bind_bat(sql, tin, "y", TYPE_int, RDONLY))) + return sql_message("42S02!COOKING(): no such column '%s.%s'", tin_name, "y"); + if(!(val = _bind_bat(sql, tin, "val", TYPE_int, RDONLY))) + return sql_message("42S02!COOKING(): no such column '%s.%s'", tin_name, "val"); + /* get the BATs of all columns of the output table */ + if(!(obsid = _bind_bat(sql, tout, "obsid", TYPE_int, RD_INS))) + return sql_message("42S02!COOKING(): no such column '%s.%s'", tout_name, "obsid"); + if(!(imageid_out = _bind_bat(sql, tout, "imageid", TYPE_int, RD_INS))) + return sql_message("42S02!COOKING(): no such column '%s.%s'", tout_name, "imageid"); + if(!(time = _bind_bat(sql, tout, "time", TYPE_int, RD_INS))) + 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(!(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))) + return sql_message("42S02!COOKING(): no such column '%s.%s'", tout_name, "centery"); + if(!(boxxstart = _bind_bat(sql, tout, "boxxstart", TYPE_int, RD_INS))) + return sql_message("42S02!COOKING(): no such column '%s.%s'", tout_name, "boxxstart"); + if(!(boxystart = _bind_bat(sql, tout, "boxystart", TYPE_int, RD_INS))) + return sql_message("42S02!COOKING(): no such column '%s.%s'", tout_name, "boxystart"); + if(!(boxxend = _bind_bat(sql, tout, "boxxend", TYPE_int, RD_INS))) + return sql_message("42S02!COOKING(): no such column '%s.%s'", tout_name, "boxxend"); + if(!(boxyend = _bind_bat(sql, tout, "boxyend", TYPE_int, RD_INS))) + return sql_message("42S02!COOKING(): no such column '%s.%s'", tout_name, "boxyend"); + + + return MAL_SUCCEED; +} + +str +SSDBregrid(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) +{ /* regrid(tin:str, tout:str):void */ + return MAL_SUCCEED; +} + +str +SSDBdensity(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) +{ /* density(tin:str, tout:str, tilesize:int, threshold:int):void */ + return MAL_SUCCEED; +} + diff --git a/sql/backends/monet5/UDF/ssdb.h b/sql/backends/monet5/UDF/ssdb.h new file mode 100644 --- /dev/null +++ b/sql/backends/monet5/UDF/ssdb.h @@ -0,0 +1,44 @@ +/* + * 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://www.monetdb.org/Legal/MonetDBLicense + * + * 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-July 2008 CWI. + * Copyright August 2008-2012 MonetDB B.V. + * All Rights Reserved. +*/ + +#ifndef _SQL_SSDB_H_ +#define _SQL_SSDB_H_ +#include "sql.h" +#include <string.h> + +/* The follwoing is required as-is for all modules for correctly exporting + * function on Unix-like and Windows systems. */ +#ifdef WIN32 +#ifndef LIBSSDB +#define ssdb_export extern __declspec(dllimport) +#else +#define ssdb_export extern __declspec(dllexport) +#endif _______________________________________________ checkin-list mailing list [email protected] http://mail.monetdb.org/mailman/listinfo/checkin-list
