LCOV - code coverage report
Current view: top level - monetdb5/optimizer - opt_candidates.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 57 57 100.0 %
Date: 2024-10-04 20:04:04 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*
       2             :  * SPDX-License-Identifier: MPL-2.0
       3             :  *
       4             :  * This Source Code Form is subject to the terms of the Mozilla Public
       5             :  * License, v. 2.0.  If a copy of the MPL was not distributed with this
       6             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       7             :  *
       8             :  * Copyright 2024 MonetDB Foundation;
       9             :  * Copyright August 2008 - 2023 MonetDB B.V.;
      10             :  * Copyright 1997 - July 2008 CWI.
      11             :  */
      12             : 
      13             : /*
      14             :  * Mark the production and use of candidate lists.
      15             :  */
      16             : 
      17             : #include "monetdb_config.h"
      18             : #include "mal_instruction.h"
      19             : #include "opt_candidates.h"
      20             : 
      21             : str
      22      463256 : OPTcandidatesImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
      23             : {
      24      463256 :         InstrPtr p;
      25      463256 :         str msg = MAL_SUCCEED;
      26             : 
      27      463256 :         if (!(ATOMIC_GET(&GDKdebug) & FORCEMITOMASK))
      28        2391 :                 goto wrapup;
      29             :         (void) cntxt;
      30             :         (void) stk;                                     /* to fool compilers */
      31    23750176 :         for (int i = 0; i < mb->stop; i++) {
      32    23289311 :                 p = getInstrPtr(mb, i);
      33    23289311 :                 if (p->token == ASSIGNsymbol) {
      34      137086 :                         for (int j = 0; j < p->retc && j + p->retc < p->argc; j++)
      35        7273 :                                 if (isVarCList(mb, getArg(p, p->retc + j)))
      36          54 :                                         setVarCList(mb, getArg(p, j));
      37             :                 }
      38    23289311 :                 if (getModuleId(p) == sqlRef) {
      39     2431723 :                         if (getFunctionId(p) == tidRef)
      40      190737 :                                 setVarCList(mb, getArg(p, 0));
      41     2240986 :                         else if (getFunctionId(p) == subdeltaRef)
      42       50518 :                                 setVarCList(mb, getArg(p, 0));
      43    20857588 :                 } else if (getModuleId(p) == algebraRef) {
      44     2168601 :                         if (getFunctionId(p) == selectRef
      45     2101891 :                                 || getFunctionId(p) == thetaselectRef)
      46      385672 :                                 setVarCList(mb, getArg(p, 0));
      47     1782929 :                         else if (getFunctionId(p) == likeselectRef)
      48        4546 :                                 setVarCList(mb, getArg(p, 0));
      49     1778383 :                         else if (getFunctionId(p) == intersectRef
      50     1772794 :                                          || getFunctionId(p) == differenceRef)
      51       76077 :                                 setVarCList(mb, getArg(p, 0));
      52     1702306 :                         else if (getFunctionId(p) == uniqueRef)
      53          65 :                                 setVarCList(mb, getArg(p, 0));
      54     1702241 :                         else if (getFunctionId(p) == firstnRef)
      55         802 :                                 setVarCList(mb, getArg(p, 0));
      56     1701439 :                         else if (getFunctionId(p) == subsliceRef)
      57        1071 :                                 setVarCList(mb, getArg(p, 0));
      58     1700368 :                         else if (getFunctionId(p) == projectionRef
      59     1032966 :                                          && isVarCList(mb, getArg(p, p->retc + 0))
      60      630792 :                                          && isVarCList(mb, getArg(p, p->retc + 1)))
      61       98481 :                                 setVarCList(mb, getArg(p, 0));
      62    18688987 :                 } else if (getModuleId(p) == generatorRef) {
      63         416 :                         if (getFunctionId(p) == selectRef
      64         416 :                                 || getFunctionId(p) == thetaselectRef)
      65          29 :                                 setVarCList(mb, getArg(p, 0));
      66    18688571 :                 } else if (getModuleId(p) == sampleRef) {
      67          21 :                         if (getFunctionId(p) == subuniformRef)
      68          21 :                                 setVarCList(mb, getArg(p, 0));
      69    18688550 :                 } else if (getModuleId(p) == groupRef && p->retc > 1) {
      70       55284 :                         if (getFunctionId(p) == subgroupRef
      71       52781 :                                 || getFunctionId(p) == subgroupdoneRef
      72       40626 :                                 || getFunctionId(p) == groupRef
      73       28626 :                                 || getFunctionId(p) == groupdoneRef)
      74       55284 :                                 setVarCList(mb, getArg(p, 1));
      75    18633266 :                 } else if (getModuleId(p) == batRef) {
      76      634745 :                         if (getFunctionId(p) == mergecandRef
      77      555246 :                                 || getFunctionId(p) == intersectcandRef
      78      555246 :                                 || getFunctionId(p) == diffcandRef
      79      555246 :                                 || getFunctionId(p) == mirrorRef)
      80      125676 :                                 setVarCList(mb, getArg(p, 0));
      81             :                 }
      82             :         }
      83             : 
      84             :         /* Defense line against incorrect plans */
      85             :         /* plan remains unaffected */
      86             :         // msg = chkTypes(cntxt->usermodule, mb, FALSE);
      87             :         // if( ms== MAL_SUCCEED)
      88             :         //      msg = chkFlow(mb);
      89             :         // if( ms== MAL_SUCCEED)
      90             :         //      msg = chkDeclarations(mb);
      91             :         /* keep actions taken as a fake argument */
      92      460865 : wrapup:
      93      463256 :         (void) pushInt(mb, pci, 1);
      94      463255 :         return msg;
      95             : }

Generated by: LCOV version 1.14