Changeset: 70f3f8a014f8 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=70f3f8a014f8
Added Files:
sql/backends/monet5/generator/90_generator.mal
sql/backends/monet5/generator/90_generator.sql
sql/backends/monet5/generator/Makefile.ag
sql/backends/monet5/generator/Tests/All
sql/backends/monet5/generator/Tests/generator00.sql
sql/backends/monet5/generator/Tests/generator00.stable.err
sql/backends/monet5/generator/Tests/generator00.stable.out
sql/backends/monet5/generator/Tests/generator01.sql
sql/backends/monet5/generator/Tests/generator01.stable.err
sql/backends/monet5/generator/Tests/generator01.stable.out
sql/backends/monet5/generator/Tests/generator02.sql
sql/backends/monet5/generator/Tests/generator02.stable.err
sql/backends/monet5/generator/Tests/generator02.stable.out
sql/backends/monet5/generator/Tests/generator03.sql
sql/backends/monet5/generator/Tests/generator03.stable.err
sql/backends/monet5/generator/Tests/generator03.stable.out
sql/backends/monet5/generator/generator.c
sql/backends/monet5/generator/generator.h
sql/backends/monet5/generator/generator.mal
Modified Files:
gdk/gdk.h
gdk/gdk_imprints.c
sql/backends/monet5/Makefile.ag
Branch: transaction-replication
Log Message:
Merge with default branch
diffs (truncated from 1718 to 300 lines):
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -2196,6 +2196,8 @@ gdk_export void IMPSdestroy(BAT *b);
gdk_export BAT *BATimprints(BAT *b);
gdk_export lng IMPSimprintsize(BAT *b);
+gdk_export BAT *BATbloom(BAT *b);
+
/*
* @- Multilevel Storage Modes
*
diff --git a/gdk/gdk_imprints.c b/gdk/gdk_imprints.c
--- a/gdk/gdk_imprints.c
+++ b/gdk/gdk_imprints.c
@@ -902,3 +902,120 @@ do {
\
free(s);
}
#endif
+
+/* round hashing */
+
+#define smpl_xor_rng(R,X) {\
+R = X; \
+R ^= (R<<13); \
+R ^= (R>>17); \
+R ^= (R<<5); \
+}
+
+#define hash_init(S,X,Y,Z) {\
+smpl_xor_rng(X,S); \
+smpl_xor_rng(Y,X); \
+smpl_xor_rng(Z,Y); \
+}
+
+#define next_hash(N,X,Y,Z) {\
+N = (X^(X<<3))^(Y^(Y>>19))^(Z^(Z<<6)); \
+X = Y; \
+Y = Z; \
+Z = N; \
+}
+
+#define hash_mod(V,MOD) ((V) % (MOD))
+
+BAT *
+BATbloom(BAT *b) {
+ BAT *bn;
+ BUN cnt;
+ BUN mn;
+ BUN p;
+ bit *o;
+
+ assert(BAThdense(b)); /* assert void head */
+
+ switch (ATOMstorage(b->T->type)) {
+ case TYPE_bte:
+ case TYPE_sht:
+ case TYPE_int:
+ case TYPE_lng:
+ case TYPE_flt:
+ case TYPE_dbl:
+ break;
+ default: /* type not supported */
+ GDKerror("#BATbloom: col type not "
+ "suitable for bloom filters.\n");
+ return b; /* do nothing */
+ }
+
+ BATcheck(b, "BATblooms");
+
+ cnt = BATcount(b);
+ mn = 4 * cnt; /* make it power of 2 for faster modulo */
+
+ bn = BATnew(TYPE_void, TYPE_bit, mn);
+ if (bn == NULL) {
+ GDKerror("#BATbloom: memory allocation error");
+ return NULL;
+ }
+
+ o = (bit *) Tloc(bn, BUNfirst(bn));
+ for (p = 0; p < mn; p++) {
+ o[p] = 0;
+ }
+
+#define BLOOM_BUILD(TYPE) \
+do {
\
+ oid key,hv,x,y,z; /* for hashing */ \
+ TYPE *ob = (TYPE *)Tloc(b, BUNfirst(b)); \
+ for (p = 0; p < cnt; p++) { \
+ key = (oid) ob[p];
\
+ hash_init(key, x,y,z); \
+ next_hash(hv, x,y,z); \
+ o[hash_mod(hv,mn)] = 1; \
+ next_hash(hv, x,y,z); \
+ o[hash_mod(hv,mn)] = 1; \
+ next_hash(hv, x,y,z); \
+ o[hash_mod(hv,mn)] = 1; \
+ }
\
+} while (0)
+ switch (ATOMstorage(b->T->type)) {
+ case TYPE_bte:
+ BLOOM_BUILD(bte);
+ break;
+ case TYPE_sht:
+ BLOOM_BUILD(sht);
+ break;
+ case TYPE_int:
+ BLOOM_BUILD(int);
+ break;
+ case TYPE_lng:
+ BLOOM_BUILD(lng);
+ break;
+ case TYPE_flt:
+ BLOOM_BUILD(flt);
+ break;
+ case TYPE_dbl:
+ BLOOM_BUILD(dbl);
+ break;
+ default:
+ /* should never reach here */
+ assert(0);
+ }
+
+ /* property management */
+ BATsetcount(bn, mn);
+ bn->trevsorted = 0;
+ bn->tsorted = 0;
+ bn->tkey = 0;
+ bn->tdense = 0;
+ bn->hdense = 1;
+ bn->hseqbase = 0;
+ bn->hkey = 1;
+ bn->hrevsorted = bn->batCount <= 1;
+
+ return bn;
+}
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
HAVE_JSONSTORE?rest HAVE_GSL?gsl
+SUBDIRS = NOT_WIN32?vaults UDF LSST ENABLE_DATACELL?datacell
HAVE_JSONSTORE?rest HAVE_GSL?gsl generator
INCLUDES = ../../include ../../common ../../storage ../../server \
../../../monetdb5/modules/atoms \
diff --git a/sql/backends/monet5/generator/90_generator.mal
b/sql/backends/monet5/generator/90_generator.mal
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/generator/90_generator.mal
@@ -0,0 +1,18 @@
+# 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.
+
+include generator;
diff --git a/sql/backends/monet5/generator/90_generator.sql
b/sql/backends/monet5/generator/90_generator.sql
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/generator/90_generator.sql
@@ -0,0 +1,77 @@
+-- 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.
+
+-- Author M.Kersten
+-- The vault is the container for all foreign file support functionalities
+
+-- example of a (void) foreign file interface
+
+create function sys.generate_series(first tinyint, last tinyint)
+returns table (value tinyint)
+external name vault.generate_series;
+
+create function sys.generate_series(first tinyint, last tinyint, stepsize
tinyint)
+returns table (value tinyint)
+external name vault.generate_series;
+
+create function sys.generate_series(first int, last int)
+returns table (value int)
+external name vault.generate_series;
+
+create function sys.generate_series(first int, last int, stepsize int)
+returns table (value int)
+external name vault.generate_series;
+
+create function sys.generate_series(first bigint, last bigint)
+returns table (value bigint)
+external name vault.generate_series;
+
+create function sys.generate_series(first bigint, last bigint, stepsize bigint)
+returns table (value bigint)
+external name vault.generate_series;
+
+create function sys.generate_series(first real, last real, stepsize real)
+returns table (value real)
+external name vault.generate_series;
+
+create function sys.generate_series(first double, last double, stepsize double)
+returns table (value double)
+external name vault.generate_series;
+
+create function sys.generate_series(first decimal(10,2), last decimal(10,2),
stepsize decimal(10,2))
+returns table (value decimal(10,2))
+external name vault.generate_series;
+
+create function sys.generate_series(first timestamp, last timestamp, stepsize
interval second)
+returns table (value timestamp)
+external name vault.generate_series;
+
+-- create function sys.generate_series(first timestamp, last timestamp,
stepsize interval minute)
+-- returns table (value timestamp)
+-- external name vault.generate_series;
+--
+-- create function sys.generate_series(first timestamp, last timestamp,
stepsize interval hour)
+-- returns table (value timestamp)
+-- external name vault.generate_series;
+--
+-- create function sys.generate_series(first timestamp, last timestamp,
stepsize interval day)
+-- returns table (value timestamp)
+-- external name vault.generate_series;
+--
+-- create function sys.generate_series(first timestamp, last timestamp,
stepsize interval month)
+-- returns table (value timestamp)
+-- external name vault.generate_series;
diff --git a/sql/backends/monet5/generator/Makefile.ag
b/sql/backends/monet5/generator/Makefile.ag
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/generator/Makefile.ag
@@ -0,0 +1,62 @@
+# 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 \
+ ../../../../monetdb5/scheduler \
+ ../../../../clients/mapilib \
+ ../../../../common/options \
+ ../../../../common/stream \
+ ../../../../common/utils \
+ ../../../../gdk \
+ $(READLINE_INCS) $(MSEED_CFLAGS) $(curl_CFLAGS)
+
+lib__generator = {
+ MODULE
+ DIR = libdir/monetdb5
+ SOURCES = generator.c
+ LIBS = ../../../../monetdb5/tools/libmonetdb5 \
+ ../../../../gdk/libbat $(curl_LIBS)
+}
+
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list