trafodion-codereview mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DaveBirdsall <...@git.apache.org>
Subject [GitHub] incubator-trafodion pull request #634: JIRA TRAFODION-2137 metadata access p...
Date Tue, 02 Aug 2016 21:48:38 GMT
Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/634#discussion_r73244593
  
    --- Diff: core/sql/sqlcat/TrafDDLdesc.h ---
    @@ -0,0 +1,1120 @@
    +/**********************************************************************
    +// @@@ 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 @@@
    +//
    +**********************************************************************/
    +#ifndef TRAF_DDL_DESC_H
    +#define TRAF_DDL_DESC_H
    +
    +#include "Platform.h"
    +#include "NAVersionedObject.h"
    +#include "charinfo.h"
    +#include "ComSmallDefs.h"
    +
    +#define GENHEAP(h)    (h ? (NAMemory*)h : CmpCommon::statementHeap())
    +
    +enum ConstraintType { UNIQUE_CONSTRAINT, PRIMARY_KEY_CONSTRAINT, REF_CONSTRAINT,
    +		      CHECK_CONSTRAINT
    +		    };
    +
    +enum desc_nodetype {
    +  DESC_UNKNOWN_TYPE = 0,
    +  DESC_CHECK_CONSTRNTS_TYPE,
    +  DESC_COLUMNS_TYPE,
    +  DESC_CONSTRNTS_TYPE,
    +  DESC_CONSTRNT_KEY_COLS_TYPE,
    +  DESC_FILES_TYPE,
    +  DESC_HBASE_RANGE_REGION_TYPE,
    +  DESC_HISTOGRAM_TYPE,
    +  DESC_HIST_INTERVAL_TYPE,
    +  DESC_INDEXES_TYPE,
    +  DESC_KEYS_TYPE,
    +  DESC_PARTNS_TYPE,
    +  DESC_REF_CONSTRNTS_TYPE,
    +  DESC_TABLE_TYPE,
    +  DESC_USING_MV_TYPE,  // MV  -- marks an MV using this object
    +  DESC_VIEW_TYPE,
    +  DESC_SCHEMA_LABEL_TYPE,
    +  DESC_SEQUENCE_GENERATOR_TYPE,
    +  DESC_ROUTINE_TYPE,
    +  DESC_LIBRARY_TYPE
    +};
    +
    +class TrafDesc;
    +typedef NAVersionedObjectPtrTempl<TrafDesc> DescStructPtr;
    +
    +class TrafCheckConstrntsDesc;
    +class TrafColumnsDesc;
    +class TrafConstrntsDesc;
    +class TrafConstrntKeyColsDesc;
    +class TrafHbaseRegionDesc;
    +class TrafHistogramDesc;
    +class TrafHistIntervalDesc;
    +class TrafFilesDesc;
    +class TrafKeysDesc;
    +class TrafIndexesDesc;
    +class TrafLibraryDesc;
    +class TrafPartnsDesc;
    +class TrafRefConstrntsDesc;
    +class TrafRoutineDesc;
    +class TrafSequenceGeneratorDesc;
    +class TrafTableDesc;
    +class TrafUsingMvDesc;
    +class TrafViewDesc;
    +
    +class TrafDesc : public NAVersionedObject {
    +public:
    +  enum {CURR_VERSION = 1};
    +
    +  TrafDesc(UInt16 nodeType);
    +  TrafDesc() : NAVersionedObject(-1) {}
    +
    +  // ---------------------------------------------------------------------
    +  // Redefine virtual functions required for Versioning.
    +  //----------------------------------------------------------------------
    +  virtual unsigned char getClassVersionID()
    +  {
    +    return 1;
    +  }
    +
    +  virtual void populateImageVersionIDArray()
    +  {
    +    setImageVersionID(0,getClassVersionID());
    +  }
    +
    +  virtual short getClassSize()      { return (short)sizeof(TrafDesc); }
    +
    +  virtual Lng32 migrateToNewVersion(NAVersionedObject *&newImage);
    +
    +  virtual char *findVTblPtr(short classID);
    +
    +  virtual Long pack(void *space);
    +  virtual Lng32 unpack(void * base, void * reallocator);
    +
    +  Lng32 validateSize();
    +  Lng32 validateVersion();
    + 
    +  UInt16 nodetype;
    +  UInt16 version;
    +  UInt32 descFlags;
    +  DescStructPtr next;
    +  char* descExtension; // extension of descriptor, if it needs to be extended
    +
    +  virtual TrafCheckConstrntsDesc *checkConstrntsDesc() const { return NULL; }
    +  virtual TrafColumnsDesc *columnsDesc() const { return NULL; }
    +  virtual TrafConstrntsDesc *constrntsDesc() const { return NULL; }
    +  virtual TrafConstrntKeyColsDesc *constrntKeyColsDesc() const { return NULL; }
    +  virtual TrafFilesDesc *filesDesc() const { return NULL; }
    +  virtual TrafHbaseRegionDesc *hbaseRegionDesc() const { return NULL; }
    +  virtual TrafHistogramDesc *histogramDesc() const { return NULL; }
    +  virtual TrafHistIntervalDesc *histIntervalDesc() const { return NULL; }
    +  virtual TrafKeysDesc *keysDesc() const { return NULL; }
    +  virtual TrafIndexesDesc *indexesDesc() const { return NULL; }
    +  virtual TrafLibraryDesc *libraryDesc() const { return NULL; }
    +  virtual TrafPartnsDesc *partnsDesc() const { return NULL; }
    +  virtual TrafRefConstrntsDesc *refConstrntsDesc() const { return NULL; }
    +  virtual TrafRoutineDesc *routineDesc() const { return NULL; }
    +  virtual TrafSequenceGeneratorDesc *sequenceGeneratorDesc() const { return NULL; }
    +  virtual TrafTableDesc *tableDesc() const { return NULL; }
    +  virtual TrafUsingMvDesc *usingMvDesc() const { return NULL; }
    +  virtual TrafViewDesc *viewDesc() const { return NULL; }
    +
    +};
    +
    +class TrafCheckConstrntsDesc : public TrafDesc {
    +public:
    +  TrafCheckConstrntsDesc() : TrafDesc(DESC_CHECK_CONSTRNTS_TYPE)
    +  {}
    +
    +  // ---------------------------------------------------------------------
    +  // Redefine virtual functions required for Versioning.
    +  //----------------------------------------------------------------------
    +  virtual unsigned char getClassVersionID()
    +  {
    +    return 1;
    +  }
    +
    +  virtual void populateImageVersionIDArray()
    +  {
    +    setImageVersionID(0,getClassVersionID());
    +  }
    +
    +  virtual short getClassSize()      { return (short)sizeof(TrafCheckConstrntsDesc); }
    + 
    +  virtual Long pack(void *space);
    +  virtual Lng32 unpack(void * base, void * reallocator);
    +
    +  virtual TrafCheckConstrntsDesc *checkConstrntsDesc() const { return (TrafCheckConstrntsDesc*)this;
}
    +
    +  char* constrnt_text;
    +  char filler[16];
    +};
    +
    +class TrafColumnsDesc : public TrafDesc {
    +public:
    +  TrafColumnsDesc() : TrafDesc(DESC_COLUMNS_TYPE) 
    +  {};
    +
    +  // ---------------------------------------------------------------------
    +  // Redefine virtual functions required for Versioning.
    +  //----------------------------------------------------------------------
    +  virtual unsigned char getClassVersionID()
    +  {
    +    return 1;
    +  }
    +
    +  virtual void populateImageVersionIDArray()
    +  {
    +    setImageVersionID(0,getClassVersionID());
    +  }
    +
    +  virtual short getClassSize()      { return (short)sizeof(TrafColumnsDesc); }
    + 
    +  virtual Long pack(void *space);
    +  virtual Lng32 unpack(void * base, void * reallocator);
    +
    +  virtual TrafColumnsDesc *columnsDesc() const { return (TrafColumnsDesc*)this; }
    +
    +  enum ColumnsDescFlags
    +    { 
    +      NULLABLE           = 0x0001,  
    +      ADDED              = 0x0002,
    +      UPSHIFTED          = 0x0004,
    +      CASEINSENSITIVE    = 0x0008,
    +      OPTIONAL           = 0x0010
    +    };
    +
    +  void setNullable(NABoolean v) 
    +  {(v ? columnsDescFlags |= NULLABLE : columnsDescFlags &= ~NULLABLE); };
    +  NABoolean isNullable() { return (columnsDescFlags & NULLABLE) != 0; };
    +
    +  void setAdded(NABoolean v) 
    +  {(v ? columnsDescFlags |= ADDED : columnsDescFlags &= ~ADDED); };
    +  NABoolean isAdded() { return (columnsDescFlags & ADDED) != 0; };
    +
    +  void setUpshifted(NABoolean v) 
    +  {(v ? columnsDescFlags |= UPSHIFTED : columnsDescFlags &= ~UPSHIFTED); };
    +  NABoolean isUpshifted() { return (columnsDescFlags & UPSHIFTED) != 0; };
    +
    +  void setCaseInsensitive(NABoolean v) 
    +  {(v ? columnsDescFlags |= CASEINSENSITIVE : columnsDescFlags &= ~CASEINSENSITIVE);
};
    +  NABoolean isCaseInsensitive() { return (columnsDescFlags & CASEINSENSITIVE) !=
0; };
    +
    +  void setOptional(NABoolean v) 
    +  {(v ? columnsDescFlags |= OPTIONAL : columnsDescFlags &= ~OPTIONAL); };
    +  NABoolean isOptional() { return (columnsDescFlags & OPTIONAL) != 0; };
    +
    +  rec_datetime_field datetimeStart() 
    +  { return (rec_datetime_field)datetimestart;}
    +  rec_datetime_field datetimeEnd() 
    +  { return (rec_datetime_field)datetimeend;}
    +
    +  ComColumnDefaultClass defaultClass() 
    +  { return (ComColumnDefaultClass)defaultClass_;}
    +  void setDefaultClass(ComColumnDefaultClass v)
    +  { defaultClass_ = (Int16)v;}
    +
    +  CharInfo::CharSet characterSet() 
    +  { return (CharInfo::CharSet)character_set;}
    +  CharInfo::CharSet encodingCharset() 
    +  { return (CharInfo::CharSet)encoding_charset;}
    +  CharInfo::Collation  collationSequence()
    +  {return (CharInfo::Collation)collation_sequence; }
    +
    +  ComParamDirection paramDirection() 
    +  { return (ComParamDirection)paramDirection_;}
    +  void setParamDirection(ComParamDirection v)
    +  {paramDirection_ = (Int16)v; }
    +
    +  char* colname;
    +
    +  Int32 colnumber;
    +  Int32 datatype;
    +
    +  Int32 offset;
    +  Lng32 length;
    +
    +  Lng32 scale;
    +  Lng32 precision;
    +
    +  Int16/*rec_datetime_field*/ datetimestart, datetimeend;
    +  Int16 datetimefractprec, intervalleadingprec;
    +
    +  Int16/*ComColumnDefaultClass*/ defaultClass_;
    +  Int16/*CharInfo::CharSet*/     character_set;
    +  Int16/*CharInfo::CharSet*/     encoding_charset;
    +  Int16/*CharInfo::Collation*/   collation_sequence;
    +
    +  ULng32 hbaseColFlags;
    +  Int16/*ComParamDirection*/ paramDirection_;
    +  char colclass; // 'S' -- system generated, 'U' -- user created
    +  char filler0;
    +
    +  Int64 colFlags;
    +  Int64 columnsDescFlags; // my flags
    +
    +  char* pictureText;
    +  char* defaultvalue;
    +  char* heading;
    +  char* computed_column_text;
    +  char* hbaseColFam;
    +  char* hbaseColQual;
    +
    +  char filler[24];
    +};
    +
    +class TrafConstrntKeyColsDesc : public TrafDesc {
    +public:
    +  TrafConstrntKeyColsDesc() : TrafDesc(DESC_CONSTRNT_KEY_COLS_TYPE)
    +  {}
    +
    +  // ---------------------------------------------------------------------
    +  // Redefine virtual functions required for Versioning.
    +  //----------------------------------------------------------------------
    +  virtual unsigned char getClassVersionID()
    +  {
    +    return 1;
    +  }
    +
    +  virtual void populateImageVersionIDArray()
    +  {
    +    setImageVersionID(0,getClassVersionID());
    +  }
    +
    +  virtual short getClassSize()      { return (short)sizeof(TrafConstrntKeyColsDesc);
}
    + 
    +  virtual Long pack(void *space);
    +  virtual Lng32 unpack(void * base, void * reallocator);
    +
    +  virtual TrafConstrntKeyColsDesc *constrntKeyColsDesc() const { return (TrafConstrntKeyColsDesc*)this;
}
    +
    +  char* colname;
    +  Int32  position;
    +
    +  Int64 constrntKeyColsDescFlags; // my flags
    +
    +  char filler[16];
    +};
    +
    +class TrafConstrntsDesc : public TrafDesc {
    +public:
    +  TrafConstrntsDesc() : TrafDesc(DESC_CONSTRNTS_TYPE)
    +  {}
    +
    +  // ---------------------------------------------------------------------
    +  // Redefine virtual functions required for Versioning.
    +  //----------------------------------------------------------------------
    +  virtual unsigned char getClassVersionID()
    +  {
    +    return 1;
    +  }
    +
    +  virtual void populateImageVersionIDArray()
    +  {
    +    setImageVersionID(0,getClassVersionID());
    +  }
    +
    +  virtual short getClassSize()      { return (short)sizeof(TrafConstrntsDesc); }
    + 
    +  virtual Long pack(void *space);
    +  virtual Lng32 unpack(void * base, void * reallocator);
    +
    +  virtual TrafConstrntsDesc *constrntsDesc() const { return (TrafConstrntsDesc*)this;
}
    +
    +  enum ConstrntsDescFlags
    +    { 
    +      ENFORCED           = 0x0001
    +    };
    +
    +  void setEnforced(NABoolean v) 
    +  {(v ? constrntsDescFlags |= ENFORCED : constrntsDescFlags &= ~ENFORCED); };
    +  NABoolean isEnforced() { return (constrntsDescFlags & ENFORCED) != 0; };
    +
    +  char* constrntname;
    +  char* tablename;
    +
    +  Int16 /*ConstraintType*/ type;
    +  Int16 fillerInt16;
    +  Int32  colcount;
    +
    +  Int64 constrntsDescFlags; // my flags
    +
    +  DescStructPtr check_constrnts_desc;
    +  DescStructPtr constr_key_cols_desc;
    +  DescStructPtr referenced_constrnts_desc;
    +  DescStructPtr referencing_constrnts_desc;
    +
    +  char filler[24];
    +};
    +
    +class TrafFilesDesc : public TrafDesc {
    +public:
    +  TrafFilesDesc() : TrafDesc(DESC_FILES_TYPE)
    +  {}
    +
    +  // ---------------------------------------------------------------------
    +  // Redefine virtual functions required for Versioning.
    +  //----------------------------------------------------------------------
    +  virtual unsigned char getClassVersionID()
    +  {
    +    return 1;
    +  }
    +
    +  virtual void populateImageVersionIDArray()
    +  {
    +    setImageVersionID(0,getClassVersionID());
    +  }
    +
    +  virtual short getClassSize()      { return (short)sizeof(TrafFilesDesc); }
    + 
    +  virtual Long pack(void *space);
    +  virtual Lng32 unpack(void * base, void * reallocator);
    +
    +  virtual TrafFilesDesc *filesDesc() const { return (TrafFilesDesc*)this; }
    +
    +  enum FilesDescFlags
    +    { 
    +      AUDITED           = 0x0001
    +    };
    +
    +  void setAudited(NABoolean v) 
    +  {(v ? filesDescFlags |= AUDITED : filesDescFlags &= ~AUDITED); };
    +  NABoolean isAudited() { return (filesDescFlags & AUDITED) != 0; };
    +
    +  Int64 filesDescFlags; // my flags
    +  DescStructPtr partns_desc;
    +};
    +
    +class TrafHbaseRegionDesc : public TrafDesc {
    +public:
    +  TrafHbaseRegionDesc() : TrafDesc(DESC_HBASE_RANGE_REGION_TYPE)
    +  {}
    +
    +  // ---------------------------------------------------------------------
    +  // Redefine virtual functions required for Versioning.
    +  //----------------------------------------------------------------------
    +  virtual unsigned char getClassVersionID()
    +  {
    +    return 1;
    +  }
    +
    +  virtual void populateImageVersionIDArray()
    +  {
    +    setImageVersionID(0,getClassVersionID());
    +  }
    +
    +  virtual short getClassSize()      { return (short)sizeof(TrafHbaseRegionDesc); }
    + 
    +  virtual Long pack(void *space);
    +  virtual Lng32 unpack(void * base, void * reallocator);
    +
    +  virtual TrafHbaseRegionDesc *hbaseRegionDesc() const { return (TrafHbaseRegionDesc*)this;
}
    +
    +  Int64  hbaseRegionDescFlags; // my flags
    +
    +  Lng32  beginKeyLen;
    +  Lng32  endKeyLen;
    +
    +  char*  beginKey;
    +  char*  endKey;
    +
    +  char filler[16];
    +};
    +
    +class TrafHistogramDesc : public TrafDesc {
    +public:
    +  TrafHistogramDesc() : TrafDesc(DESC_HISTOGRAM_TYPE)
    +  {}
    +
    +  // ---------------------------------------------------------------------
    +  // Redefine virtual functions required for Versioning.
    +  //----------------------------------------------------------------------
    +  virtual unsigned char getClassVersionID()
    +  {
    +    return 1;
    +  }
    +
    +  virtual void populateImageVersionIDArray()
    +  {
    +    setImageVersionID(0,getClassVersionID());
    +  }
    +
    +  virtual short getClassSize()      { return (short)sizeof(TrafHistogramDesc); }
    + 
    +  virtual Long pack(void *space);
    +  virtual Lng32 unpack(void * base, void * reallocator);
    +
    +  virtual TrafHistogramDesc *histogramDesc() const { return (TrafHistogramDesc*)this;
}
    +
    +  char*   tablename;
    +  char*   histid;
    +
    +  Int32   tablecolnumber;
    +  Int32   colposition;
    +
    +  Float32 rowcount;
    +  Float32 uec;
    +
    +  char*   highval;
    +  char*   lowval;
    +
    +  Int64 histogramDescFlags; // my flags
    +
    +  DescStructPtr hist_interval_desc;
    +
    +  char filler[24];
    +};
    +
    +class TrafHistIntervalDesc : public TrafDesc {
    +public:
    +  TrafHistIntervalDesc() : TrafDesc(DESC_HIST_INTERVAL_TYPE)
    +  {}
    +
    +  // ---------------------------------------------------------------------
    +  // Redefine virtual functions required for Versioning.
    +  //----------------------------------------------------------------------
    +  virtual unsigned char getClassVersionID()
    +  {
    +    return 1;
    +  }
    +
    +  virtual void populateImageVersionIDArray()
    +  {
    +    setImageVersionID(0,getClassVersionID());
    +  }
    +
    +  virtual short getClassSize()      { return (short)sizeof(TrafHistIntervalDesc); }
    + 
    +  virtual Long pack(void *space);
    +  virtual Lng32 unpack(void * base, void * reallocator);
    +
    +  virtual TrafHistIntervalDesc *histIntervalDesc() const { return (TrafHistIntervalDesc*)this;
}
    +
    +  char*   histid;
    +  char*   intboundary;
    +
    +  Float32  rowcount;
    +  Float32  uec;
    +
    +  Int32   intnum;
    +  Int32   fillerInt32;
    +
    +  Int64 histIntervalDescFlags; // my flags
    +
    +  char filler[16];
    +};
    +
    +class TrafIndexesDesc : public TrafDesc {
    +public:
    +  TrafIndexesDesc() : TrafDesc(DESC_INDEXES_TYPE)
    +  {}
    +
    +  // ---------------------------------------------------------------------
    +  // Redefine virtual functions required for Versioning.
    +  //----------------------------------------------------------------------
    +  virtual unsigned char getClassVersionID()
    +  {
    +    return 1;
    +  }
    +
    +  virtual void populateImageVersionIDArray()
    +  {
    +    setImageVersionID(0,getClassVersionID());
    +  }
    +
    +  virtual short getClassSize()      { return (short)sizeof(TrafIndexesDesc); }
    + 
    +  virtual Long pack(void *space);
    +  virtual Lng32 unpack(void * base, void * reallocator);
    +
    +  virtual TrafIndexesDesc *indexesDesc() const { return (TrafIndexesDesc*)this; }
    +
    +  enum IndexesDescFlags
    +    { 
    +      SYSTEM_TABLE_CODE = 0x0001,  
    +      EXPLICIT          = 0x0002,
    +      VOLATILE          = 0x0004,
    +      IN_MEM_OBJ        = 0x0008,
    +      UNIQUE            = 0x0010
    +    };
    +
    +  void setSystemTableCode(NABoolean v) 
    +  {(v ? indexesDescFlags |= SYSTEM_TABLE_CODE : indexesDescFlags &= ~SYSTEM_TABLE_CODE);
};
    +  NABoolean isSystemTableCode() { return (indexesDescFlags & SYSTEM_TABLE_CODE) !=
0; };
    +
    +  void setExplicit(NABoolean v) 
    +  {(v ? indexesDescFlags |= EXPLICIT : indexesDescFlags &= ~EXPLICIT); };
    +  NABoolean isExplicit() { return (indexesDescFlags & EXPLICIT) != 0; };
    +
    +  void setVolatile(NABoolean v) 
    +  {(v ? indexesDescFlags |= VOLATILE : indexesDescFlags &= ~VOLATILE); };
    +  NABoolean isVolatile() { return (indexesDescFlags & VOLATILE) != 0; };
    +
    +  void setInMemoryObject(NABoolean v) 
    +  {(v ? indexesDescFlags |= IN_MEM_OBJ : indexesDescFlags &= ~IN_MEM_OBJ); };
    +  NABoolean isInMemoryObject() { return (indexesDescFlags & IN_MEM_OBJ) != 0; };
    +
    +  void setUnique(NABoolean v) 
    +  {(v ? indexesDescFlags |= UNIQUE : indexesDescFlags &= ~UNIQUE); };
    +  NABoolean isUnique() { return (indexesDescFlags & UNIQUE) != 0; };
    +
    +  ComPartitioningScheme partitioningScheme() 
    +  { return (ComPartitioningScheme)partitioningScheme_; }
    +  void setPartitioningScheme(ComPartitioningScheme v) 
    +  { partitioningScheme_ = (Int16)v; }
    +  ComRowFormat rowFormat() { return (ComRowFormat)rowFormat_; }
    +  void setRowFormat(ComRowFormat v) { rowFormat_ = (Int16)v; }
    +
    +  char* tablename;  // name of the base table
    --- End diff --
    
    I was wondering about the char *'s. Do these pointer fields need to be packed and unpacked
as well? (In the old pre-64-bit days perhaps we had to, but no longer?) I was wondering why
they aren't wrapped in some pointer class like descriptor pointers. Perhaps it is because
there is nothing inside the character array that itself needs to be packed/unpacked?


---
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