Changeset: 880ee6dfb75d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=880ee6dfb75d
Modified Files:
pathfinder/compiler/algebra/logical.c
Branch: default
Log Message:
Merge branch 'PF2M5'
diffs (truncated from 3667 to 300 lines):
diff -r d1ebb27a53a2 -r 880ee6dfb75d pathfinder/compiler/Makefile.ag
--- a/pathfinder/compiler/Makefile.ag Sun May 16 01:24:16 2010 +0200
+++ b/pathfinder/compiler/Makefile.ag Wed May 19 12:10:04 2010 +0200
@@ -21,7 +21,7 @@
# 2008-2010 Eberhard Karls Universitaet Tuebingen, respectively. All
# Rights Reserved.
-SUBDIRS = utils schema debug mem parser semantics core algebra mil include sql
xmlimport
+SUBDIRS = utils schema debug mem parser semantics core algebra mil include sql
algebra-m5sql xmlimport
EXTRA_DIST_DIR = Tests
@@ -72,6 +72,7 @@
mil/libmil \
libcompiler2 \
mem/libmem \
+ algebra-m5sql/libmsa \
sql/libsql \
#
xmlimport/libxmlimport \
diff -r d1ebb27a53a2 -r 880ee6dfb75d
pathfinder/compiler/algebra-m5sql/Makefile.ag
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pathfinder/compiler/algebra-m5sql/Makefile.ag Wed May 19 12:10:04
2010 +0200
@@ -0,0 +1,48 @@
+#
+# Copyright Notice:
+# -----------------
+#
+# The contents of this file are subject to the Pathfinder 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/PathfinderLicense-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 Pathfinder system.
+#
+# The Original Code has initially been developed by the Database &
+# Information Systems Group at the University of Konstanz, Germany and
+# the Database Group at the Technische Universitaet Muenchen, Germany.
+# It is now maintained by the Database Systems Group at the Eberhard
+# Karls Universitaet Tuebingen, Germany. Portions created by the
+# University of Konstanz, the Technische Universitaet Muenchen, and the
+# Universitaet Tuebingen are Copyright (C) 2000-2005 University of
+# Konstanz, (C) 2005-2008 Technische Universitaet Muenchen, and (C)
+# 2008-2010 Eberhard Karls Universitaet Tuebingen, respectively. All
+# Rights Reserved.
+#
+# Fri Oct 27 10:05:33 CEST 2006, Manuel Mayr
+
+INCLUDES = ../include $(MONETDB_INCS)
+
+# locally disable "-Werror"
+#X_CFLAGS = "-pedantic"
+
+# ignore warning "null dimension: sizeof()"
+# with Sun Studio 12 compiler
+lalg2msa_CFLAGS = $(SUN_NOERR_CFLAGS)
+
+lib_msa = {
+ NOINST
+ DIR = libdir
+ SOURCES = \
+ lalg2msa.c \
+ msa.c \
+ msaprint.c
+}
+
+#EXTRA_DIST =
diff -r d1ebb27a53a2 -r 880ee6dfb75d
pathfinder/compiler/algebra-m5sql/lalg2msa.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pathfinder/compiler/algebra-m5sql/lalg2msa.c Wed May 19 12:10:04
2010 +0200
@@ -0,0 +1,1043 @@
+/**
+ * @file
+ *
+ * Transforms the logical algebra tree into a tree that represents
+ * SQL statements.
+ *
+ * Copyright Notice:
+ * -----------------
+ *
+ * The contents of this file are subject to the Pathfinder 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/PathfinderLicense-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 Pathfinder system.
+ *
+ * The Original Code has initially been developed by the Database &
+ * Information Systems Group at the University of Konstanz, Germany and
+ * the Database Group at the Technische Universitaet Muenchen, Germany.
+ * It is now maintained by the Database Systems Group at the Eberhard
+ * Karls Universitaet Tuebingen, Germany. Portions created by the
+ * University of Konstanz, the Technische Universitaet Muenchen, and the
+ * Universitaet Tuebingen are Copyright (C) 2000-2005 University of
+ * Konstanz, (C) 2005-2008 Technische Universitaet Muenchen, and (C)
+ * 2008-2010 Eberhard Karls Universitaet Tuebingen, respectively. All
+ * Rights Reserved.
+ *
+ * $Id: $
+ */
+
+/* always include pf_config.h first! */
+#include "pf_config.h"
+#include "pathfinder.h"
+
+/** assert() */
+#include <assert.h>
+/** fprintf() */
+#include <stdio.h>
+/** strcpy, strlen, ... */
+#include <string.h>
+
+#include "oops.h" /* PFoops() */
+#include "mem.h"
+#include "array.h"
+#include "string_utils.h"
+
+#include "lalg2msa.h"
+
+/* Easily access subtree-parts */
+#include "child_mnemonic.h"
+
+#include "msa.h"
+#include "algebra.h"
+#include "alg_dag.h"
+#include "ordering.h"
+
+#include "msa_mnemonic.h"
+
+/* Auxiliary function that searches for a certain col
+ in a expression list and returns an expression
+ representing the found column. If no column was
+ found, NULL will be returned */
+static PFmsa_expr_t *
+find_expr(PFmsa_exprlist_t *expr_list, PFalg_col_t col)
+{
+ unsigned int i;
+
+ for (i = 0; i < elsize(expr_list); i++) {
+ PFmsa_expr_t *curr_expr = elat(expr_list, i);
+ if ((curr_expr->col) == col)
+ return curr_expr;
+ }
+ return NULL;
+}
+
+/* Auxiliary function that constructs an expression list containing
+ column references of the columns in a schema */
+static PFmsa_exprlist_t *
+exprlist_from_schema(PFalg_schema_t schema)
+{
+ unsigned int i;
+ PFmsa_exprlist_t *ret = el(schema.count);
+
+ for (i = 0; i < schema.count; i++) {
+ PFmsa_expr_t *new_expr = PFmsa_expr_column(schema.items[i].name,
schema.items[i].type);
+ eladd(ret) = new_expr;
+ }
+
+ return ret;
+}
+
+static PFmsa_expr_t *
+deep_copy_expr(PFmsa_expr_t *n)
+{
+ PFmsa_expr_t *ret = PFmalloc (sizeof(PFmsa_expr_t));
+ memcpy(ret, n, sizeof(PFmsa_expr_t));
+ unsigned int i;
+
+ for (i = 0; i < PFMSA_OP_MAXCHILD && n->child[i]; i++) {
+ ret->child[i] = deep_copy_expr(n->child[i]);
+ }
+
+ return ret;
+}
+
+/* Bind a msa operator to a la operator during translation. That is:
+ Put a selection and projection operator on top of the current
+ operator to 'materialize' changes in schema and predicates */
+static void
+bind(PFla_op_t *n)
+{
+ PFmsa_op_t *sel = PFmsa_op_select (OP(n), SEL_LIST(n));
+ PFmsa_op_t *prj = PFmsa_op_project (sel, false, PRJ_LIST(n));
+
+ OP(n) = prj;
+ PRJ_LIST(n) = exprlist_from_schema (n->schema);
+ SEL_LIST(n) = el(1);
+
+ return;
+}
+
+/* ----- Translate the logical algebra into M5 SQL algebra ----- */
+
+/* Worker that performes translation from la to msa. Note that
+ not every operator is translated 1-to-1 but so called selection
+ and projection lists are carried along, which represent changes
+ in schema (e.g. attaching of a row) or selection predicates.
+
+ The function is bottom-up: We descend to leaf nodes, compute
+ operators and lists and write them to an annotation field (msa_ann)
+ in the original la operator */
+static void
+alg2msa_worker(PFla_op_t *n)
+{
+ unsigned int i;
+ /* declarations need for the translation: msa annotation and its contents
*/
+ PFmsa_ann_t *msa_ann;
+ PFmsa_op_t *op;
+ PFmsa_exprlist_t *prj_list;
+ PFmsa_exprlist_t *sel_list;
+
+ /* traverse child operators recursively */
+ for (i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) {
+ if (!n->child[i]->bit_dag)
+ alg2msa_worker(n->child[i]);
+ }
+
+ switch (n->kind) {
+
+ case la_serialize_seq:
+ {
+ PFalg_collist_t *collist;
+
+ /* bind node containing la DAG */
+ bind(R(n));
+
+ /* la_side_effects node will not be bound */
+
+ /* build list containing the item column */
+ collist = PFalg_collist(1);
+ PFalg_collist_add(collist) = n->sem.ser_seq.item;
+
+ op = PFmsa_op_serialize_rel(OP (R(n)),
+ OP (L(n)),
+ col_NULL,
+ n->sem.ser_seq.pos,
+ collist);
+
+ /* not necessary to set project nor select list */
+ }
+ break;
+
+ case la_serialize_rel:
+
+ /* FIXME: NOT TESTED YET! */
+
+ /* bind node with la DAG */
+ bind(R(n));
+
+ /* la_side_effects node will not be bound */
+
+ op = PFmsa_op_serialize_rel(OP (R(n)),
+ OP (L(n)),
+ n->sem.ser_rel.iter,
+ n->sem.ser_rel.pos,
+ n->sem.ser_rel.items);
+
+ /* not necessary to set project nor select list */
+
+ break;
+
+ case la_side_effects:
+
+ /* build operator and lists */
+ op = PFmsa_op_nil_node();
+ prj_list = NULL;
+ sel_list = NULL;
+
+ break;
+
+ case la_lit_tbl:
+ /* Build literal table operator with the information
+ of the original la operator. */
+
+ /* build operator and lists */
+ op = PFmsa_op_literal_table(n->schema, n->sem.lit_tbl.count,
+ n->sem.lit_tbl.tuples);
+ prj_list = exprlist_from_schema(n->schema);
+ sel_list = el(1);
+
+ break;
+
+ case la_empty_tbl:
+ /* Build empty table operator with the schema
+ of the original la operator. */
+
+ /* build operator and lists */
+ op = PFmsa_op_literal_table(n->schema, 0,
+ NULL);
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list