Changeset: b0aa66d63743 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b0aa66d63743
Modified Files:
        common/utils/mutils.c
        debian/monetdb5-server.manpages
Branch: default
Log Message:

Merge with Apr2011 branch.


diffs (truncated from 1020 to 300 lines):

diff --git a/common/utils/mutils.c b/common/utils/mutils.c
--- a/common/utils/mutils.c
+++ b/common/utils/mutils.c
@@ -23,6 +23,9 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <stdlib.h>
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
 #include "mutils.h"
 
 #ifdef HAVE_EXECINFO_H
diff --git a/debian/monetdb-client-testing.install 
b/debian/monetdb-client-testing.install
--- a/debian/monetdb-client-testing.install
+++ b/debian/monetdb-client-testing.install
@@ -6,8 +6,6 @@
 debian/tmp/usr/bin/smack00 usr/bin
 debian/tmp/usr/bin/smack01 usr/bin
 debian/tmp/usr/bin/malsample.pl usr/bin
-debian/tmp/usr/bin/milsample.pl usr/bin
 debian/tmp/usr/bin/sqlsample.php usr/bin
 debian/tmp/usr/bin/sqlsample.pl usr/bin
 debian/tmp/usr/bin/sqlsample.py usr/bin
-debian/tmp/usr/bin/xquerysample.php usr/bin
diff --git a/debian/monetdb5-server.manpages b/debian/monetdb5-server.manpages
deleted file mode 100644
--- a/debian/monetdb5-server.manpages
+++ /dev/null
@@ -1,1 +0,0 @@
-debian/tmp/usr/share/man/man5/monetdb5.conf.5
diff --git a/monetdb5/optimizer/optimizerWrapper.mx 
b/monetdb5/optimizer/optimizerWrapper.mx
--- a/monetdb5/optimizer/optimizerWrapper.mx
+++ b/monetdb5/optimizer/optimizerWrapper.mx
@@ -83,6 +83,8 @@
                mnstr_printf(cntxt->fdout,"=FINISHED @1 %d\n",actions);
                printFunction(cntxt->fdout,mb,0,LIST_MAL_STMT | LIST_MAPI);
        }
+       DEBUGoptimizers
+               mnstr_printf(cntxt->fdout,"#opt_reduce: %d ms\n",t);
        QOTupdateStatistics("@1",actions,t);
        addtoMalBlkHistory(mb,"@1");
        return msg;
diff --git a/sql/backends/monet5/LSST/80_lsst.mal 
b/sql/backends/monet5/LSST/80_lsst.mal
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/LSST/80_lsst.mal
@@ -0,0 +1,19 @@
+# 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://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html
+#
+# 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-2011 MonetDB B.V.
+# All Rights Reserved.
+
+# This loads the MonetDB/SQL module
+include lsst;
diff --git a/sql/backends/monet5/LSST/Makefile.ag 
b/sql/backends/monet5/LSST/Makefile.ag
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/LSST/Makefile.ag
@@ -0,0 +1,63 @@
+# 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://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html
+#
+# 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-2011 MonetDB B.V.
+# All Rights Reserved.
+
+INCLUDES = ../../../include \
+                  ../../../common \
+                  ../../../storage \
+                  ../../../server .. \
+                  ../../../../monetdb5/modules/atoms \
+                  ../../../../monetdb5/compiler \
+                  ../../../../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) $(cfitsio_CFLAGS) 
$(curl_CFLAGS)
+
+lib__lsst = {
+       MODULE
+       DIR = libdir/monetdb5
+       SOURCES = lsst.c
+       LIBS = ../../../../monetdb5/tools/libmonetdb5 \
+                  ../../../../gdk/libbat $(curl_LIBS)
+}
+
+headers_lsstmal = {
+       HEADERS = mal
+       DIR = libdir/monetdb5
+       SOURCES = lsst.mal
+}
+
+headers_sql = {
+       HEADERS = sql
+       DIR = libdir/monetdb5
+       SOURCES = lsst.sql
+}
+
+headers_lsstautoload = {
+       HEADERS = mal
+       DIR = libdir/monetdb5/autoload
+       SOURCES = 80_lsst.mal
+}
+
+EXTRA_DIST_DIR = Tests
+EXTRA_DIST = 80_lsst.mal 
diff --git a/sql/backends/monet5/LSST/lsst.c b/sql/backends/monet5/LSST/lsst.c
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/LSST/lsst.c
@@ -0,0 +1,433 @@
+/*
+ * 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://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html
+ * 
+ * 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-2011 MonetDB B.V.
+ * All Rights Reserved.
+*/
+
+#include "lsst.h"
+
+/* The remainder of the code base is taken over from MySQLSpatialUdf.c */
+
+static double const QSERV_DEG_PER_RAD = 180.0 / M_PI;
+static double const QSERV_RAD_PER_DEG = M_PI / 180.0;
+static double const QSERV_ARCSEC_PER_DEG = 3600.0;
+
+
+/* -- Angular separation -------- */
+
+/** Returns D^2/4, where D is the euclidian distance between the two
+       input points on the unit sphere. */
+static double _qserv_dist(double ra1, double dec1, double ra2, double dec2) {
+       double x, y, z, dist;
+       x = sin((ra1 - ra2) * QSERV_RAD_PER_DEG * 0.5);
+       x *= x;
+       y = sin((dec1 - dec2) * QSERV_RAD_PER_DEG * 0.5);
+       y *= y;
+       z = cos((dec1 + dec2) * QSERV_RAD_PER_DEG * 0.5);
+       z *= z;
+       dist = x * (z - y) + y;
+       return dist < 0.0 ? 0.0 : (dist > 1.0 ? 1.0 : dist);
+}
+
+static double _qserv_angSep(double ra1, double dec1, double ra2, double dec2) {
+       double dist;
+       dist = _qserv_dist(ra1, dec1, ra2, dec2);
+       return 2.0 * QSERV_DEG_PER_RAD * asin(sqrt(dist));
+}
+
+/** Returns the angular separation in degrees between two spherical
+  * coordinate pairs (ra1, dec1) and (ra2, dec2).
+  *
+  * Consumes 4 arguments ra1, dec1, ra2 and dec2 all of type REAL:
+  * @li ra1:  right ascension of the first position (deg)
+  * @li dec1: declination of the first position (deg)
+  * @li ra2:  right ascension of the second position (deg)
+  * @li dec2: declination of the second position (deg)
+  *
+  * Also:
+  * @li If any parameter is NULL, NULL is returned.
+  * @li If dec1 or dec2 lies outside of [-90, 90], this is an error
+  *     and NULL is returned.
+  */
+sql5_export str 
+qserv_angSep(dbl *sep, dbl *ra1, dbl *dec1, dbl *ra2, dbl *dec2)
+{
+       /* If any input is null, the result is null. */
+       if ( *ra1 == dbl_nil || *dec1 == dbl_nil || *ra2 == dbl_nil || *dec2 == 
dbl_nil){
+               *sep = dbl_nil;
+               return MAL_SUCCEED;
+       }
+       
+       /* Check that dec lies in range. */
+       if (*dec1 < -90.0 || *dec1 > 90.0 || *dec2 < -90.0 || *dec2 > 90.0)
+               throw(MAL,"lsst.qserv_angSep", "Illegal angulars");
+
+       *sep = _qserv_dist(*ra1, *dec1, *ra2, *dec2);
+       return MAL_SUCCEED;
+}
+
+
+/* -- Point in spherical box test -------- */
+
+/** Range reduces the given angle to lie in the range [0.0, 360.0). */
+static double _qserv_reduceRa(double theta) {
+       if (theta  < 0.0 || theta >= 360.0) {
+               theta = fmod(theta, 360.0);
+               if (theta  < 0.0) {
+                       theta += 360.0;
+               }
+       }
+       return theta;
+}
+
+/** Returns 1 if the given spherical longitude/latitude box contains
+  * the given position, and 0 otherwise.
+  *
+  * Consumes 6 arguments ra, dec, ra_min, dec_min, ra_max and dec_max, in
+  * that order, all of type REAL and in units of degrees. (ra, dec) is the
+  * position to test - the remaining parameters specify the spherical box.
+  *
+  * Note that:
+  * @li If any parameter is NULL, the return value is 0.
+  * @li If dec, dec_min or dec_max lies outside of [-90, 90],
+  *     this is an error and NULL is returned.
+  * @li If dec_min is greater than dec_max, the spherical box is empty
+  *     and 0 is returned.
+  * @li If both ra_min and ra_max lie in the range [0, 360], then ra_max
+  *     can be less than ra_min. For example, a box with ra_min = 350
+  *     and ra_max = 10 includes points with right ascensions in the ranges
+  *     [350, 360) and [0, 10].
+  * @li If either ra_min or ra_max lies outside of [0, 360], then ra_min
+  *     must be = ra_max (otherwise, NULL is returned), though the values
+  *     can be arbitrary. If the two are separated by 360 degrees or more,
+  *     then the box spans [0, 360). Otherwise, both values are range reduced.
+  *     For example, a spherical box with ra_min = 350 and ra_max = 370
+  *     includes points with right ascensions in the rnages [350, 360) and
+  *     [0, 10].
+  */
+str qserv_ptInSphBox(int *ret, dbl *ra, dbl *dec, dbl *ra_min, dbl *dec_min, 
dbl *ra_max, dbl *dec_max)
+{
+       dbl lra, lra_min, lra_max;
+
+       if (*ra == dbl_nil || *dec == dbl_nil || *ra_min == dbl_nil || *dec_min 
== dbl_nil || *ra_max == dbl_nil || *dec_max == dbl_nil){
+               *ret = int_nil;
+               return MAL_SUCCEED;
+       }
+       /* Check arguments. */
+       if (*dec < -90.0 || *dec_min < -90.0 || *dec_max < -90.0 ||
+               *dec > 90.0 || *dec_min > 90.0 || *dec_max > 90.0) {
+               *ret = int_nil;
+               return MAL_SUCCEED;
+       }
+       if ( *ra_max  <  *ra_min && ( *ra_max < 0.0 ||  *ra_min > 360.0)) {
+               *ret = int_nil;
+               return MAL_SUCCEED;
+       }
+       if ( *dec_min >  *dec_max ||  *dec <  *dec_min ||  *dec >  *dec_max) {
+               *ret = int_nil;
+               return MAL_SUCCEED;
+       }
+       /* Range-reduce longitude angles */
+       lra = _qserv_reduceRa(*ra);
+       if ( *ra_max - *ra_min >= 360.0) {
+               lra_min = 0.0;
+               lra_max = 360.0;
+       } else {
+               lra_min = _qserv_reduceRa(*ra_min);
+               lra_max = _qserv_reduceRa(*ra_max);
+       }
+       if (lra_min == lra_max) 
+               *ret = lra >= lra_min && lra == lra_max;
+       else 
+               *ret = lra >= lra_min || lra == lra_max;
+       return MAL_SUCCEED;
+}
+
+
+/* -- Point in spherical circle test -------- */
_______________________________________________
Checkin-list mailing list
Checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to