当前位置: 首页>>代码示例>>C++>>正文


C++ Attributes::getDatatype方法代码示例

本文整理汇总了C++中Attributes::getDatatype方法的典型用法代码示例。如果您正苦于以下问题:C++ Attributes::getDatatype方法的具体用法?C++ Attributes::getDatatype怎么用?C++ Attributes::getDatatype使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Attributes的用法示例。


在下文中一共展示了Attributes::getDatatype方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: new

//Detailed error support for clause expression evaluation.
ComDiagsArea *ExRaiseDetailSqlError(CollHeap* heap, 
				    ComDiagsArea** diagsArea,
				    ExeErrorCode err, 
				    ex_clause *clause,
                                    char *op_data[])
{
  if (diagsArea == NULL)
    return NULL;
  
  if (*diagsArea == NULL){
  
    if (heap == NULL)
      return NULL;
    *diagsArea = ComDiagsArea::allocate(heap);
  }
 
  Int16 numOperands = clause->getNumOperands();
  Attributes *op;
  Int16 i; 
  
  // Single allocation of buf is split up to be used for opstrings,
  // formatting. See defines at beginning of this header file 
  // for details. 
  char *buf = new (heap)
    char[(numOperands * (VALUE_TYPE_LEN + OPVALUE_LEN)) + INSTR_LEN + FORMATTING];
  
  if( !buf ){
    ExRaiseSqlError(heap, diagsArea, err);
    return *diagsArea;
  }
  char *opStrings = &buf[(numOperands * VALUE_TYPE_LEN) + INSTR_LEN ];
  // assign FORMATTING part of address.
  char *buf1 = &buf[(numOperands * (VALUE_TYPE_LEN + OPVALUE_LEN)) + INSTR_LEN];
 
  for (i = 1; i < numOperands; i++){
    op = clause->getOperand(i);
    ExConvertErrorToString(heap,
                           diagsArea,
                           (char*)op_data[i],
                           op->getLength(),
                           op->getDatatype(),
                           op->getScale(),
                           (char*)&opStrings[(i-1)*OPVALUE_LEN],
                           OPVALUE_LEN);

  }

  //initialize buf before entering the loop.
  buf[0] = '\0';

  for(i = 1; i< numOperands; i++){
    op = clause->getOperand(i);
    str_sprintf(buf1, " Operand%d Type:%s(%s) Operand%d Value:%s",i,
                        getDatatypeAsString(op->getDatatype(), true),
                        getDatatypeAsString(op->getDatatype(), false),
                        i,
                        &opStrings[(i-1)*OPVALUE_LEN]);
    str_cat(buf, buf1, buf);
  }
  if(numOperands)
  {
    str_sprintf(buf1,".");
    str_cat(buf, buf1, buf);
  }
  str_sprintf(buf1, " Clause Type:%d Clause number:%d Operation:%s.",
                     clause->getType(), clause->clauseNum(),
                     exClauseGetText(clause->getOperType()));
  str_cat(buf, buf1, buf);
  
  **diagsArea << DgSqlCode(-err);
  **diagsArea<<DgString0(buf);
  
  NADELETEBASICARRAY(buf, (heap));
  return *diagsArea;
}
开发者ID:apache,项目名称:incubator-trafodion,代码行数:76,代码来源:ExpError.cpp

示例2: work


//.........这里部分代码省略.........
              Lng32 intParam1 = -retcode;
              ComDiagsArea * diagsArea = NULL;
              ExRaiseSqlError(getHeap(), &diagsArea,
                  (ExeErrorCode)(8442), NULL, &intParam1,
                  &cliError, NULL, (char*)"ExpLOBinterfaceCreate",
                  getLobErrStr(intParam1));
              pentry_down->setDiagsArea(diagsArea);
              pstate.step_ = EXTRACT_ERROR;
              break;
            }
          }
            
          if (feStats)
          {
            feStats->setPartitionNumber(fileNum);
          }
        }
        else
        {
          updateWorkATPDiagsArea(__FILE__,__LINE__,"sockets are not supported");
          pstate.step_ = EXTRACT_ERROR;
          break;
        }

      for (UInt32 i = 0; i < myTdb().getChildTuple()->numAttrs(); i++)
      {
        Attributes * attr = myTdb().getChildTableAttr(i);
        Attributes * attr2 = myTdb().getChildTableAttr2(i);

        ex_conv_clause tempClause;
        int convIndex = 0;
        sourceFieldsConvIndex_[i] =
            tempClause.find_case_index(
                attr->getDatatype(),
                0,
                attr2->getDatatype(),
                0,
                0);

      }

      pstate.step_= EXTRACT_PASS_REQUEST_TO_CHILD;
    }
    break;

    case EXTRACT_PASS_REQUEST_TO_CHILD:
    {
      // pass the parent request to the child downqueue
      if (!qChild_.down->isFull())
      {
        ex_queue_entry * centry = qChild_.down->getTailEntry();

        if (request == ex_queue::GET_N)
          centry->downState.request = ex_queue::GET_ALL;
        else
          centry->downState.request = request;

        centry->downState.requestValue = pentry_down->downState.requestValue;
        centry->downState.parentIndex = qParent_.down->getHeadIndex();
        // set the child's input atp
        centry->passAtp(pentry_down->getAtp());
        qChild_.down->insert();
        pstate.processingStarted_ = TRUE;
      }
      else
        // couldn't pass request to child, return
开发者ID:sandhyasun,项目名称:incubator-trafodion,代码行数:67,代码来源:ExFastTransport.cpp

示例3: convDoIt

// error denoted by negative return code
int ex_expr::formatARow2(const char** srcFldsPtr,
                         const int* srcFldsLength,
                         const int * srcFieldsConvIndex,
                         char* formattedRow,
                         int& formattedRowLength,
                         int numAttrs,
                         AttributesPtr * attrs,
                         ExpTupleDesc *tupleDesc,
                         UInt16 firstFixedOffset,
                         UInt16 bitmapEntryOffset,
                         UInt16 bitmapOffset,
                         NABoolean sysKeyTable,
                         CollHeap *heap,
                         ComDiagsArea **diags)
{

  formattedRowLength = tupleDesc->tupleDataLength();  //need to fix this later for other types
  //char *sourceData = (char*)asciiRow;
  //char *sourceDataEnd =(char*)asciiRow + rowLength;
  //assert (sourceDataEnd);


  //set the headers in tuple.
  ExpTupleDesc::setFirstFixedOffset(formattedRow,
                                firstFixedOffset,
                                tupleDesc->getTupleDataFormat());

  //Bitmap offset value is zero if bitmap is not preset. But bitmap offset
  //still exists.
  ExpAlignedFormat::setBitmapOffset(formattedRow + bitmapEntryOffset,
                                    - bitmapOffset);


  char *targetData = NULL;

  //for varchars
  UInt32  vcActualLen = 0;
  UInt32  voaOffset = 0;
  UInt32  vOffset = 0;
  Int32   vcLenIndOffset = 0;
  bool    firstvc = true;
  char paddedTimestampVal[27] = "2000-01-01 00:00:00.000000" ;
  

  int startCol = 0;
  if (sysKeyTable)
  {
    startCol =1;
  }
  for(int index= startCol; index < numAttrs ; index++)
  {
    //Attributes * attr = myTdb().getOutputAttr(index);
    Attributes * attr = attrs[index];
    //loop thru all the columns in the row. For each column,
    //find its corresponding offset in ascii row. Corresponding
    //offset is identified and converted.

    char * srcColData = (char*)srcFldsPtr[index - startCol];
    int  srcColLen = srcFldsLength[index - startCol];

    //set null bit map if column is nullable.
    //if ( attr->getDefaultClass() == Attributes::DEFAULT_NULL )
      // ExpAlignedFormat::setNullValue( formattedRow, attr->getNullBitIndex() );

    if (! srcColLen )
    {
        ExpAlignedFormat::setNullValue( formattedRow, attr->getNullBitIndex() );
        continue;
    }

    if((!firstvc)  && attr->getVCIndicatorLength() > 0)
      targetData = (char*) formattedRow + vOffset;
    else
      targetData = (char*) formattedRow + attr->getOffset();

    if (attr->getDatatype() == REC_DATETIME && srcColLen == 10)
      {
        srcColData = &(paddedTimestampVal[0]);
        srcColLen = 26;
      }

    ex_expr::exp_return_type err = convDoIt(srcColData,
                                            srcColLen,
                                            REC_BYTE_F_ASCII,
                                            0,0,
                                            targetData,
                                            attr->getLength(),
                                            attr->getDatatype(),
                                            attr->getPrecision(),
                                            attr->getScale(),
                                            (char*)&vcActualLen,
                                            sizeof(vcActualLen),
                                            heap,
                                            diags,
                                            (conv_case_index)srcFieldsConvIndex[index]
                                            );

    if(err == ex_expr::EXPR_ERROR) return -1;

//.........这里部分代码省略.........
开发者ID:XueminZhu,项目名称:incubator-trafodion,代码行数:101,代码来源:exp_expr.cpp

示例4: convertSQRowToString

void ExHdfsFastExtractTcb::convertSQRowToString(ULng32 nullLen,
                            ULng32 recSepLen,
                            ULng32 delimLen,
                            tupp_descriptor* dataDesc,
                            char* targetData,
                            NABoolean & convError) {
  char* childRow = dataDesc->getTupleAddress();
  ULng32 childRowLen = dataDesc->getAllocatedSize();
  UInt32 vcActualLen = 0;

  for (UInt32 i = 0; i < myTdb().getChildTuple()->numAttrs(); i++) {
    Attributes * attr = myTdb().getChildTableAttr(i);
    Attributes * attr2 = myTdb().getChildTableAttr2(i);
    char *childColData = NULL; //childRow + attr->getOffset();
    UInt32 childColLen = 0;
    UInt32 maxTargetColLen = attr2->getLength();

    //format is aligned format--
    //----------
    // field is varchar
    if (attr->getVCIndicatorLength() > 0) {
      childColData = childRow + *((UInt32*) (childRow + attr->getVoaOffset()));
      childColLen = attr->getLength(childColData);
      childColData += attr->getVCIndicatorLength();
    } else {              //source is fixed length
      childColData = childRow + attr->getOffset();
      childColLen = attr->getLength();
      if ((attr->getCharSet() == CharInfo::ISO88591
          || attr->getCharSet() == CharInfo::UTF8) && childColLen > 0) {
        // trim trailing blanks
        while (childColLen > 0 && childColData[childColLen - 1] == ' ') {
          childColLen--;
        }
      } else if (attr->getCharSet() == CharInfo::UCS2 && childColLen > 1) {
        ex_assert(childColLen % 2 == 0, "invalid ucs2");
        NAWchar* wChildColData = (NAWchar*) childColData;
        Int32 wChildColLen = childColLen / 2;
        while (wChildColLen > 0 && wChildColData[wChildColLen - 1] == L' ') {
          wChildColLen--;
        }
        childColLen = wChildColLen * 2;
      }
    }

    if (attr->getNullFlag()
        && ExpAlignedFormat::isNullValue(childRow + attr->getNullIndOffset(),
            attr->getNullBitIndex())) {
      // source is a null value.

      nullLen = 0;
      if (myTdb().getNullString()) {
        nullLen = strlen(myTdb().getNullString());
        memcpy(targetData, myTdb().getNullString(), nullLen); 
      } 

      targetData += nullLen;
      currBuffer_->bytesLeft_ -= nullLen;
    } else {
      switch ((conv_case_index) sourceFieldsConvIndex_[i]) {
      case CONV_ASCII_V_V:
      case CONV_ASCII_F_V:
      case CONV_UNICODE_V_V:
      case CONV_UNICODE_F_V: {
        if (childColLen > 0) {
          memcpy(targetData, childColData, childColLen);
          targetData += childColLen;
          currBuffer_->bytesLeft_ -= childColLen;
        }
      }
        break;

      default:
        ex_expr::exp_return_type err = convDoIt(childColData, childColLen,
            attr->getDatatype(), attr->getPrecision(), attr->getScale(),
            targetData, attr2->getLength(), attr2->getDatatype(),
            attr2->getPrecision(), attr2->getScale(), (char*) &vcActualLen,
            sizeof(vcActualLen), 0, 0,             // diags may need to be added
            (conv_case_index) sourceFieldsConvIndex_[i]);

        if (err == ex_expr::EXPR_ERROR) {
          convError = TRUE;
          // not exit loop -- we will log the errenous row later
          // do not cancel processing for this type of error???
        }
        targetData += vcActualLen;
        currBuffer_->bytesLeft_ -= vcActualLen;
        break;
      }                      //switch
    }

    if (i == myTdb().getChildTuple()->numAttrs() - 1) {
      strncpy(targetData, myTdb().getRecordSeparator(), recSepLen);
      targetData += recSepLen;
      currBuffer_->bytesLeft_ -= recSepLen;
    } else {
      strncpy(targetData, myTdb().getDelimiter(), delimLen);
      targetData += delimLen;
      currBuffer_->bytesLeft_ -= delimLen;
    }

//.........这里部分代码省略.........
开发者ID:sandhyasun,项目名称:incubator-trafodion,代码行数:101,代码来源:ExFastTransport.cpp


注:本文中的Attributes::getDatatype方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。