LCOV - code coverage report
Current view: top level - monetdb5/optimizer - opt_volcano.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 54 0.0 %
Date: 2021-10-13 02:24:04 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /*
       2             :  * This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0.  If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       5             :  *
       6             :  * Copyright 1997 - July 2008 CWI, August 2008 - 2021 MonetDB B.V.
       7             :  */
       8             : 
       9             : /*
      10             :  * Selectively inject serialization operations when we know the
      11             :  * raw footprint of the query exceeds 80% of RAM.
      12             :  */
      13             : 
      14             : #include "monetdb_config.h"
      15             : #include "mal_instruction.h"
      16             : #include "opt_volcano.h"
      17             : 
      18             : // delaying the startup should not be continued throughout the plan
      19             : // after the startup phase there should be intermediate work to do
      20             : //A heuristic to check it
      21             : #define MAXdelays 128
      22             : 
      23             : str
      24           0 : OPTvolcanoImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
      25             : {
      26             :         int i, limit, actions = 0;
      27             :         int mvcvar = -1;
      28             :         int count=0;
      29             :         InstrPtr p,q, *old = NULL;
      30             :         str msg = MAL_SUCCEED;
      31             : 
      32             :         (void) cntxt;
      33             :         (void) stk;             /* to fool compilers */
      34             : 
      35           0 :         if ( mb->inlineProp )
      36           0 :                 goto wrapup;
      37             : 
      38           0 :         old = mb->stmt;
      39           0 :         limit= mb->stop;
      40           0 :         if ( newMalBlkStmt(mb, mb->ssize + 20) < 0)
      41           0 :                 throw(MAL,"optimizer.volcano", SQLSTATE(HY013) MAL_MALLOC_FAIL);
      42             : 
      43             :         actions = 1;
      44           0 :         for (i = 0; i < limit; i++) {
      45           0 :                 p = old[i];
      46             : 
      47           0 :                 pushInstruction(mb,p);
      48           0 :                 if( getModuleId(p) == sqlRef && getFunctionId(p)== mvcRef ){
      49           0 :                         mvcvar = getArg(p,0);
      50           0 :                         continue;
      51             :                 }
      52             : 
      53           0 :                 if( count < MAXdelays && getModuleId(p) == algebraRef ){
      54           0 :                         if( getFunctionId(p) == selectRef ||
      55           0 :                                 getFunctionId(p) == thetaselectRef ||
      56           0 :                                 getFunctionId(p) == likeselectRef ||
      57           0 :                                 getFunctionId(p) == joinRef
      58             :                         ){
      59           0 :                                 q= newInstruction(0,languageRef,blockRef);
      60           0 :                                 setDestVar(q, newTmpVariable(mb,TYPE_any));
      61           0 :                                 q =  addArgument(mb,q,mvcvar);
      62           0 :                                 q =  addArgument(mb,q,getArg(p,0));
      63           0 :                                 mvcvar=  getArg(q,0);
      64           0 :                                 pushInstruction(mb,q);
      65           0 :                                 count++;
      66             :                         }
      67           0 :                         continue;
      68             :                 }
      69           0 :                 if( count < MAXdelays && getModuleId(p) == groupRef ){
      70           0 :                         if( getFunctionId(p) == subgroupdoneRef || getFunctionId(p) == groupdoneRef ){
      71           0 :                                 q= newInstruction(0,languageRef,blockRef);
      72           0 :                                 setDestVar(q, newTmpVariable(mb,TYPE_any));
      73           0 :                                 q =  addArgument(mb,q,mvcvar);
      74           0 :                                 q =  addArgument(mb,q,getArg(p,0));
      75           0 :                                 mvcvar=  getArg(q,0);
      76           0 :                                 pushInstruction(mb,q);
      77           0 :                                 count++;
      78             :                         }
      79             :                 }
      80           0 :                 if( getModuleId(p) == sqlRef){
      81           0 :                         if ( getFunctionId(p) == bindRef ||
      82           0 :                                 getFunctionId(p) == bindidxRef ||
      83           0 :                                 getFunctionId(p)== tidRef ||
      84           0 :                                 getFunctionId(p)== appendRef ||
      85           0 :                                 getFunctionId(p)== updateRef ||
      86           0 :                                 getFunctionId(p)== claimRef ||
      87           0 :                                 getFunctionId(p)== deleteRef
      88             :                         ){
      89           0 :                                 setArg(p,p->retc,mvcvar);
      90             :                         }
      91             :                 }
      92             :         }
      93           0 :         GDKfree(old);
      94             : 
      95             :         /* Defense line against incorrect plans */
      96           0 :         if( count){
      97           0 :                 msg = chkTypes(cntxt->usermodule, mb, FALSE);
      98           0 :                 if (!msg)
      99           0 :                         msg = chkFlow(mb);
     100           0 :                 if (!msg)
     101           0 :                         msg = chkDeclarations(mb);
     102             :         }
     103           0 : wrapup:
     104             :         /* keep actions taken as a fake argument*/
     105           0 :         (void) pushInt(mb, pci, actions);
     106           0 :         return msg;
     107             : }

Generated by: LCOV version 1.14