Changeset: fcaa14c339e6 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fcaa14c339e6
Modified Files:
        monetdb5/extras/compiler/mal_compiler.mx
        monetdb5/mal/Makefile.ag
        monetdb5/mal/mal_atom.c
        monetdb5/mal/mal_atom.h
        monetdb5/mal/mal_atom.mx
        monetdb5/mal/mal_authorize.c
        monetdb5/mal/mal_authorize.h
        monetdb5/mal/mal_authorize.mx
        monetdb5/mal/mal_box.c
        monetdb5/mal/mal_box.h
        monetdb5/mal/mal_box.mx
        monetdb5/mal/mal_dataflow.c
        monetdb5/mal/mal_dataflow.h
        monetdb5/mal/mal_dataflow.mx
        monetdb5/mal/mal_debugger.c
        monetdb5/mal/mal_debugger.h
        monetdb5/mal/mal_debugger.mx
        monetdb5/mal/mal_errors.h
        monetdb5/mal/mal_errors.mx
        monetdb5/mal/mal_function.c
        monetdb5/mal/mal_function.h
        monetdb5/mal/mal_function.mx
        monetdb5/mal/mal_instruction.c
        monetdb5/mal/mal_instruction.h
        monetdb5/mal/mal_instruction.mx
        monetdb5/mal/mal_interpreter.c
        monetdb5/mal/mal_interpreter.h
        monetdb5/mal/mal_interpreter.mx
        monetdb5/mal/mal_listing.c
        monetdb5/mal/mal_listing.h
        monetdb5/mal/mal_listing.mx
        monetdb5/mal/mal_namespace.c
        monetdb5/mal/mal_namespace.h
        monetdb5/mal/mal_namespace.mx
        monetdb5/mal/mal_profiler.c
        monetdb5/mal/mal_profiler.h
        monetdb5/mal/mal_profiler.mx
        monetdb5/mal/mal_properties.c
        monetdb5/mal/mal_properties.h
        monetdb5/mal/mal_properties.mx
        monetdb5/mal/mal_readline.c
        monetdb5/mal/mal_readline.h
        monetdb5/mal/mal_readline.mx
        monetdb5/mal/mal_recycle.c
        monetdb5/mal/mal_recycle.h
        monetdb5/mal/mal_recycle.mx
        monetdb5/mal/mal_resolve.c
        monetdb5/mal/mal_resolve.h
        monetdb5/mal/mal_resolve.mx
        monetdb5/mal/mal_runtime.c
        monetdb5/mal/mal_runtime.h
        monetdb5/mal/mal_runtime.mx
        monetdb5/mal/mal_scenario.c
        monetdb5/mal/mal_scenario.h
        monetdb5/mal/mal_scenario.mx
        monetdb5/mal/mal_syntax.mx
        monetdb5/mal/mal_syntax.txt
        monetdb5/modules/mal/mal_mapi.mx
        monetdb5/modules/mal/mdb.mx
        monetdb5/modules/mal/remote.mx
        monetdb5/modules/mal/replication.mx
        monetdb5/modules/mal/trader.c
        monetdb5/optimizer/Makefile.ag
        monetdb5/optimizer/Makefile.msc
        monetdb5/optimizer/mal_evaluate.h
        monetdb5/optimizer/opt_accumulators.c
        monetdb5/optimizer/opt_accumulators.h
        monetdb5/optimizer/opt_accumulators.mx
        monetdb5/optimizer/opt_aliases.c
        monetdb5/optimizer/opt_aliases.h
        monetdb5/optimizer/opt_aliases.mx
        monetdb5/optimizer/opt_cluster.c
        monetdb5/optimizer/opt_cluster.h
        monetdb5/optimizer/opt_cluster.mx
        monetdb5/optimizer/opt_coercion.c
        monetdb5/optimizer/opt_coercion.h
        monetdb5/optimizer/opt_coercion.mx
        monetdb5/optimizer/opt_commonTerms.c
        monetdb5/optimizer/opt_commonTerms.h
        monetdb5/optimizer/opt_commonTerms.mx
        monetdb5/optimizer/opt_compression.c
        monetdb5/optimizer/opt_compression.h
        monetdb5/optimizer/opt_compression.mx
        monetdb5/optimizer/opt_costModel.c
        monetdb5/optimizer/opt_costModel.h
        monetdb5/optimizer/opt_costModel.mx
        monetdb5/optimizer/opt_crack.mx
        monetdb5/optimizer/opt_crackers.c
        monetdb5/optimizer/opt_crackers.h
        monetdb5/optimizer/opt_datacell.c
        monetdb5/optimizer/opt_datacell.h
        monetdb5/optimizer/opt_datacell.mx
        monetdb5/optimizer/opt_datacyclotron.c
        monetdb5/optimizer/opt_datacyclotron.h
        monetdb5/optimizer/opt_datacyclotron.mx
        monetdb5/optimizer/opt_dataflow.c
        monetdb5/optimizer/opt_dataflow.h
        monetdb5/optimizer/opt_dataflow.mx
        monetdb5/optimizer/opt_deadcode.c
        monetdb5/optimizer/opt_deadcode.h
        monetdb5/optimizer/opt_deadcode.mx
        monetdb5/optimizer/opt_derivepath.c
        monetdb5/optimizer/opt_derivepath.h
        monetdb5/optimizer/opt_derivepath.mx
        monetdb5/optimizer/opt_dictionary.c
        monetdb5/optimizer/opt_dictionary.h
        monetdb5/optimizer/opt_dictionary.mx
        monetdb5/optimizer/opt_emptySet.c
        monetdb5/optimizer/opt_emptySet.h
        monetdb5/optimizer/opt_emptySet.mx
        monetdb5/optimizer/opt_evaluate.c
        monetdb5/optimizer/opt_evaluate.h
        monetdb5/optimizer/opt_evaluate.mx
        monetdb5/optimizer/opt_factorize.c
        monetdb5/optimizer/opt_factorize.h
        monetdb5/optimizer/opt_factorize.mx
        monetdb5/optimizer/opt_garbageCollector.mx
        monetdb5/optimizer/opt_garbagecollector.c
        monetdb5/optimizer/opt_garbagecollector.h
        monetdb5/optimizer/opt_heuristics.mx
        monetdb5/optimizer/opt_history.c
        monetdb5/optimizer/opt_history.h
        monetdb5/optimizer/opt_history.mx
        monetdb5/optimizer/opt_inline.c
        monetdb5/optimizer/opt_inline.h
        monetdb5/optimizer/opt_inline.mx
        monetdb5/optimizer/opt_joinpath.c
        monetdb5/optimizer/opt_joinpath.h
        monetdb5/optimizer/opt_joinpath.mx
        monetdb5/optimizer/opt_joinselect.h
        monetdb5/optimizer/opt_joinselect.mx
        monetdb5/optimizer/opt_macro.c
        monetdb5/optimizer/opt_macro.h
        monetdb5/optimizer/opt_macro.mx
        monetdb5/optimizer/opt_mapreduce.c
        monetdb5/optimizer/opt_mapreduce.h
        monetdb5/optimizer/opt_mapreduce.mx
        monetdb5/optimizer/opt_mergetable.c
        monetdb5/optimizer/opt_mergetable.h
        monetdb5/optimizer/opt_mergetable.mx
        monetdb5/optimizer/opt_mitosis.c
        monetdb5/optimizer/opt_mitosis.h
        monetdb5/optimizer/opt_mitosis.mx
        monetdb5/optimizer/opt_multiplex.c
        monetdb5/optimizer/opt_multiplex.h
        monetdb5/optimizer/opt_multiplex.mx
        monetdb5/optimizer/opt_octopus.c
        monetdb5/optimizer/opt_octopus.h
        monetdb5/optimizer/opt_octopus.mx
        monetdb5/optimizer/opt_partitions.c
        monetdb5/optimizer/opt_partitions.h
        monetdb5/optimizer/opt_partitions.mx
        monetdb5/optimizer/opt_peephole.mx
        monetdb5/optimizer/opt_prejoin.c
        monetdb5/optimizer/opt_prejoin.h
        monetdb5/optimizer/opt_prejoin.mx
        monetdb5/optimizer/opt_prelude.c
        monetdb5/optimizer/opt_prelude.h
        monetdb5/optimizer/opt_pushranges.c
        monetdb5/optimizer/opt_pushranges.h
        monetdb5/optimizer/opt_pushranges.mx
        monetdb5/optimizer/opt_qep.c
        monetdb5/optimizer/opt_qep.h
        monetdb5/optimizer/opt_qep.mx
        monetdb5/optimizer/opt_recycler.c
        monetdb5/optimizer/opt_recycler.h
        monetdb5/optimizer/opt_recycler.mx
        monetdb5/optimizer/opt_reduce.c
        monetdb5/optimizer/opt_reduce.h
        monetdb5/optimizer/opt_reduce.mx
        monetdb5/optimizer/opt_remap.c
        monetdb5/optimizer/opt_remap.h
        monetdb5/optimizer/opt_remap.mx
        monetdb5/optimizer/opt_remoteQueries.c
        monetdb5/optimizer/opt_remoteQueries.h
        monetdb5/optimizer/opt_remoteQueries.mx
        monetdb5/optimizer/opt_reorder.c
        monetdb5/optimizer/opt_reorder.h
        monetdb5/optimizer/opt_reorder.mx
        monetdb5/optimizer/opt_replication.c
        monetdb5/optimizer/opt_replication.mx
        monetdb5/optimizer/opt_replications.h
        monetdb5/optimizer/opt_selcrack.c
        monetdb5/optimizer/opt_selcrack.h
        monetdb5/optimizer/opt_selcrack.mx
        monetdb5/optimizer/opt_sidcrack.mx
        monetdb5/optimizer/opt_singleton.c
        monetdb5/optimizer/opt_singleton.h
        monetdb5/optimizer/opt_singleton.mx
        monetdb5/optimizer/opt_statistics.c
        monetdb5/optimizer/opt_statistics.h
        monetdb5/optimizer/opt_statistics.mx
        monetdb5/optimizer/opt_strengthReduction.c
        monetdb5/optimizer/opt_strengthReduction.h
        monetdb5/optimizer/opt_strengthReduction.mx
        monetdb5/optimizer/opt_support.c
        monetdb5/optimizer/opt_support.h
        monetdb5/optimizer/opt_support.mx
        monetdb5/optimizer/opt_tarantula.c
        monetdb5/optimizer/opt_tarantula.h
        monetdb5/optimizer/opt_tarantula.mx
        monetdb5/optimizer/opt_trace.c
        monetdb5/optimizer/opt_trace.h
        monetdb5/optimizer/opt_trace.mx
        monetdb5/optimizer/opt_wrapper.c
        monetdb5/optimizer/optimizer.c
        monetdb5/optimizer/optimizer.h
        monetdb5/optimizer/optimizer.mal
        monetdb5/optimizer/optimizer.mx
        monetdb5/scheduler/run_adder.c
        monetdb5/scheduler/run_octopus.mx
        monetdb5/scheduler/run_pipeline.mx
        sql/backends/monet5/sql.mx
        sql/backends/monet5/sql_bpm.mx
        sql/backends/monet5/sql_emptyset.mx
        sql/backends/monet5/sql_gencode.mx
        sql/backends/monet5/sql_optimizer.mx
        sql/backends/monet5/sql_scenario.c
Branch: headless
Log Message:

Mx gone in from src/mal and src/optimizers
All converted and still compilable against old gdk


diffs (truncated from 82398 to 300 lines):

diff --git a/monetdb5/extras/compiler/mal_compiler.mx 
b/monetdb5/extras/compiler/mal_compiler.mx
--- a/monetdb5/extras/compiler/mal_compiler.mx
+++ b/monetdb5/extras/compiler/mal_compiler.mx
@@ -245,7 +245,7 @@
        int sz = 0;
        ValPtr val;
 
-       val = &getVarConstant(mb, i);
+       val = getVarConstant(mb, i);
        if (val->vtype == TYPE_str) {
                mnstr_printf(f, "\"%s\"", val->val.sval);
        } else {
@@ -267,7 +267,7 @@
        tpe = getTypeName(getVarType(mb, i));
        if (strcmp(tpe, "void") == 0) {
                mnstr_printf(f, "void *");
-       } else if (isaBatType(getVarType(mb, i))) {
+       } else if (isaColType(getVarType(mb, i))) {
                mnstr_printf(f, "int *");
        } else {
                mnstr_printf(f, "%s *", tpe);
@@ -329,9 +329,9 @@
        }
 
        for (i = 1; i < mb->vtop; i++) 
-       if( !isVarTypedef(mb,i)){
+       if( !isaTypeVar(getVarType(mb,i)) ){
                tpe = getTypeName(getVarType(mb, i));
-               seenbat += isaBatType(getVarType(mb,i));
+               seenbat += isaColType(getVarType(mb,i));
                v = getVarName(mb, i);
                if (isTmpVar(mb, i))
                        *v = 'V';
@@ -339,7 +339,7 @@
                        mnstr_printf(f, "\tint ");
                        mccVar(f, mb, i);
                        mnstr_printf(f, "= 0; /* %s */\n", tpe);
-               } else if (isaBatType(getVarType(mb, i))) {
+               } else if (isaColType(getVarType(mb, i))) {
                        mnstr_printf(f, "\tBID ");
                        mccVar(f, mb, i);
                        mnstr_printf(f, "= 0; /* %s */\n", tpe);
@@ -463,7 +463,7 @@
        int i;
        if( garbageControl(p)){
                for(i=0;i<p->retc; i++){
-                       if( isaBatType(getArgType(mb,p,i))){
+                       if( isaColType(getArgType(mb,p,i))){
                                mnstr_printf(f,"\tbackup[%d]=",i);
                                mccVar(f,mb,getArg(p,i));
                                mnstr_printf(f,";\n");
@@ -487,7 +487,7 @@
        int i;
        if( garbageControl(p)){
                for(i=0;i<p->retc; i++){
-                       if( isaBatType(getArgType(mb,p,i))){
+                       if( isaColType(getArgType(mb,p,i))){
                                mnstr_printf(f,"\tif(backup[%d] == ",i);
                                mccVar(f,mb,getArg(p,i));
                                mnstr_printf(f,") 
BBPreleaseref(backup[%d]);\n",i);
@@ -580,7 +580,7 @@
        if (getModuleId(pn))
                setModuleId(p,NULL);
        setModuleId(pn, NULL);
-       setFunctionId(pn, GDKstrdup(getVarConstant(mb, 
pn->argv[pn->retc]).val.sval));
+       setFunctionId(pn, GDKstrdup(getVarConstant(mb, 
pn->argv[pn->retc])->val.sval));
        delArgument(pn, pn->retc);
        typeChecker(cntxt->nspace, mb, pn, TRUE);
 
@@ -717,7 +717,7 @@
        int i;
        mnstr_printf(f,"wrapup:;\n");
        for(i=0; i< mb->vtop; i++)
-       if( isaBatType(getVarType(mb,i))
+       if( isaColType(getVarType(mb,i))
        ){
                mnstr_printf(f,"\tif( ");
                mccVar(f,mb,i);
diff --git a/monetdb5/mal/Makefile.ag b/monetdb5/mal/Makefile.ag
--- a/monetdb5/mal/Makefile.ag
+++ b/monetdb5/mal/Makefile.ag
@@ -28,39 +28,71 @@
        NOINST
        SOURCES = \
                mal.c \
-               mal_atom.mx \
-               mal_authorize.mx \
-               mal_box.mx \
+               mal_atom.c \
+               mal_authorize.c \
+               mal_box.c \
                mal_builder.c \
                mal_client.c \
-               mal_debugger.mx \
-               mal_errors.mx \
+               mal_dataflow.c \
+               mal_debugger.c \
                mal_exception.c \
                mal_factory.c \
-               mal_function.mx \
+               mal_function.c \
                mal_import.c \
-               mal_instruction.mx \
-               mal_listing.mx \
-               mal_interpreter.mx \
-               mal_dataflow.mx \
+               mal_instruction.c \
+               mal_interpreter.c \
+               mal_listing.c \
                mal_linker.c \
                mal_module.c \
-               mal_namespace.mx \
+               mal_namespace.c \
                mal_parser.c \
-               mal_runtime.mx \
-               mal_profiler.mx \
-               mal_properties.mx \
-               mal_readline.mx \
-               mal_recycle.mx \
-               mal_resolve.mx \
+               mal_runtime.c \
+               mal_profiler.c \
+               mal_properties.c \
+               mal_readline.c \
+               mal_recycle.c \
+               mal_resolve.c \
                mal_sabaoth.c \
-               mal_scenario.mx \
+               mal_scenario.c \
                mal_session.c \
                mal_stack.c \
-               mal_type.t \
+               mal_type.c \
                mal_utils.c \
                mal_xml.c
 }
 
 EXTRA_DIST_DIR = Tests
-EXTRA_DIST = mal.h mal_builder.h mal_client.h mal_exception.h mal_factory.h 
mal_import.h mal_linker.h mal_module.h mal_sabaoth.h mal_session.h mal_stack.h 
mal_type.h mal_utils.h mal_xml.h mal_parser.h
+EXTRA_DIST = \
+               mal.h \
+               mal_atom.h \
+               mal_authorize.h \
+               mal_box.h \
+               mal_builder.h \
+               mal_client.h \
+               mal_dataflow.h \
+               mal_debugger.h \
+               mal_exception.h \
+               mal_errors.h \
+               mal_factory.h \
+               mal_function.h \
+               mal_import.h \
+               mal_instruction.h \
+               mal_interpreter.h \
+               mal_listing.h \
+               mal_linker.h \
+               mal_module.h \
+               mal_namespace.h \
+               mal_parser.h \
+               mal_runtime.h \
+               mal_profiler.h \
+               mal_properties.h \
+               mal_readline.h \
+               mal_recycle.h \
+               mal_resolve.h \
+               mal_sabaoth.h \
+               mal_scenario.h \
+               mal_session.h \
+               mal_stack.h \
+               mal_type.h \
+               mal_utils.h \
+               mal_xml.h
diff --git a/monetdb5/mal/mal_atom.c b/monetdb5/mal/mal_atom.c
new file mode 100644
--- /dev/null
+++ b/monetdb5/mal/mal_atom.c
@@ -0,0 +1,347 @@
+/*
+ * 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.
+*/
+
+/* Author(s) M.L.Kersten
+ * User Defined Types
+ * MonetDB supports an extensible type system to accomodate a wide
+ * spectrum of database kernels and application needs.
+ * The type administration keeps track of their properties and
+ * provides access to the underlying implementations.
+ * 
+ * MAL recognizes the definition of a new
+ * type by replacing the @sc{module} keyword with @sc{atom}.
+ * Atoms definitions require special care, because their definition and 
+ * properties should be communicated with the kernel library.
+ * The commands defined in an @sc{atom } block are screened as of interest 
+ * to the library. 
+ * 
+ * MonetDB comes with the hardwired types @sc{bit, chr, sht, int, lng, oid, 
flt, 
+ * dbl, str} and @sc{bat}, the representation of a bat identifier.
+ * The kernel code has been optimized to deal with these types efficiently,
+ * i.e. without unnecessary function call overheads.
+ * 
+ * A small collection of user-defined @sc{atom} types is shipped with the 
sysem.
+ * They implement types considered essential for end-user applications,
+ * such as @sc{color, date, daytime,  time, timestamp, timezone, blob}, 
+ * and @sc{inet, url}.
+ * They are implemented using the type extension mechanism described below.
+ * As such, they provide examples for future extensions.
+ * A concrete example is the 'blob' datatype in the MonetDB atom module
+ * library(see ../modules/atoms/blob.mx)
+ * 
+ * Defining your own types
+ * For the courageous at heart, you may enter the difficult world
+ * of extending the kernel library. The easiest way is to derive
+ * the atom modules from one shipped in the source distributed.
+ * More involved atomary types require a study of the
+ * documentation associated with the atom structures (gdk_atoms),
+ * because you have to develop a handful routines complying with the
+ * signatures required in the kernel library.
+ * They are registered upon loading the @sc{atom} module.
+ * 
+ * The atom registration functions perform the necessary
+ * type checks, but relies on the user to comply with this signature in
+ * its C-implementation. The ruler calls are part of a module
+ * initialization routine.
+ *
+ * Functions passed to the GDK kernel are not directly accessible
+ * as MAL routines, because their implementation requires a
+ * GDK-specific signature. (See GDK documentation)
+ * They are renamed to an non-parseable function, effectively shielding
+ * them from the MAL programmer.
+ * 
+ * This feature is of particular interest to system experts. 
+ * It is not meant for end-users trying to intruduce record- or 
+ * struct-like objects in the database. They better decompose
+ * the complex object structure and represent the components in
+ * different BATs.
+ *
+ * Every MAL command introduced in an atom module should be checked
+ * to detect overloading of a predefined function.
+ * Subsequently, we update the BAT atom structure.
+ * The function signatures should be parameter-less, which
+ * enables additional functions with the same name to appear
+ * as ordinary mal operators.
+ * 
+ * A few fields are set only once, at creation time.
+ * They should be implemented with parameter-less functions.
+*/
+
+#include "monetdb_config.h"
+#include "mal_utils.h"
+#include "mal_atom.h"
+#include "mal_namespace.h"
+#include "mal_exception.h"
+
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 1024
+#endif
+
+void setAtomName(InstrPtr pci){
+       char buf[MAXPATHLEN];
+       snprintf(buf,MAXPATHLEN,"#%s", getFunctionId(pci));
+       setFunctionId(pci, putName(buf,strlen(buf)));
+}
+
+int malAtomProperty(MalBlkPtr mb, InstrPtr pci){
+       str name= getFunctionId(pci);
+       int tpe = getTypeIndex(getModuleId(pci), (int) 
strlen(getModuleId(pci)), TYPE_any);
+       (void) mb; /* fool compilers */
+       if( tpe<0 || tpe>= GDKatomcnt)
+               return 0;
+       assert(pci != 0);
+       switch(name[0]){
+       case 'd': 
+               if( idcmp("del",name)==0 && pci->argc==1){
+                       BATatoms[tpe].atomDel= (void (*)(Heap *, var_t *)) 
pci->fcn;
+                       setAtomName(pci);
+                       return 1;
+               }
+               break;
+       case 'c': 
+               if( idcmp("cmp",name)==0 && pci->argc==1){
+                       BATatoms[tpe].atomCmp= (int (*)(ptr, ptr)) pci->fcn;
+                       setAtomName(pci);
+                       return 1;
+               } 
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to