Changeset: 5f0aea363cc4 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5f0aea363cc4 Added Files: sql/backends/monet5/BDCC/82_bdcc.mal sql/backends/monet5/BDCC/Makefile.ag sql/backends/monet5/BDCC/bdcc.c sql/backends/monet5/BDCC/bdcc.h sql/backends/monet5/BDCC/bdcc.mal Modified Files: sql/backends/monet5/Makefile.ag Branch: BDCC Log Message:
First BDCC commit diffs (193 lines): diff --git a/sql/backends/monet5/BDCC/82_bdcc.mal b/sql/backends/monet5/BDCC/82_bdcc.mal new file mode 100644 --- /dev/null +++ b/sql/backends/monet5/BDCC/82_bdcc.mal @@ -0,0 +1,1 @@ +include bdcc; diff --git a/sql/backends/monet5/BDCC/Makefile.ag b/sql/backends/monet5/BDCC/Makefile.ag new file mode 100644 --- /dev/null +++ b/sql/backends/monet5/BDCC/Makefile.ag @@ -0,0 +1,59 @@ +# 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-2014 MonetDB B.V. +# All Rights Reserved. + +INCLUDES = .. \ + ../../../include \ + ../../../common \ + ../../../storage \ + ../../../server \ + ../../../../monetdb5/modules/atoms \ + ../../../../monetdb5/modules/kernel \ + ../../../../monetdb5/mal \ + ../../../../monetdb5/modules/mal \ + ../../../../monetdb5/optimizer \ + ../../../../clients/mapilib \ + ../../../../common/options \ + ../../../../common/stream \ + ../../../../gdk + +lib__bdcc = { + MODULE + DIR = libdir/monetdb5 + SOURCES = bdcc.c bdcc.h + LIBS = ../../../../monetdb5/tools/libmonetdb5 \ + ../../../../gdk/libbat +} + +headers_mal = { + HEADERS = mal + DIR = libdir/monetdb5 + SOURCES = bdcc.mal +} + +# headers_sql = { +# HEADERS = sql +# DIR = libdir/monetdb5/createdb +# SOURCES = 82_bdcc.sql +# } + +headers_autoload = { + HEADERS = mal + DIR = libdir/monetdb5/autoload + SOURCES = 82_bdcc.mal +} + +# EXTRA_DIST_DIR = Tests diff --git a/sql/backends/monet5/BDCC/bdcc.c b/sql/backends/monet5/BDCC/bdcc.c new file mode 100644 --- /dev/null +++ b/sql/backends/monet5/BDCC/bdcc.c @@ -0,0 +1,66 @@ +#include "bdcc.h" + +int xtrRev (int n, int m); + +int xtrRev (int n, int m) { + int mul; + int res; + + for (mul = 1, res = 0; n & m; n >>= 1, m >>= 1) + if (m % 2) { + if (n % 2) res |= mul; + + mul <<= 1; + } + + return res; +} + +bdcc_export char * BDCCxtrRev (bat * res, bat * b, int * m) { + BAT * B = BATdescriptor(*b); + BAT * Res = BATcopy(B, TYPE_void, TYPE_int, TRUE); + + int mIsRShift; + int mCopy = *m; + int mVal = *m; + int seenOne; + int numRShift; + + BUN i; + BATiter ResI = bat_iterator(Res); + BUN ResL; + + if (BATcount(B) == 0 || Res == NULL) throw(MAL, "bdcc.xtrRev", "ERROR"); + + for (mIsRShift = 1, seenOne = 0, numRShift = 0; mCopy; mCopy >>= 1) { + if (mCopy % 2) { + if (!seenOne) seenOne = 1; + } + else { + if (seenOne) { + mIsRShift = 0; + break; + } + else numRShift++; + } + } + + if (mIsRShift) + for (i = BUNfirst(Res), ResL = BUNlast(Res); i < ResL; i++) { + int * ResLoc = (int *) BUNtail(ResI, i); + + *ResLoc = *ResLoc >> numRShift; + } + + else for (i = BUNfirst(Res), ResL = BUNlast(Res); i < ResL; i++) { + int * ResLoc = (int *) BUNtail(ResI, i); + + *ResLoc = xtrRev(*ResLoc, mVal); + } + + Res->tsorted = (B->tsorted && mIsRShift) ? 1 : 0; + + BBPkeepref(*res = Res->batCacheid); + + return MAL_SUCCEED; +} diff --git a/sql/backends/monet5/BDCC/bdcc.h b/sql/backends/monet5/BDCC/bdcc.h new file mode 100644 --- /dev/null +++ b/sql/backends/monet5/BDCC/bdcc.h @@ -0,0 +1,19 @@ +#ifndef _SQL_BDCC_H_ +#define _SQL_BDCC_H_ + +#include "monetdb_config.h" +#include "mal_exception.h" + +#ifdef WIN32 +#ifndef LIBBDCC +#define bdcc_export extern __declspec(dllimport) +#else +#define bdcc_export extern __declspec(dllexport) +#endif +#else +#define bdcc_export extern +#endif + +bdcc_export char * BDCCxtrRev (bat * res, bat * b, int * m); + +#endif diff --git a/sql/backends/monet5/BDCC/bdcc.mal b/sql/backends/monet5/BDCC/bdcc.mal new file mode 100644 --- /dev/null +++ b/sql/backends/monet5/BDCC/bdcc.mal @@ -0,0 +1,11 @@ +module bdcc; + +command xtrRev(b:bat[:oid,:int], mask:int):bat[:oid,:int] +address BDCCxtrRev; + +function xtrJoin(x:bat[:oid,:int], y:bat[:oid,:int], xM:int, yM:int) (l:bat[:oid,:oid],r:bat[:oid,:oid]); + xRev := xtrRev(x, xM); + yRev := xtrRev(y, yM); + (l, r) := algebra.join(xRev, yRev); + return (l, r); +end xtrJoin; diff --git a/sql/backends/monet5/Makefile.ag b/sql/backends/monet5/Makefile.ag --- a/sql/backends/monet5/Makefile.ag +++ b/sql/backends/monet5/Makefile.ag @@ -15,7 +15,7 @@ # Copyright August 2008-2014 MonetDB B.V. # All Rights Reserved. -SUBDIRS = NOT_WIN32?vaults UDF LSST ENABLE_DATACELL?datacell +SUBDIRS = NOT_WIN32?vaults UDF LSST ENABLE_DATACELL?datacell BDCC INCLUDES = ../../include ../../common ../../storage ../../server \ ../../../monetdb5/modules/atoms \ _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list