trafodion-codereview mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From narendragoyal <...@git.apache.org>
Subject [GitHub] incubator-trafodion pull request #750: TRAFODION-2265
Date Mon, 10 Oct 2016 17:35:29 GMT
Github user narendragoyal commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/750#discussion_r82648928
  
    --- Diff: core/sql/exp/exp_fixup.cpp ---
    @@ -1740,6 +1741,103 @@ Lng32 ex_conv_clause::findIndexIntoInstrArray(ConvInstruction
ci)
       return -1; // not found
     }
     
    +bool   ex_conv_clause::sv_instrOffsetIndexPopulated = false;
    +short  ex_conv_clause::sv_MaxOpTypeValue = -1;
    +int   *ex_conv_clause::sv_convIndexSparse = 0;
    +
    +/* 
    + * Scans convInstrInfo[] and populates a 
    + * sparsely populated index: sv_convIndexSparse. 
    + * 
    + * For a given op type: op_type, 
    + * if (sv_convIndexSparse[op_type>] != -1) then 
    + * it contains the offset into the first row of 
    + * convInstrInfo[]
    + */
    +void ex_conv_clause::populateInstrOffsetIndex()
    +{
    +  if (sv_instrOffsetIndexPopulated) {
    +    return;
    +  }
    +
    +  typedef struct convInstrIndexStruct {
    +    short type_op1;
    +    short offset;
    +  } convInstrIndexDef;
    +  
    +  short lv_MaxIndex = -1;
    +
    +  // Currently, the number of distinct 'type_op1' values in the convInstrInf[] is 32
    +  const int lv_MaxIndexCapacity = 100;
    +  convInstrIndexDef lv_convIndex[lv_MaxIndexCapacity];
    +
    +  Int32 i = 0;
    +  Int32 lv_source_type = -1;
    +  Int32 lv_max_array_size = sizeof(ex_conv_clause::convInstrInfo) / sizeof(ex_conv_clause::ConvInstrStruct);
    +  
    +  // collect distinct type_op1 values and their 1st offset in convInstrInfo[]
    +  while (i < lv_max_array_size) {
    +    if (ex_conv_clause::convInstrInfo[i].type_op1 != lv_source_type) {
    +      lv_source_type = ex_conv_clause::convInstrInfo[i].type_op1;
    +      if ((lv_source_type > -1) && 
    +	  (lv_MaxIndex < (lv_MaxIndexCapacity - 1))) {
    +	lv_convIndex[++lv_MaxIndex].type_op1 = lv_source_type;
    +	lv_convIndex[lv_MaxIndex].offset = i;
    +      }
    +    }
    +    i++;
    +  }
    +
    +  // Find the max op type value in lv_convIndex
    +  int j = 0;
    +  while (j <= lv_MaxIndex) {
    +    if (sv_MaxOpTypeValue < lv_convIndex[j].type_op1) {
    +      sv_MaxOpTypeValue = lv_convIndex[j].type_op1;
    +    }
    +    j++;
    +  }
    +
    +  // just in case some op type has been assigned a pretty large value
    +  // we dont want to allocate a very large sparse value
    +  if (sv_MaxOpTypeValue > 8000) {
    +    sv_MaxOpTypeValue = 8000;
    +  }
    +  
    +  // Allocate a sparsely populated array
    +  sv_convIndexSparse = (int *) calloc(sizeof(int), 
    --- End diff --
    
    Thanks Dave! Agreed - will take care of it as you suggested.
    
    I will also remove the call to ex_conv_clause::populateInstrOffsetIndex() from ex_conv_clause::getInstrOffset.
This way ex_conv_clause::populateInstrOffsetIndex() will only be called from sqInit().


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message