Changeset: 26239957e3d7 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=26239957e3d7 Modified Files: monetdb5/modules/mal/mosaic.c monetdb5/modules/mal/mosaic.h sql/backends/monet5/sql.mal sql/backends/monet5/sql_mosaic.c sql/scripts/76_compression.sql Branch: mosaic Log Message:
First step into mosaic layout analysis The layout can be obtained as an ordinary SQL table for further analysis diffs (170 lines): diff --git a/monetdb5/modules/mal/mosaic.c b/monetdb5/modules/mal/mosaic.c --- a/monetdb5/modules/mal/mosaic.c +++ b/monetdb5/modules/mal/mosaic.c @@ -74,13 +74,30 @@ MOSdumpTask(Client cntxt,MOStask task) } str -MOSlayout(Client cntxt, BAT *b, BAT *btech, BAT *bcount, BAT *binput, BAT *boutput, BAT *bproperties) +MOSlayout(Client cntxt, BAT *b, BAT *btech, BAT *bcount, BAT *binput, BAT *boutput, BAT *bproperties, str compressionscheme) { MOStask task=0; + int i,ret,bid; + BAT *bn= NULL; task= (MOStask) GDKzalloc(sizeof(*task)); if( task == NULL) throw(SQL,"mosaic",MAL_MALLOC_FAIL); + + if(compressionscheme){ + //create a tempory compressed column + for( i = 0; i< MOSAIC_METHODS; i++) + task->filter[i]= strstr(compressionscheme, MOSfiltername[i]) != 0; + bid = b->batCacheid; + MOScompressInternal(cntxt, &ret, &bid, task,0,FALSE); + if( ret == 0) + throw(MAL,"mosaic.layout","Compression failed"); + bn = BATdescriptor(ret); + if( bn == NULL) + throw(MAL,"mosaic.layout", RUNTIME_OBJECT_MISSING); + b = bn; + } + MOSinit(task,b); MOSinitializeScan(cntxt,task,0,task->hdr->top); while(task->start< task->stop){ @@ -110,6 +127,8 @@ MOSlayout(Client cntxt, BAT *b, BAT *bte MOSadvance_frame(cntxt,task); } } + if( bn) + BBPunfix(bn->batCacheid); return MAL_SUCCEED; } @@ -1330,7 +1349,7 @@ makepatterns(int *patterns, int size, st int candidate[MOSAIC_METHODS]= {0}; for( i = 0; i < MOSAIC_METHODS; i++) - candidate[i] = strstr(compressions,MOSfiltername[i]) != 0; + candidate[i] = compressions == NULL || strstr(compressions,MOSfiltername[i]) != 0; for( k=0, i=0; i<lim && k <size; i++){ patterns[k]=0; @@ -1669,7 +1688,7 @@ MOSoptimize(Client cntxt, MalBlkPtr mb, bid = *getArgReference_int(stk,pci,1); MOSblocklimit = 100000; - for( i = 0; i < 1024; i++) + for( i = 0; i < CANDIDATES; i++) xf[i]= -1; for( i = 1; i< cases; i++){ diff --git a/monetdb5/modules/mal/mosaic.h b/monetdb5/modules/mal/mosaic.h --- a/monetdb5/modules/mal/mosaic.h +++ b/monetdb5/modules/mal/mosaic.h @@ -217,7 +217,7 @@ mosaic_export str MOSthetasubselect(Clie mosaic_export str MOSleftfetchjoin(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); mosaic_export str MOSjoin(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); mosaic_export str MOSdump(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); -mosaic_export str MOSlayout(Client cntxt, BAT *b, BAT *btech, BAT *bcount, BAT *binput, BAT *boutput, BAT *bproperties); +mosaic_export str MOSlayout(Client cntxt, BAT *b, BAT *btech, BAT *bcount, BAT *binput, BAT *boutput, BAT *bproperties, str compressionscheme); mosaic_export str MOSsliceInternal(Client cntxt, bat *slices, BUN size, BAT *b); mosaic_export int MOSanalyseInternal(Client cntxt, int threshold, MOStask task, bat bid); mosaic_export void MOSanalyseReport(Client cntxt, BAT *b, BAT *btech, BAT *output, BAT *factor, str compressions); diff --git a/sql/backends/monet5/sql.mal b/sql/backends/monet5/sql.mal --- a/sql/backends/monet5/sql.mal +++ b/sql/backends/monet5/sql.mal @@ -477,6 +477,13 @@ pattern storage()( address sql_storage comment "return a table with storage information "; +pattern mosaicLayout(sch:str,tbl:str,col:str,compressionscheme:str)( + technique:bat[:oid,:str], + count:bat[:oid,:lng], + inputsize:bat[:oid,:lng], + outputsize:bat[:oid,:lng], + properties:bat[:oid,:str]) +address sql_mosaicLayout; pattern mosaicLayout(sch:str,tbl:str,col:str)( technique:bat[:oid,:str], count:bat[:oid,:lng], diff --git a/sql/backends/monet5/sql_mosaic.c b/sql/backends/monet5/sql_mosaic.c --- a/sql/backends/monet5/sql_mosaic.c +++ b/sql/backends/monet5/sql_mosaic.c @@ -31,6 +31,7 @@ sql_mosaicLayout(Client cntxt, MalBlkPtr str sch = 0, tbl = 0, col = 0; BAT *bn, *btech, *bcount, *binput, *boutput, *bproperties; int *tech,*count,*input,*output, *properties; + str compressionscheme= NULL; if (msg != MAL_SUCCEED || (msg = checkSQLContext(cntxt)) != NULL) return msg; @@ -80,12 +81,16 @@ sql_mosaicLayout(Client cntxt, MalBlkPtr throw(SQL,"mosaicLayout", MAL_MALLOC_FAIL); } BATseqbase(bproperties,0); - properties = getArgReference_bat(stk, pci, 3); - *properties = boutput->batCacheid; + properties = getArgReference_bat(stk, pci, 4); + *properties = bproperties->batCacheid; - sch = *getArgReference_str(stk, pci, 4); - tbl = *getArgReference_str(stk, pci, 5); - col = *getArgReference_str(stk, pci, 6); + sch = *getArgReference_str(stk, pci, 5); + tbl = *getArgReference_str(stk, pci, 6); + col = *getArgReference_str(stk, pci, 7); + if ( pci->argc == 9){ + // use a predefined collection of compression schemes. + compressionscheme = *getArgReference_str(stk,pci,8); + } #ifdef DEBUG_SQL_MOSAIC mnstr_printf(cntxt->fdout, "#mosaic layout %s.%s.%s \n", sch, tbl, col); @@ -112,12 +117,17 @@ sql_mosaicLayout(Client cntxt, MalBlkPtr continue; // perform the analysis bn = store_funcs.bind_col(m->session->tr, c, 0); - MOSlayout(cntxt, bn, btech, bcount, binput, boutput, bproperties); + MOSlayout(cntxt, bn, btech, bcount, binput, boutput, bproperties, compressionscheme); BBPunfix(bn->batCacheid); (void) c; } } } + BBPkeepref(*tech); + BBPkeepref(*count); + BBPkeepref(*input); + BBPkeepref(*output); + BBPkeepref(*properties); return MAL_SUCCEED; } @@ -131,7 +141,6 @@ sql_mosaicAnalysis(Client cntxt, MalBlkP str sch = 0, tbl = 0, col = 0; int *tech,*output, *factor; BAT *bn, *btech, *boutput, *bfactor; - int k; str compressions = NULL; if (msg != MAL_SUCCEED || (msg = checkSQLContext(cntxt)) != NULL) diff --git a/sql/scripts/76_compression.sql b/sql/scripts/76_compression.sql --- a/sql/scripts/76_compression.sql +++ b/sql/scripts/76_compression.sql @@ -31,6 +31,15 @@ returns table ( properties string -- additional information ) external name sql."mosaicLayout"; +create function mosaic.layout(sch string, tbl string, col string, compressionscheme string) +returns table ( + "technique" string, -- any of the built-in compressors + header + "count" bigint, -- entries covered + inputsize bigint, -- original storage footprint + outputsize bigint, -- after compression + properties string -- additional information + ) external name sql."mosaicLayout"; + -- provide an analysis of the possible mosaic storage layouts create function mosaic.analysis(sch string, tbl string, col string) returns table( _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list