Changeset: c876925109c7 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c876925109c7
Added Files:
        sql/backends/monet5/sql_mosaic.c
        sql/backends/monet5/sql_mosaic.h
Branch: mosaic
Log Message:

Added missing files


diffs (252 lines):

diff --git a/sql/backends/monet5/sql_mosaic.c b/sql/backends/monet5/sql_mosaic.c
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/sql_mosaic.c
@@ -0,0 +1,212 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+/* (c) M.L. Kersten
+ * The mosaic interace routines are defined here.
+*/
+#include "monetdb_config.h"
+#include "mal_backend.h"
+#include "sql_scenario.h"
+#include "sql_result.h"
+#include "sql_gencode.h"
+#include "sql_optimizer.h"
+#include "sql_env.h"
+#include "sql_mvc.h"
+#include "sql_mosaic.h"
+#include "mosaic.h"
+#include "sql_scenario.h"
+
+str
+sql_mosaicLayout(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+       mvc *m = NULL;
+       str msg = getSQLContext(cntxt, mb, &m, NULL);
+       sql_trans *tr = m->session->tr;
+       node *nsch, *ntab, *ncol;
+       str sch = 0, tbl = 0, col = 0;
+       BAT *bn, *btech, *bcount, *binput, *boutput, *bproperties;
+       int *tech,*count,*input,*output, *properties;
+
+       if (msg != MAL_SUCCEED || (msg = checkSQLContext(cntxt)) != NULL)
+               return msg;
+       btech = BATnew(TYPE_void, TYPE_str,0, TRANSIENT);
+       if( btech == NULL)
+               throw(SQL,"mosaicLayout", MAL_MALLOC_FAIL);
+       BATseqbase(btech,0);
+       tech = getArgReference_bat(stk, pci, 0);
+       *tech = btech->batCacheid;
+
+       bcount = BATnew(TYPE_void, TYPE_lng,0, TRANSIENT);
+       if( bcount == NULL){
+               BBPunfix(btech->batCacheid);
+               throw(SQL,"mosaicLayout", MAL_MALLOC_FAIL);
+       }
+       BATseqbase(bcount,0);
+       count = getArgReference_bat(stk, pci, 1);
+       *count = bcount->batCacheid;
+
+       binput = BATnew(TYPE_void, TYPE_lng,0, TRANSIENT);
+       if( binput == NULL){
+               BBPunfix(btech->batCacheid);
+               BBPunfix(bcount->batCacheid);
+               throw(SQL,"mosaicLayout", MAL_MALLOC_FAIL);
+       }
+       BATseqbase(binput,0);
+       input = getArgReference_bat(stk, pci, 2);
+       *input = binput->batCacheid;
+
+       boutput = BATnew(TYPE_void, TYPE_lng,0, TRANSIENT);
+       if( boutput == NULL){
+               BBPunfix(btech->batCacheid);
+               BBPunfix(bcount->batCacheid);
+               BBPunfix(binput->batCacheid);
+               throw(SQL,"mosaicLayout", MAL_MALLOC_FAIL);
+       }
+       BATseqbase(boutput,0);
+       output = getArgReference_bat(stk, pci, 3);
+       *output = boutput->batCacheid;
+
+       bproperties = BATnew(TYPE_void, TYPE_str,0, TRANSIENT);
+       if( bproperties == NULL){
+               BBPunfix(btech->batCacheid);
+               BBPunfix(bcount->batCacheid);
+               BBPunfix(binput->batCacheid);
+               BBPunfix(boutput->batCacheid);
+               throw(SQL,"mosaicLayout", MAL_MALLOC_FAIL);
+       }
+       BATseqbase(bproperties,0);
+       properties = getArgReference_bat(stk, pci, 3);
+       *properties = boutput->batCacheid;
+
+       sch = *getArgReference_str(stk, pci, 4);
+       tbl = *getArgReference_str(stk, pci, 5);
+       col = *getArgReference_str(stk, pci, 6);
+
+#ifdef DEBUG_SQL_MOSAIC
+       mnstr_printf(cntxt->fdout, "#mosaic layout %s.%s.%s \n", sch, tbl, col);
+#endif
+       for (nsch = tr->schemas.set->h; nsch; nsch = nsch->next) {
+               sql_base *b = nsch->data;
+               sql_schema *s = (sql_schema *) nsch->data;
+               if (!isalpha((int) b->name[0]))
+                       continue;
+               if (sch && strcmp(sch, b->name))
+                       continue;
+               if (s->tables.set)
+                       for (ntab = (s)->tables.set->h; ntab; ntab = 
ntab->next) {
+                               sql_base *bt = ntab->data;
+                               sql_table *t = (sql_table *) bt;
+
+                               if (tbl && strcmp(bt->name, tbl))
+                                       continue;
+                               if (isTable(t) && t->columns.set)
+                                       for (ncol = (t)->columns.set->h; ncol; 
ncol = ncol->next) {
+                                               sql_base *bc = ncol->data;
+                                               sql_column *c = (sql_column *) 
ncol->data;
+                                               if (col && strcmp(bc->name, 
col))
+                                                       continue;
+                                               // perform the analysis
+                                               bn = 
store_funcs.bind_col(m->session->tr, c, 0);
+                                               MOSlayout(cntxt, bn, btech, 
bcount, binput, boutput, bproperties);
+                                               BBPunfix(bn->batCacheid);
+                                               (void) c;
+                                       }
+                       }
+       }
+       return MAL_SUCCEED;
+}
+
+str
+sql_mosaicAnalysis(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+       mvc *m = NULL;
+       str msg = getSQLContext(cntxt, mb, &m, NULL);
+       sql_trans *tr = m->session->tr;
+       node *nsch, *ntab, *ncol;
+       str sch = 0, tbl = 0, col = 0;
+       int *tech,*output, *factor;
+       BAT *bn, *btech, *boutput, *bfactor;
+       int k;
+       MOStask task = (MOStask) GDKzalloc(sizeof(*task));
+       str compressions = NULL;
+
+       if (msg != MAL_SUCCEED || (msg = checkSQLContext(cntxt)) != NULL)
+               return msg;
+
+       btech = BATnew(TYPE_void, TYPE_str,0, TRANSIENT);
+       if( btech == NULL)
+               throw(SQL,"mosaicAnalysis", MAL_MALLOC_FAIL);
+       BATseqbase(btech,0);
+       tech = getArgReference_bat(stk, pci, 0);
+       *tech = btech->batCacheid;
+
+       boutput = BATnew(TYPE_void, TYPE_lng,0, TRANSIENT);
+       if( boutput == NULL){
+               BBPunfix(btech->batCacheid);
+               throw(SQL,"mosaicAnalysis", MAL_MALLOC_FAIL);
+       }
+       BATseqbase(boutput,0);
+       output = getArgReference_bat(stk, pci, 1);
+       *output = boutput->batCacheid;
+
+       bfactor = BATnew(TYPE_void, TYPE_dbl,0, TRANSIENT);
+       if( bfactor == NULL){
+               BBPunfix(btech->batCacheid);
+               BBPunfix(boutput->batCacheid);
+               throw(SQL,"mosaicAnalysis", MAL_MALLOC_FAIL);
+       }
+       BATseqbase(bfactor,0);
+       factor = getArgReference_bat(stk, pci, 2);
+       *factor = bfactor->batCacheid;
+
+       sch = *getArgReference_str(stk, pci, 3);
+       tbl = *getArgReference_str(stk, pci, 4);
+       col = *getArgReference_str(stk, pci, 5);
+       if ( pci->argc == 7){
+               // use a predefined collection of compression schemes.
+               compressions = *getArgReference_str(stk,pci,6);
+       }
+
+       for( k = 0; k< MOSAIC_METHODS; k++)
+               task->filter[k]= 1;
+#ifdef DEBUG_SQL_MOSAIC
+       mnstr_printf(cntxt->fdout, "#mosaic analysis %s.%s.%s \n", sch, tbl, 
col);
+#endif
+       for (nsch = tr->schemas.set->h; nsch; nsch = nsch->next) {
+               sql_base *b = nsch->data;
+               sql_schema *s = (sql_schema *) nsch->data;
+               if (!isalpha((int) b->name[0]))
+                       continue;
+               if (sch && strcmp(sch, b->name))
+                       continue;
+               if (s->tables.set)
+                       for (ntab = (s)->tables.set->h; ntab; ntab = 
ntab->next) {
+                               sql_base *bt = ntab->data;
+                               sql_table *t = (sql_table *) bt;
+
+                               if (tbl && strcmp(bt->name, tbl))
+                                       continue;
+                               if (isTable(t) && t->columns.set)
+                                       for (ncol = (t)->columns.set->h; ncol; 
ncol = ncol->next) {
+                                               sql_base *bc = ncol->data;
+                                               sql_column *c = (sql_column *) 
ncol->data;
+                                               if (col && strcmp(bc->name, 
col))
+                                                       continue;
+                                               // perform the analysis
+                                               bn = 
store_funcs.bind_col(m->session->tr, c, 0);
+                                               MOSanalyseReport(cntxt, bn, 
btech, boutput, bfactor, compressions);
+                                               BBPunfix(bn->batCacheid);
+                                               (void) c;
+                                       }
+                       }
+       }
+       BBPkeepref(*tech);
+       BBPkeepref(*output);
+       BBPkeepref(*factor);
+       return MAL_SUCCEED;
+}
diff --git a/sql/backends/monet5/sql_mosaic.h b/sql/backends/monet5/sql_mosaic.h
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/sql_mosaic.h
@@ -0,0 +1,30 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+/*  (co) M.L. Kersten */
+#ifndef _SQL_MOSAIC_DEF
+#define _SQL_MOSAIC_DEF
+
+/* #define DEBUG_SQL_MOSAIC */
+
+#include "sql.h"
+
+#ifdef WIN32
+#ifndef LIBSQL
+#define sql5_export extern __declspec(dllimport)
+#else
+#define sql5_export extern __declspec(dllexport)
+#endif
+#else
+#define sql5_export extern
+#endif
+
+sql5_export str sql_mosaicLayout(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
+sql5_export str sql_mosaicAnalysis(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
+
+#endif /* _SQL_MOSAIC_DEF */
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to