Changeset: 9f4c1a0473f4 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9f4c1a0473f4
Modified Files:
        MonetDB5/configure.ag
        MonetDB5/src/mal/mal_linker.mx
        sql/configure.ag
        sql/src/backends/monet5/vaults/71_mseed.mal
        sql/src/backends/monet5/vaults/Makefile.ag
        sql/src/backends/monet5/vaults/mseed.mx
        sql/src/backends/monet5/vaults/vault.mx
Branch: default
Log Message:

Mseed functionality
The mseed library is looked up in the local environment.
The linker contains some better error messages.
The vault+mseed module can take a remote mseed file and read it.


diffs (truncated from 454 to 300 lines):

diff -r 80a2253e0080 -r 9f4c1a0473f4 MonetDB5/configure.ag
--- a/MonetDB5/configure.ag     Wed Jul 07 14:46:47 2010 +0200
+++ b/MonetDB5/configure.ag     Wed Jul 07 16:42:54 2010 +0200
@@ -364,38 +364,6 @@
 AC_SUBST(CFITSIO_LIBS, $CFITSIO_LIBS)
 AM_CONDITIONAL(HAVE_CFITSIO, test x"$have_cfitsio" != xno)
 
-have_mseed="auto"
-AC_ARG_WITH(mseed,
-    AS_HELP_STRING([--with-mseed=DIR],[mseed library is installed in DIR]),
-    [have_mseed="$withval"], [have_mseed="auto"])
-if test "x$have_mseed" != xno; then
-
-       case "$have_mseed" in
-       auto|yes)
-           ;;
-       *)
-           MSEED_CFLAGS="-I$have_mseed/include"
-           MSEED_LIBS="-L$have_mseed/lib -lmseed"
-           ;;
-       esac
-
-       save_CPPFLAGS="$CPPFLAGS"
-       save_LDFLAGS="$LDFLAGS"
-       CPPFLAGS="$CPPFLAGS $MSEED_CFLAGS"
-       LDFLAGS="$LDFLAGS $MSEED_LIBS"
-       AC_CHECK_HEADER(libmseed.h,
-               AC_CHECK_LIB(mseed, msr_init,
-                       AC_DEFINE(HAVE_MSEED, 1, [Define if you have the mseed 
library])
-                       have_mseed=yes,
-                       [ if test "x$have_mseed" != xauto; then 
AC_MSG_ERROR([-lmseed library not found]); fi; have_mseed=no ], "-lm"),
-               [ if test "x$have_mseed" != xauto; then 
AC_MSG_ERROR([libmseed.h header not found]); fi; have_mseed=no ])
-       LDFLAGS="$save_LDFLAGS"
-       CPPFLAGS="$save_CPPFLAGS"
-fi
-AC_SUBST(MSEED_CFLAGS, $MSEED_CFLAGS)
-AC_SUBST(MSEED_LIBS, $MSEED_LIBS)
-AM_CONDITIONAL(HAVE_MSEED, test x"$have_mseed" != xno)
-
 dnl RIPEMD160 is patent free, academic and European, but unfortunately
 dnl can't use it by default, as that would exclude JDBC usage (Java
 dnl doesn't natively support RIPEMD160).
diff -r 80a2253e0080 -r 9f4c1a0473f4 MonetDB5/src/mal/mal_linker.mx
--- a/MonetDB5/src/mal/mal_linker.mx    Wed Jul 07 14:46:47 2010 +0200
+++ b/MonetDB5/src/mal/mal_linker.mx    Wed Jul 07 16:42:54 2010 +0200
@@ -239,7 +239,7 @@
                if (!errmsg) 
                        errmsg = "(no error from dlerror())";
                GDKfree(fullname);
-               throw(LOADER, "loadLibrary", RUNTIME_LOAD_ERROR " '%s' in file 
'%s'", errmsg, filename);
+               throw(LOADER, "loadLibrary", RUNTIME_LOAD_ERROR " '%s' from 
within file '%s'", errmsg, filename);
        }
 
        mal_set_lock(mal_contextLock, "loadModule");
diff -r 80a2253e0080 -r 9f4c1a0473f4 sql/configure.ag
--- a/sql/configure.ag  Wed Jul 07 14:46:47 2010 +0200
+++ b/sql/configure.ag  Wed Jul 07 16:42:54 2010 +0200
@@ -119,6 +119,42 @@
 
 dnl AC_CHECK_HEADERS(limits.h malloc.h pwd.h)
 
+have_mseed="auto"
+AC_ARG_WITH(mseed,
+    AS_HELP_STRING([--with-mseed=DIR],[mseed library is installed in DIR]),
+    [have_mseed="$withval"], [have_mseed="auto"])
+if test "x$have_mseed" != xno; then
+
+       case "$have_mseed" in
+       auto|yes)
+           ;;
+       *)
+           MSEED_CFLAGS="-I$have_mseed/include"
+           MSEED_LIBS="-L$have_mseed/lib -lmseed"
+           ;;
+       esac
+
+       save_CPPFLAGS="$CPPFLAGS"
+       save_LDFLAGS="$LDFLAGS"
+       CPPFLAGS="$CPPFLAGS $MSEED_CFLAGS"
+       LDFLAGS="$LDFLAGS $MSEED_LIBS"
+       AC_CHECK_HEADER(libmseed.h,
+               AC_CHECK_LIB(mseed, msr_init,
+                       AC_DEFINE(HAVE_MSEED, 1, [Define if you have the mseed 
library])
+                       have_mseed=yes,
+                       [ if test "x$have_mseed" != xauto; then 
AC_MSG_ERROR([-lmseed library not found]); fi; have_mseed=no ], "-lm"),
+               [ if test "x$have_mseed" != xauto; then 
AC_MSG_ERROR([libmseed.h header not found]); fi; have_mseed=no ])
+       LDFLAGS="$save_LDFLAGS"
+       CPPFLAGS="$save_CPPFLAGS"
+  if test "x$have_mseed" = "xyes"; then
+           MSEED_CFLAGS=
+           MSEED_LIBS="-lmseed"
+  fi
+fi
+AC_SUBST(MSEED_CFLAGS, $MSEED_CFLAGS)
+AC_SUBST(MSEED_LIBS, $MSEED_LIBS)
+AM_CONDITIONAL(HAVE_MSEED, test x"$have_mseed" != xno)
+
 dnl  stuff required for merovingian and monetdb
 AC_CHECK_HEADERS([fcntl.h stropts.h sys/ioctl.h sys/un.h termios.h])
 AC_CHECK_HEADERS([uuid/uuid.h])
diff -r 80a2253e0080 -r 9f4c1a0473f4 sql/src/backends/monet5/vaults/71_mseed.mal
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sql/src/backends/monet5/vaults/71_mseed.mal       Wed Jul 07 16:42:54 
2010 +0200
@@ -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-2010 MonetDB B.V.
+# All Rights Reserved.
+
+# This loads the MonetDB/SQL module
+include mseed;
diff -r 80a2253e0080 -r 9f4c1a0473f4 sql/src/backends/monet5/vaults/Makefile.ag
--- a/sql/src/backends/monet5/vaults/Makefile.ag        Wed Jul 07 14:46:47 
2010 +0200
+++ b/sql/src/backends/monet5/vaults/Makefile.ag        Wed Jul 07 16:42:54 
2010 +0200
@@ -16,33 +16,32 @@
 # All Rights Reserved.
 
 INCLUDES = ../../include ../../common ../../storage ../../server \
-       $(MONETDB5_INCS) $(CLIENTS_INCS) $(MONETDB_INCS) $(READLINE_INCS)
+       $(MONETDB5_INCS) $(CLIENTS_INCS) $(MONETDB_INCS) $(READLINE_INCS) 
$(MSEED_CFLAGS)
 
 lib__vault = {
        DIR = libdir/MonetDB5/
-       SOURCES = vault.mx 
-#      LIBS = ../../server/libsqlserver ../../storage/libstore 
../../storage/bat/libbatstore ../../storage/restrict/librestrictstore 
../../storage/bpm/libbpmstore ../../common/libsqlcommon \
+       SOURCES = vault.mx mseed.mx
        LIBS = ../../../server/libsqlserver ../../../storage/libstore 
../../../storage/bat/libbatstore ../../../storage/restrict/librestrictstore 
../../../storage/bpm/libbpmstore ../../../common/libsqlcommon \
                $(MONETDB5_MODS) -l_bbp -l_replication -l_mkey -l_str -l_blob 
-l_logger -l_mtime -l_bat5 -l_optimizer -l_tablet -l_cluster -l_bpm -l_remote 
-l_run_octopus -l_algebra \
                $(MONETDB5_RDF_LIB) $(MONETDB5_LIBS) -lmonetdb5 -l_mal_mapi \
-               $(MONETDB_LIBS) -lbat -lstream $(READLINE_LIBS) $(PTHREAD_LIBS) 
+               $(MONETDB_LIBS) -lbat -lstream $(READLINE_LIBS) $(PTHREAD_LIBS) 
$(MSEED_LIBS)
 }
 
 headers_h = {
        HEADERS = h
        DIR = includedir/MonetDB5/sql
-       SOURCES = vault.mx 
+       SOURCES = vault.mx mseed.mx
 }
 
 headers_mal = {
        HEADERS = mal
        DIR = libdir/MonetDB5
-       SOURCES = vault.mx 
+       SOURCES = vault.mx mseed.mx
 }
 headers_autoload = {
     HEADERS = mal
     DIR = libdir/MonetDB5/autoload
-    SOURCES = 70_vault.mal
+    SOURCES = 70_vault.mal 71_mseed.mal
 }
 EXTRA_DIST_DIR = Tests
-EXTRA_DIST = 70_vault.mal
+EXTRA_DIST = 70_vault.mal 71_mseed.mal
diff -r 80a2253e0080 -r 9f4c1a0473f4 sql/src/backends/monet5/vaults/mseed.mx
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sql/src/backends/monet5/vaults/mseed.mx   Wed Jul 07 16:42:54 2010 +0200
@@ -0,0 +1,151 @@
+@/
+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-2010 MonetDB B.V.
+All Rights Reserved.
+@
+
+...@f mseed
+...@a Martin Kersten
+...@v 0.1
+...@+ Mseed
+These routines are meant to interpret mseed files.
+It is derived from the mseed library example.
+The code base assumes that libmseed has been installed on your system.
+...@mal
+module mseed;
+command dump(fnme:str)
+address MSEdump
+comment "Dump the record content of an mseed file from the vault";
+...@h
+#ifndef _MSEED_H
+#define _MSEED_H
+
+#include "sql_config.h"
+#include "clients.h"
+#include "mal.h" 
+#include "mal_client.h"
+#include "mal_interpreter.h"
+#include "mal_function.h"
+#ifdef HAVE_MSEED
+#include "libmseed.h"
+#endif
+
+#ifdef WIN32
+#ifndef LIBMSEED
+#define vault_export extern __declspec(dllimport)
+#else
+#define vault_export extern __declspec(dllexport)
+#endif
+#else
+#define vault_export extern
+#endif
+
+vault_export str MSEdump(int *ret, str *nme);
+
+#define _MSEED_DEBUG_
+
+#endif /* _MSEED_H */
+...@c
+#include "mseed.h"
+#include "vault.h"
+
+str
+MSEdump(int *ret, str *inputfile)
+{
+       str msg = MAL_SUCCEED;
+#ifdef HAVE_MSEED
+       MSRecord *msr = 0;
+
+       int verbose   = 1;
+       int ppackets  = 2;
+       int reclen    = -1;
+       int dataflag  = 0;
+       int totalrecs = 0;
+       int totalsamps = 0;
+       int retcode;
+       int j;
+       time_t t;
+       char *s;
+       char buf[BUFSIZ];
+
+       *ret = 0;
+       if ( vaultpath[0] == 0)
+               throw(MAL,"mseed.dump","Vault not initialized");
+       snprintf(buf,BUFSIZ,"%s%c%s",vaultpath,DIR_SEP,*inputfile);
+
+       printf("Processing %s\n",buf);
+
+       /* Loop over the input file */
+       while ( (retcode = ms_readmsr (&msr, buf, reclen, NULL, NULL, 1, 
dataflag, verbose)) == MS_NOERROR )
+       {
+               totalrecs++;
+               totalsamps += msr->samplecnt;
+               msr_print(msr, ppackets);
+
+               printf("%s,%s,%s,%s,", msr->network, msr->station, 
msr->location, msr->channel);
+               //printf("%ld,",  msr->starttime);
+               t= MS_HPTIME2EPOCH(msr->starttime);
+               s= ctime(&t);
+               s[24]=0;
+               printf("%s,",s);
+               printf("%ld,",msr->starttime % HPTMODULUS);
+               printf("%d,", msr->sequence_number);
+               printf("%d,", msr->samplecnt);
+               printf("%f,", msr->samprate);
+               switch(msr->sampletype){
+                       case 'a': printf("string,"); break;
+                       case 'i': printf("int,"); break;
+                       case 'f': printf("flt,"); break;
+                       case 'd': printf("dbl,"); break;
+                       default: printf("%d,",msr->sampletype);
+               }
+               printf("\n");
+
+               if (msr->datasamples)
+               for ( j=0;j< msr->samplecnt; j++){
+                       switch(msr->sampletype){
+                       case 'a':
+                               printf("%s ", ((char**) msr->datasamples)[j]);
+                               break;
+                       case 'i':
+                               printf("%8d ",((int*)msr->datasamples)[j]);
+                               break;
+                       case 'f':
+                               printf("%f ",((float*)msr->datasamples)[j]);
+                               break;
+                       case 'd':
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to