[ 
https://issues.apache.org/jira/browse/TRAFODION-2137?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15404860#comment-15404860
 ] 

ASF GitHub Bot commented on TRAFODION-2137:
-------------------------------------------

Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/634#discussion_r73243684
  
    --- Diff: core/sql/sqlcat/TrafDDLdesc.cpp ---
    @@ -0,0 +1,617 @@
    +/**********************************************************************
    +// @@@ START COPYRIGHT @@@
    +//
    +// Licensed to the Apache Software Foundation (ASF) under one
    +// or more contributor license agreements.  See the NOTICE file
    +// distributed with this work for additional information
    +// regarding copyright ownership.  The ASF licenses this file
    +// to you under the Apache License, Version 2.0 (the
    +// "License"); you may not use this file except in compliance
    +// with the License.  You may obtain a copy of the License at
    +//
    +//   http://www.apache.org/licenses/LICENSE-2.0
    +//
    +// Unless required by applicable law or agreed to in writing,
    +// software distributed under the License is distributed on an
    +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +// KIND, either express or implied.  See the License for the
    +// specific language governing permissions and limitations
    +// under the License.
    +//
    +// @@@ END COPYRIGHT @@@
    +//
    +**********************************************************************/
    +
    +#include "TrafDDLdesc.h"
    +#include "CmpCommon.h"
    +
    +// -----------------------------------------------------------------------
    +// Allocate one of the primitive structs and initialize to all zeroes.
    +// Uses HEAP (StatementHeap) of CmpCommon or space.
    +// -----------------------------------------------------------------------
    +TrafDesc *TrafAllocateDDLdesc(desc_nodetype nodetype, Space * space)
    +{
    +  size_t size = 0;
    +  TrafDesc * desc_ptr = NULL;
    +
    +  switch (nodetype)
    +    {
    +    case DESC_CHECK_CONSTRNTS_TYPE:
    +      desc_ptr = new GENHEAP(space) TrafCheckConstrntsDesc();
    +      break;
    +    case DESC_COLUMNS_TYPE:
    +      desc_ptr = new GENHEAP(space) TrafColumnsDesc();
    +      break;
    +    case DESC_CONSTRNTS_TYPE:
    +      desc_ptr = new GENHEAP(space) TrafConstrntsDesc();
    +      break;
    +    case DESC_CONSTRNT_KEY_COLS_TYPE:
    +      desc_ptr = new GENHEAP(space) TrafConstrntKeyColsDesc();
    +      break;
    +    case DESC_FILES_TYPE:
    +      desc_ptr = new GENHEAP(space) TrafFilesDesc();
    +      break;
    +    case DESC_HBASE_RANGE_REGION_TYPE:
    +      desc_ptr = new GENHEAP(space) TrafHbaseRegionDesc();
    +      break;
    +    case DESC_HISTOGRAM_TYPE:
    +      desc_ptr = new GENHEAP(space) TrafHistogramDesc();
    +      break;
    +    case DESC_HIST_INTERVAL_TYPE:
    +      desc_ptr = new GENHEAP(space) TrafHistIntervalDesc();
    +      break;
    +    case DESC_INDEXES_TYPE:
    +      desc_ptr = new GENHEAP(space) TrafIndexesDesc();
    +      break;
    +    case DESC_KEYS_TYPE:
    +      desc_ptr = new GENHEAP(space) TrafKeysDesc();
    +      break;
    +    case DESC_LIBRARY_TYPE:
    +      desc_ptr = new GENHEAP(space) TrafLibraryDesc();
    +      break;
    +     case DESC_PARTNS_TYPE:
    +      desc_ptr = new GENHEAP(space) TrafPartnsDesc();
    +      break;
    +    case DESC_REF_CONSTRNTS_TYPE:
    +      desc_ptr = new GENHEAP(space) TrafRefConstrntsDesc();
    +      break;
    +    case DESC_ROUTINE_TYPE:
    +      desc_ptr = new GENHEAP(space) TrafRoutineDesc();
    +      break;
    +    case DESC_SEQUENCE_GENERATOR_TYPE:   
    +      desc_ptr = new GENHEAP(space) TrafSequenceGeneratorDesc();
    +      break;
    +    case DESC_TABLE_TYPE:
    +      desc_ptr = new GENHEAP(space) TrafTableDesc();
    +      break;
    +    case DESC_VIEW_TYPE:
    +      desc_ptr = new GENHEAP(space) TrafViewDesc();
    +      break;              
    +    case DESC_USING_MV_TYPE: 
    +      desc_ptr = new GENHEAP(space) TrafUsingMvDesc();
    +      break;
    +    default:
    +      assert(FALSE);
    +      break;
    +    }
    +
    +  // if not being allocated from space, memset all bytes to 0.
    +  // If allocated from space, it will be set to 0 during space allocation.
    +  if (! space)
    +    memset((char*)desc_ptr+sizeof(TrafDesc), 0, 
    +           desc_ptr->getClassSize()-sizeof(TrafDesc));
    +
    +  return desc_ptr;
    +
    +}
    +
    +TrafDesc::TrafDesc(UInt16 nodeType) 
    +  : NAVersionedObject(nodeType),
    +    nodetype(nodeType),
    +    version(CURR_VERSION),
    +    descFlags(0),
    +    next(NULL)
    +{}
    +
    +Lng32 TrafDesc::validateSize()
    +{
    +  if (getImageSize() != getClassSize())
    +    return -1;
    +
    +  return 0;
    +}
    +
    +Lng32 TrafDesc::validateVersion()
    +{
    +  if (version != CURR_VERSION)
    +    return -1;
    +
    +  return 0;
    +}
    +
    +Lng32 TrafDesc::migrateToNewVersion(
    +     NAVersionedObject *&newImage)
    +{
    +  short tempimagesize = getClassSize();
    +  // -----------------------------------------------------------------
    +  // The base class implementation of migrateToNewVersion() is only
    +  // called with newImage == NULL when the same function is not
    +  // redefined at the subclass. That means no new version of that
    +  // subclass has been invented yet.
    +  // -----------------------------------------------------------------
    +  if (newImage == NULL)
    +    {
    +      if (validateSize())
    +        return -1;
    +
    +      if (validateVersion())
    +        return -1;
    +    }
    +
    +  return NAVersionedObject::migrateToNewVersion(newImage);
    +}
    +
    +char *TrafDesc::findVTblPtr(short classID)
    +{
    +  char *vtblptr = NULL;
    +
    +  switch (classID)
    +    {
    +    case DESC_CHECK_CONSTRNTS_TYPE:
    +      GetVTblPtr(vtblptr, TrafCheckConstrntsDesc);
    +      break;
    +    case DESC_COLUMNS_TYPE:
    +      GetVTblPtr(vtblptr, TrafColumnsDesc);
    +      break;
    +    case DESC_CONSTRNTS_TYPE:
    +      GetVTblPtr(vtblptr, TrafConstrntsDesc);
    +      break;
    +    case DESC_CONSTRNT_KEY_COLS_TYPE:
    +      GetVTblPtr(vtblptr, TrafConstrntKeyColsDesc);
    +      break;
    +    case DESC_FILES_TYPE:
    +      GetVTblPtr(vtblptr, TrafFilesDesc);
    +      break;
    +    case DESC_HBASE_RANGE_REGION_TYPE:
    +      GetVTblPtr(vtblptr, TrafHbaseRegionDesc);
    +      break;
    +    case DESC_HISTOGRAM_TYPE:
    +      GetVTblPtr(vtblptr, TrafHistogramDesc);
    +      break;
    +    case DESC_HIST_INTERVAL_TYPE:
    +      GetVTblPtr(vtblptr, TrafHistIntervalDesc);
    +      break;
    +    case DESC_INDEXES_TYPE:
    +      GetVTblPtr(vtblptr, TrafIndexesDesc);
    +      break;
    +    case DESC_KEYS_TYPE:
    +      GetVTblPtr(vtblptr, TrafKeysDesc);
    +      break;
    +    case DESC_LIBRARY_TYPE:
    +      GetVTblPtr(vtblptr, TrafLibraryDesc);
    +      break;
    +     case DESC_PARTNS_TYPE:
    +      GetVTblPtr(vtblptr, TrafPartnsDesc);
    +      break;
    +    case DESC_REF_CONSTRNTS_TYPE:
    +      GetVTblPtr(vtblptr, TrafRefConstrntsDesc);
    +      break;
    +    case DESC_ROUTINE_TYPE:
    +      GetVTblPtr(vtblptr, TrafRoutineDesc);
    +      break;
    +    case DESC_SEQUENCE_GENERATOR_TYPE:   
    +      GetVTblPtr(vtblptr, TrafSequenceGeneratorDesc);
    +      break;
    +    case DESC_TABLE_TYPE:
    +      GetVTblPtr(vtblptr, TrafTableDesc);
    +      break;
    +    case DESC_VIEW_TYPE:
    +      GetVTblPtr(vtblptr, TrafViewDesc);
    +      break;              
    +    case DESC_USING_MV_TYPE: 
    +      GetVTblPtr(vtblptr, TrafUsingMvDesc);
    +      break;
    +    default:
    +      assert(FALSE);
    +      break;
    +    }
    +
    +  return vtblptr;
    +}
    +
    +// pack and unpack methods for various descriptor structs
    +
    +Long TrafDesc::pack(void * space)
    +{
    +  next.pack(space);
    --- End diff --
    
    These guys are all recursive. Any worries about stack overflow limits?


> Improve metadata access time during query compilation
> -----------------------------------------------------
>
>                 Key: TRAFODION-2137
>                 URL: https://issues.apache.org/jira/browse/TRAFODION-2137
>             Project: Apache Trafodion
>          Issue Type: Improvement
>            Reporter: Anoop Sharma
>            Assignee: Anoop Sharma
>
> When a trafodion object is accessed for the first time in a session, 
> information about it is read from metadata.
> Multiple metadata tables are read to retrieve information about the
> objects being used in the query.
> Once metadata info is read about a table, it is cached in compiler memory. 
> Another query accessing the same object gets it from compiler metadata
> cache.
> This results in the first query compile performance to be slower than the
> subsequent queries accessing the same objects.
> This JIRA is to improve performance of first access of an object in
> a query.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to