<commit_before>/* -*- c-basic-offset:4; c-indentation-style:"k&r"; indent-tabs-mode:nil -*- */

/**
 * @file
 *
 * Functions related to logical algebra tree construction.
 *
 * This file mainly contains the constructor functions to create an
 * internal representation of the intermediate relational algebra.
 *
 * For documentation on the algebra compilation process, please
 * refer to the @ref compilation documentation in algebra/algebra.c.
 *
 * 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
 * is now maintained by the Database Systems Group at the Technische
 * Universitaet Muenchen, Germany.  Portions created by the University of
 * Konstanz and the Technische Universitaet Muenchen are Copyright (C)
 * 2000-2005 University of Konstanz and (C) 2005-2007 Technische
 * Universitaet Muenchen, respectively.  All Rights Reserved.
 *
 * $Id$
 */

/* always include pathfinder.h first! */
#include "pathfinder.h"

/** handling of variable argument lists */
#include <stdarg.h>
/** strcpy, strlen, ... */
#include <string.h>
#include <stdio.h>
/** assert() */
#include <assert.h>

#include "oops.h"
#include "mem.h"
#include "array.h"

#include "logical.h"

/** include mnemonic names for constructor functions */
#include "logical_mnemonic.h"


/* Encapsulates initialization stuff common to binary comparison operators.  */
static PFla_op_t *
compar_op (PFla_op_kind_t kind, const PFla_op_t *n,
           PFalg_att_t res, PFalg_att_t att1, PFalg_att_t att2);

/* Encapsulates initialization stuff common to binary boolean operators. */
static PFla_op_t *
boolean_op (PFla_op_kind_t kind, const PFla_op_t *n, PFalg_att_t att1,
            PFalg_att_t att2, PFalg_att_t res);

/* Encapsulates initialization stuff common to unary operators. */
static PFla_op_t *
unary_op (PFla_op_kind_t kind, const PFla_op_t *n, PFalg_att_t att,
          PFalg_att_t res);


/**
 * Create a logical algebra operator (leaf) node.
 *
 * Allocates memory for an algebra operator leaf node
 * and initializes all its fields. The node will have the
 * kind @a kind.
 */
static PFla_op_t *
la_op_leaf (PFla_op_kind_t kind)
{
    unsigned int i;
    PFla_op_t *ret = PFmalloc (sizeof (PFla_op_t));

    ret->kind = kind;

    ret->schema.count  = 0;
    ret->schema.items  = NULL;

    for (i = 0; i < PFLA_OP_MAXCHILD; i++)
        ret->child[i] = NULL;

    ret->plans         = NULL;
    ret->prop          = PFprop ();
    ret->node_id       = 0;

    /* bits required to allow DAG traversals */
    ret->bit_reset     = 0;
    ret->bit_dag       = 0;
    /* bits required to look up proxy nodes */
    ret->bit_in        = 0;
    ret->bit_out       = 0;

    ret->sql_ann       = NULL;
    ret->dirty         = false;
    /* initialize environment */
    ret->crrltn_cnt       = 0;

    return ret;
}
<commit_msg>set distinct annotation to 0<commit_after>/* -*- c-basic-offset:4; c-indentation-style:"k&r"; indent-tabs-mode:nil -*- */

/**
 * @file
 *
 * Functions related to logical algebra tree construction.
 *
 * This file mainly contains the constructor functions to create an
 * internal representation of the intermediate relational algebra.
 *
 * For documentation on the algebra compilation process, please
 * refer to the @ref compilation documentation in algebra/algebra.c.
 *
 * 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
 * is now maintained by the Database Systems Group at the Technische
 * Universitaet Muenchen, Germany.  Portions created by the University of
 * Konstanz and the Technische Universitaet Muenchen are Copyright (C)
 * 2000-2005 University of Konstanz and (C) 2005-2007 Technische
 * Universitaet Muenchen, respectively.  All Rights Reserved.
 *
 * $Id$
 */

/* always include pathfinder.h first! */
#include "pathfinder.h"

/** handling of variable argument lists */
#include <stdarg.h>
/** strcpy, strlen, ... */
#include <string.h>
#include <stdio.h>
/** assert() */
#include <assert.h>

#include "oops.h"
#include "mem.h"
#include "array.h"

#include "logical.h"

/** include mnemonic names for constructor functions */
#include "logical_mnemonic.h"


/* Encapsulates initialization stuff common to binary comparison operators.  */
static PFla_op_t *
compar_op (PFla_op_kind_t kind, const PFla_op_t *n,
           PFalg_att_t res, PFalg_att_t att1, PFalg_att_t att2);

/* Encapsulates initialization stuff common to binary boolean operators. */
static PFla_op_t *
boolean_op (PFla_op_kind_t kind, const PFla_op_t *n, PFalg_att_t att1,
            PFalg_att_t att2, PFalg_att_t res);

/* Encapsulates initialization stuff common to unary operators. */
static PFla_op_t *
unary_op (PFla_op_kind_t kind, const PFla_op_t *n, PFalg_att_t att,
          PFalg_att_t res);


/**
 * Create a logical algebra operator (leaf) node.
 *
 * Allocates memory for an algebra operator leaf node
 * and initializes all its fields. The node will have the
 * kind @a kind.
 */
static PFla_op_t *
la_op_leaf (PFla_op_kind_t kind)
{
    unsigned int i;
    PFla_op_t *ret = PFmalloc (sizeof (PFla_op_t));

    ret->kind = kind;

    ret->schema.count  = 0;
    ret->schema.items  = NULL;

    for (i = 0; i < PFLA_OP_MAXCHILD; i++)
        ret->child[i] = NULL;

    ret->plans         = NULL;
    ret->prop          = PFprop ();
    ret->node_id       = 0;

    /* bits required to allow DAG traversals */
    ret->bit_reset     = 0;
    ret->bit_dag       = 0;
    /* bits required to look up proxy nodes */
    ret->bit_in        = 0;
    ret->bit_out       = 0;

    ret->sql_ann       = NULL;
    ret->dirty         = false;
    ret->distinct      = false;
    /* initialize environment */
    ret->crrltn_cnt       = 0;

    return ret;
}

{'fraction_non_alphanumeric': 0.10168531369494406, 'fraction_numerical': 0.009488740971533778, 'mean_word_length': 3.1201866977829638, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3208213', 'n_tokens_mistral': 2263, 'n_tokens_neox': 2152, 'n_words': 774}