コード例 #1
0
ファイル: token.cpp プロジェクト: Ambrou/cppcheck
void Token::stringify(std::ostream& os, bool varid, bool attributes, bool macro) const
{
    if (attributes) {
        if (isUnsigned())
            os << "unsigned ";
        else if (isSigned())
            os << "signed ";
        if (isLong()) {
            if (_type == eString || _type == eChar)
                os << "L";
            else
                os << "long ";
        }
    }
    if (macro && isExpandedMacro())
        os << "$";
    if (_str[0] != '\"' || _str.find("\0") == std::string::npos)
        os << _str;
    else {
        for (std::size_t i = 0U; i < _str.size(); ++i) {
            if (_str[i] == '\0')
                os << "\\0";
            else
                os << _str[i];
        }
    }
    if (varid && _varId != 0)
        os << '@' << _varId;
}
コード例 #2
0
ファイル: func_ceil.cpp プロジェクト: EPICPaaS/infinidb
double Func_ceil::getDoubleVal(Row& row,
							FunctionParm& parm,
							bool& isNull,
							CalpontSystemCatalog::ColType& op_ct)
{
	double ret = 0.0;
	if (op_ct.colDataType == CalpontSystemCatalog::DOUBLE ||
        op_ct.colDataType == CalpontSystemCatalog::UDOUBLE ||
        op_ct.colDataType == CalpontSystemCatalog::FLOAT ||
		op_ct.colDataType == CalpontSystemCatalog::UFLOAT)
	{
		ret = ceil(parm[0]->data()->getDoubleVal(row, isNull));
	}
	else if (op_ct.colDataType == CalpontSystemCatalog::VARCHAR ||
			 op_ct.colDataType == CalpontSystemCatalog::CHAR)
	{
		const string& str = parm[0]->data()->getStrVal(row, isNull);
		if (!isNull)
			ret = ceil(strtod(str.c_str(), 0));
	}
	else
	{
        if (isUnsigned(op_ct.colDataType))
        {
            ret = (double) getUintVal(row, parm, isNull, op_ct);
        }
        else
        {
            ret = (double) getIntVal(row, parm, isNull, op_ct);
        }
	}

	return ret;
}
コード例 #3
0
ファイル: AsmJsTypes.cpp プロジェクト: Cellule/ChakraCore
    bool AsmJsType::isSubType(AsmJsType type) const
    {
        switch (type.which_)
        {
        case Js::AsmJsType::Double:
            return isDouble();
            break;

        case Js::AsmJsType::MaybeDouble:
            return isMaybeDouble();
            break;
        case Js::AsmJsType::DoubleLit:
            return isDoubleLit();
            break;
        case Js::AsmJsType::Float:
            return isFloat();
            break;
        case Js::AsmJsType::MaybeFloat:
            return isMaybeFloat();
            break;
        case Js::AsmJsType::Floatish:
            return isFloatish();
            break;
        case Js::AsmJsType::FloatishDoubleLit:
            return isFloatishDoubleLit();
            break;
        case Js::AsmJsType::Fixnum:
            return which_ == Fixnum;
            break;
        case Js::AsmJsType::Int:
            return isInt();
            break;
        case Js::AsmJsType::Signed:
            return isSigned();
            break;
        case Js::AsmJsType::Unsigned:
            return isUnsigned();
            break;
        case Js::AsmJsType::Intish:
            return isIntish();
            break;
        case Js::AsmJsType::Void:
            return isVoid();
            break;
        case AsmJsType::Int32x4:
            return isSIMDInt32x4();
            break;
        case AsmJsType::Float32x4:
            return isSIMDFloat32x4();
            break;
        case AsmJsType::Float64x2:
            return isSIMDFloat64x2();
            break;
        default:
            break;
        }
        return false;
    }
コード例 #4
0
//------------------------------------------------------------------------------
// Print contents of this object to the log file.
//------------------------------------------------------------------------------
void ColExtInf::print( const JobColumn& column )
{
    boost::mutex::scoped_lock lock(fMapMutex);
    bool bIsChar = ((column.weType  == WriteEngine::WR_CHAR) &&
                    (column.colType != COL_TYPE_DICT));
    std::ostringstream oss;
    oss << "ColExtInf Map for OID: " << fColOid;
    RowExtMap::const_iterator iter = fMap.begin();
    while (iter != fMap.end())
    {
        oss << std::endl <<
            "  RowKey-" << iter->first           <<
            "; lbid-"   << iter->second.fLbid;
        if (iter->second.fLbid == (BRM::LBID_t)INVALID_LBID)
            oss << " (unset)";
        oss << "; newExt-" << iter->second.fNewExtent;
        if ( bIsChar )
        {
            // Swap/restore byte order before printing character string
            int64_t minVal = static_cast<int64_t>( uint64ToStr(
                static_cast<uint64_t>(iter->second.fMinVal) ) );
            int64_t maxVal = static_cast<int64_t>( uint64ToStr(
                static_cast<uint64_t>(iter->second.fMaxVal) ) );
            char minValStr[sizeof(int64_t) + 1];
            char maxValStr[sizeof(int64_t) + 1];
            memcpy(minValStr, &minVal, sizeof(int64_t));
            memcpy(maxValStr, &maxVal, sizeof(int64_t));
            minValStr[sizeof(int64_t)] = '\0';
            maxValStr[sizeof(int64_t)] = '\0';
            oss << "; minVal: " << minVal << "; (" << minValStr << ")"
                << "; maxVal: " << maxVal << "; (" << maxValStr << ")";
        }
        else if (isUnsigned(column.dataType))
        {
            oss << "; min: "    << static_cast<uint64_t>(iter->second.fMinVal)  <<
                   "; max: "    << static_cast<uint64_t>(iter->second.fMaxVal);
        }
        else
        {
            oss << "; min: "    << iter->second.fMinVal  <<
                   "; max: "    << iter->second.fMaxVal;
        }
        ++iter;
    }

    oss << std::endl << "  ColExtInf Rows/Extents waiting LBIDs: ";
    std::set<RID>::const_iterator iterPendingExt=fPendingExtentRows.begin();
    while (iterPendingExt != fPendingExtentRows.end())
    {
        oss << *iterPendingExt << ", ";
        ++iterPendingExt;
    }

    fLog->logMsg( oss.str(), MSGLVL_INFO2 );
}
コード例 #5
0
ファイル: token.cpp プロジェクト: Rajkishor/cppcheck
void Token::stringify(std::ostream& os, bool varid, bool attributes) const
{
    if (attributes) {
        if (isUnsigned())
            os << "unsigned ";
        else if (isSigned())
            os << "signed ";
        if (isLong())
            os << "long ";
    }
    os << _str;
    if (varid && _varId != 0)
        os << '@' << _varId;
}
コード例 #6
0
short BigNum::add(Attributes * left,
		  Attributes * right,
		  char * op_data[])
{
  // Extract signs.
  char leftSign = BIGN_GET_SIGN(op_data[1], getLength());
  char rightSign = BIGN_GET_SIGN(op_data[2], getLength());

  // Clear sign bits
  BIGN_CLR_SIGN(op_data[1], getLength());
  BIGN_CLR_SIGN(op_data[2], getLength());
 
  Int32 code;
  
  if ((!isUnsigned()) && ((leftSign) || (rightSign))) {
    // Signed addition. Either left or right is signed.
    if ((leftSign == 0) && (rightSign)) {
      code = BigNumHelper::SubHelper(getLength(), op_data[1], op_data[2], op_data[0]); 
      }
    else
      if ((leftSign) && (rightSign == 0)) {
        code = BigNumHelper::SubHelper(getLength(), op_data[2], op_data[1], op_data[0]);
        }
      else {
        // Both left and right are negative numbers
        BigNumHelper::AddHelper(getLength(), op_data[1], op_data[2], op_data[0]);
        code = 1;
        }
    }
  else {
    // Both are positive numbers
    BigNumHelper::AddHelper(getLength(), op_data[1], op_data[2], op_data[0]);
    code = 0;
    }

  // Reset sign bits
  if (leftSign)
    BIGN_SET_SIGN(op_data[1], getLength());

  if (rightSign)
    BIGN_SET_SIGN(op_data[2], getLength());

  if (code) {
    BIGN_SET_SIGN(op_data[0], getLength());
  } else {
    BIGN_CLR_SIGN(op_data[0], getLength());
  }

  return 0;
};
コード例 #7
0
short BigNum::sub(Attributes * left,
		  Attributes * right,
		  char * op_data[])
{
  // Extract signs.
  char leftSign = BIGN_GET_SIGN(op_data[1], getLength());
  char rightSign = BIGN_GET_SIGN(op_data[2], getLength());

  // Clear sign bits
  BIGN_CLR_SIGN(op_data[1], getLength());
  BIGN_CLR_SIGN(op_data[2], getLength());
 
  Int32 code;

  if ((!isUnsigned()) && ((leftSign) || (rightSign))) {
    if (leftSign == 0) { // left - (-right) => left + right
      BigNumHelper::AddHelper(getLength(), op_data[1], op_data[2], op_data[0]);
      code = 0;
      }
    else
      if (rightSign == 0) { // -left - right => -(left + right)
        BigNumHelper::AddHelper(getLength(), op_data[1], op_data[2], op_data[0]);
        code = 1;
        }
      else
        { // -left - (-right) => right - left
        code = BigNumHelper::SubHelper(getLength(), op_data[2], op_data[1], op_data[0]);
        }
    }
  else {
    code = BigNumHelper::SubHelper(getLength(), op_data[1], op_data[2], op_data[0]);
    }

  // Reset sign bits
  if (leftSign)
    BIGN_SET_SIGN(op_data[1], getLength());

  if (rightSign)
    BIGN_SET_SIGN(op_data[2], getLength());

  if (code) {
    BIGN_SET_SIGN(op_data[0], getLength());
  } else {
    BIGN_CLR_SIGN(op_data[0], getLength());
  }
  
  return 0;
}
コード例 #8
0
//------------------------------------------------------------------------------
// Add or update an entry for a new extent that we are adding.  In this case
// we have completed a Read buffer, and thus have min/max values, but we may
// not have allocated the extent from the ExtentMap yet (till the 1st output
// buffer is flushed), so we will not have an LBID for the 1st buffer for this
// extent.
//------------------------------------------------------------------------------
void ColExtInf::addOrUpdateEntry( RID     lastInputRow,
                                  int64_t minVal,
                                  int64_t maxVal,
                                  ColDataType colDataType )
{
    boost::mutex::scoped_lock lock(fMapMutex);

    RowExtMap::iterator iter = fMap.find( lastInputRow );
    if (iter == fMap.end()) // Add entry
    {
        ColExtInfEntry entry( minVal, maxVal );
        fMap[ lastInputRow ] = entry;

        fPendingExtentRows.insert( lastInputRow );
    }
    else                    // Update entry
    {
        // If all rows had null value for this column, then minVal will be
        // MAX_INT and maxVal will be MIN_INT (see getCPInfoForBRM()).

        if (iter->second.fMinVal == LLONG_MIN) // init the range
        {
            iter->second.fMinVal = minVal;
            iter->second.fMaxVal = maxVal;
        }
        else                // Update the range
        {
            if (isUnsigned(colDataType))
            {
                if (static_cast<uint64_t>(minVal) 
                    < static_cast<uint64_t>(iter->second.fMinVal))
                    iter->second.fMinVal = minVal;
                if (static_cast<uint64_t>(maxVal)
                    > static_cast<uint64_t>(iter->second.fMaxVal))
                    iter->second.fMaxVal = maxVal;
            }
            else
            {
                if (minVal < iter->second.fMinVal)
                    iter->second.fMinVal = minVal;
                if (maxVal > iter->second.fMaxVal)
                    iter->second.fMaxVal = maxVal;
            }
        }
    }
}
コード例 #9
0
ファイル: syminfo.cpp プロジェクト: gunmetal313/relipmoC
void SymInfo::declare( const string &name, ostream &out ) const
{
 
	if ( isTemp == true )
		return;

	assert ( Type( ) != FUNC || !_isReg );

	if ( isStatic( ) )
		out << "static ";

	if ( isConst( ) )
		out << " const ";

	if ( isUnsigned( ) )
		out << " unsigned ";

	//output the type
	if ( Type( ) == NOTYPE ) {
		if ( getSize( ) == 4 )
			out << e2str( LONG ) << ' ';
		else if ( getSize( ) == 2 )
			out << e2str( SINT ) << ' ';
		else if ( getSize( ) == 1 )
			out << e2str( CHAR ) << ' ';
		else
			out << e2str( LONG ) << ' ';
	}
	else
		out << e2str( Type( ) ) << ' ';

	out << name;
	if ( isArray( ) )
		out << "[ " << getSize( ) / sizeOfType( getType( ) ) << " ]";

        if ( initValue.size( ) ) {
		out << "= ";
		if ( Type( ) == FLOAT )
			out << convert2Float( atoi( initValue ) );
		else if ( Type( ) == CHAR )
			cout << getChar( atoi( initValue ) );
		else
                	out << initValue;
	}
        out << ';';
}
コード例 #10
0
ファイル: func_ceil.cpp プロジェクト: EPICPaaS/infinidb
string Func_ceil::getStrVal(Row& row,
							FunctionParm& parm,
							bool& isNull,
							CalpontSystemCatalog::ColType& op_ct)
{
	char tmp[512] = {'\0'};
	if (op_ct.colDataType == CalpontSystemCatalog::DOUBLE ||
        op_ct.colDataType == CalpontSystemCatalog::UDOUBLE ||
		op_ct.colDataType == CalpontSystemCatalog::FLOAT ||
        op_ct.colDataType == CalpontSystemCatalog::UFLOAT ||
		op_ct.colDataType == CalpontSystemCatalog::VARCHAR ||
		op_ct.colDataType == CalpontSystemCatalog::CHAR)
	{
		snprintf(tmp, 511, "%f", getDoubleVal(row, parm, isNull, op_ct));

		// remove the decimals in the oss string.
		char *d = tmp;
		while ((*d != '.') && (*d != '\0'))
			d++;
		*d = '\0';
	}
    else if (isUnsigned(op_ct.colDataType))
    {
#ifndef __LP64__
        snprintf(tmp, 511, "%llu", getUintVal(row, parm, isNull, op_ct));
#else
        snprintf(tmp, 511, "%lu", getUintVal(row, parm, isNull, op_ct));
#endif
    }
	else
	{
#ifndef __LP64__
        snprintf(tmp, 511, "%lld", getIntVal(row, parm, isNull, op_ct));
#else
        snprintf(tmp, 511, "%ld", getIntVal(row, parm, isNull, op_ct));
#endif
	}

	return string(tmp);
}
//FIXME: VARBINARY???
void PredicateOperator::setOpType(Type& l, Type& r)
{
    if ( l.colDataType == execplan::CalpontSystemCatalog::DATETIME ||
            l.colDataType == execplan::CalpontSystemCatalog::TIME ||
            l.colDataType == execplan::CalpontSystemCatalog::DATE )
    {
        switch (r.colDataType)
        {
            case execplan::CalpontSystemCatalog::CHAR:
            case execplan::CalpontSystemCatalog::VARCHAR:
                fOperationType = l;
                break;

            case execplan::CalpontSystemCatalog::DATETIME:
                fOperationType.colDataType = execplan::CalpontSystemCatalog::DATETIME;
                fOperationType.colWidth = 8;
                break;

            case execplan::CalpontSystemCatalog::TIME:
                fOperationType.colDataType = execplan::CalpontSystemCatalog::TIME;
                fOperationType.colWidth = 8;
                break;

            case execplan::CalpontSystemCatalog::DATE:
                fOperationType = l;
                break;

            default:
                fOperationType.colDataType = execplan::CalpontSystemCatalog::DOUBLE;
                fOperationType.colWidth = 8;
                break;
        }
    }
    else if ( r.colDataType == execplan::CalpontSystemCatalog::DATETIME ||
              r.colDataType == execplan::CalpontSystemCatalog::TIME ||
              r.colDataType == execplan::CalpontSystemCatalog::DATE )
    {
        switch (l.colDataType)
        {
            case execplan::CalpontSystemCatalog::CHAR:
            case execplan::CalpontSystemCatalog::VARCHAR:
                fOperationType.colDataType = execplan::CalpontSystemCatalog::VARCHAR;
                fOperationType.colWidth = 255;
                break;

            case execplan::CalpontSystemCatalog::DATETIME:
                fOperationType.colDataType = execplan::CalpontSystemCatalog::DATETIME;
                fOperationType.colWidth = 8;
                break;

            case execplan::CalpontSystemCatalog::TIME:
                fOperationType.colDataType = execplan::CalpontSystemCatalog::TIME;
                fOperationType.colWidth = 8;
                break;

            case execplan::CalpontSystemCatalog::DATE:
                fOperationType = r;
                break;

            default:
                fOperationType.colDataType = execplan::CalpontSystemCatalog::DOUBLE;
                fOperationType.colWidth = 8;
                break;
        }
    }
    else if (l.colDataType == execplan::CalpontSystemCatalog::DECIMAL ||
             l.colDataType == execplan::CalpontSystemCatalog::UDECIMAL)
    {
        switch (r.colDataType)
        {
            case execplan::CalpontSystemCatalog::DECIMAL:
            case execplan::CalpontSystemCatalog::UDECIMAL:
            {
                // should following the result type that MySQL gives
                fOperationType = l;
                fOperationType.scale = (l.scale > r.scale ? l.scale : r.scale);
                break;
            }

            case execplan::CalpontSystemCatalog::INT:
            case execplan::CalpontSystemCatalog::MEDINT:
            case execplan::CalpontSystemCatalog::TINYINT:
            case execplan::CalpontSystemCatalog::BIGINT:
            case execplan::CalpontSystemCatalog::UINT:
            case execplan::CalpontSystemCatalog::UMEDINT:
            case execplan::CalpontSystemCatalog::UTINYINT:
            case execplan::CalpontSystemCatalog::UBIGINT:
                fOperationType.colDataType = execplan::CalpontSystemCatalog::DECIMAL;
                fOperationType.scale = l.scale;
                fOperationType.colWidth = 8;
                break;

            default:
                fOperationType.colDataType = execplan::CalpontSystemCatalog::DOUBLE;
                fOperationType.colWidth = 8;
        }
    }
    else if (r.colDataType == execplan::CalpontSystemCatalog::DECIMAL ||
             r.colDataType == execplan::CalpontSystemCatalog::UDECIMAL)
    {
        switch (l.colDataType)
        {
            case execplan::CalpontSystemCatalog::DECIMAL:
            case execplan::CalpontSystemCatalog::UDECIMAL:
            {
                // should following the result type that MySQL gives based on the following logic?
                // @NOTE is this trustable?
                fOperationType = fResultType;
                break;
            }

            case execplan::CalpontSystemCatalog::INT:
            case execplan::CalpontSystemCatalog::MEDINT:
            case execplan::CalpontSystemCatalog::TINYINT:
            case execplan::CalpontSystemCatalog::BIGINT:
            case execplan::CalpontSystemCatalog::UINT:
            case execplan::CalpontSystemCatalog::UMEDINT:
            case execplan::CalpontSystemCatalog::UTINYINT:
            case execplan::CalpontSystemCatalog::UBIGINT:
                fOperationType.colDataType = execplan::CalpontSystemCatalog::DECIMAL;
                fOperationType.scale = r.scale;
                fOperationType.colWidth = 8;
                break;

            default:
                fOperationType.colDataType = execplan::CalpontSystemCatalog::DOUBLE;
                fOperationType.colWidth = 8;
        }
    }
    // If both sides are unsigned, use UBIGINT as result type, otherwise
    // "promote" to BIGINT.
    else if (isUnsigned(l.colDataType) && isUnsigned(r.colDataType))
    {
        fOperationType.colDataType = execplan::CalpontSystemCatalog::UBIGINT;
        fOperationType.colWidth = 8;
    }
    else if ((isSignedInteger(l.colDataType) && isUnsigned(r.colDataType)) ||
             (isUnsigned(l.colDataType) && isSignedInteger(r.colDataType)) ||
             (isSignedInteger(l.colDataType) && isSignedInteger(r.colDataType)))
    {
        fOperationType.colDataType = execplan::CalpontSystemCatalog::BIGINT;
        fOperationType.colWidth = 8;
    }
    else if ((l.colDataType == execplan::CalpontSystemCatalog::CHAR ||
              l.colDataType == execplan::CalpontSystemCatalog::VARCHAR ||
              l.colDataType == execplan::CalpontSystemCatalog::TEXT) &&
             (r.colDataType == execplan::CalpontSystemCatalog::CHAR ||
              r.colDataType == execplan::CalpontSystemCatalog::VARCHAR ||
              r.colDataType == execplan::CalpontSystemCatalog::TEXT))
    {
        if ( ( (l.colDataType == execplan::CalpontSystemCatalog::CHAR && l.colWidth <= 8) ||
                (l.colDataType == execplan::CalpontSystemCatalog::VARCHAR && l.colWidth < 8) ) &&
                ( (r.colDataType == execplan::CalpontSystemCatalog::CHAR && r.colWidth <= 8) ||
                  (r.colDataType == execplan::CalpontSystemCatalog::VARCHAR && r.colWidth < 8) ) )
        {
            if ( futf8 )
            {
                fOperationType.colDataType = execplan::CalpontSystemCatalog::VARCHAR;
                fOperationType.colWidth = 255;
            }
            else
            {
                fOperationType.colDataType = execplan::CalpontSystemCatalog::BIGINT;
                fOperationType.scale = 0;
                fOperationType.colWidth = 8;

                // @bug3532, char[] as network order int for fast comparison.
                l.colDataType = execplan::CalpontSystemCatalog::STRINT;
                r.colDataType = execplan::CalpontSystemCatalog::STRINT;
            }
        }
        else
        {
            fOperationType.colDataType = execplan::CalpontSystemCatalog::VARCHAR;
            fOperationType.colWidth = 255;
        }
    }
    else
    {
        fOperationType.colDataType = execplan::CalpontSystemCatalog::DOUBLE;
        fOperationType.colWidth = 8;
    }
}
コード例 #12
0
ファイル: AsmJsTypes.cpp プロジェクト: Cellule/ChakraCore
 bool AsmJsType::isInt() const
 {
     return isSigned() || isUnsigned() || which_ == Int;
 }
コード例 #13
0
const int64_t& CBORValue::getUnsigned() const
{
    ASSERT(isUnsigned());
    ASSERT(m_integerValue >= 0);
    return m_integerValue;
}
コード例 #14
0
//------------------------------------------------------------------------------
// Get updated Casual Partition (CP) information for BRM for this column at EOJ.
//------------------------------------------------------------------------------
void ColExtInf::getCPInfoForBRM( JobColumn column, BRMReporter& brmReporter )
{
    bool bIsChar = ((column.weType  == WriteEngine::WR_CHAR) &&
         (column.colType != COL_TYPE_DICT));

    boost::mutex::scoped_lock lock(fMapMutex);

    RowExtMap::const_iterator iter = fMap.begin();
    while (iter != fMap.end())
    {
        // If/when we support NULL values, we could have an extent with initial
        // value of min=MAX_BIGINT and max=MIN_BIGINT (see
        // BulkLoadBuffer::parseCol()).  If this occurs, (min>max), we still
        // send min/max to BRM so that the isValid flag can be set to CP_VALID
        // if applicable (indicating an extent with no non-NULL values).
        int64_t minVal = iter->second.fMinVal;
        int64_t maxVal = iter->second.fMaxVal;
        if ( bIsChar )
        {
            // If we have added 1 or more rows, then we should have a valid
            // range in our RowExtMap object, in which case...
            // We swap/restore byte order before sending min/max string to BRM;
            // else we leave fMinVal & fMaxVal set to LLONG_MIN and send as-is,
            // to let BRM know we added no rows.
            if ((iter->second.fMinVal != iter->second.fMaxVal) ||
                (iter->second.fMinVal != LLONG_MIN))
            {
                minVal = static_cast<int64_t>( uint64ToStr(
                    static_cast<uint64_t>(iter->second.fMinVal) ) );
                maxVal = static_cast<int64_t>( uint64ToStr(
                    static_cast<uint64_t>(iter->second.fMaxVal) ) );
            }
        }

        // Log for now; may control with debug flag later
        //if (fLog->isDebug( DEBUG_1 ))
        {
            std::ostringstream oss;
            oss << "Saving CP  update for OID-" << fColOid <<
                   "; lbid-"   << iter->second.fLbid <<
                   "; type-"   << bIsChar            <<
                   "; isNew-"  << iter->second.fNewExtent;
            if (bIsChar)
            {
                char minValStr[sizeof(int64_t) + 1];
                char maxValStr[sizeof(int64_t) + 1];
                memcpy(minValStr, &minVal, sizeof(int64_t));
                memcpy(maxValStr, &maxVal, sizeof(int64_t));
                minValStr[sizeof(int64_t)] = '\0';
                maxValStr[sizeof(int64_t)] = '\0';
                oss << "; minVal: " << minVal << "; (" << minValStr << ")"
                    << "; maxVal: " << maxVal << "; (" << maxValStr << ")";
            }
            else if (isUnsigned(column.dataType))
            {
                oss << "; min: "    << static_cast<uint64_t>(minVal)  <<
                       "; max: "    << static_cast<uint64_t>(maxVal);
            }
            else
            {
                oss << "; min: "    << minVal <<
                       "; max: "    << maxVal;
            }

            fLog->logMsg( oss.str(), MSGLVL_INFO2 );
        }

        BRM::CPInfoMerge cpInfoMerge;
        cpInfoMerge.startLbid = iter->second.fLbid;
        cpInfoMerge.max       = maxVal;
        cpInfoMerge.min       = minVal;
        cpInfoMerge.seqNum    = -1;     // Not used by mergeExtentsMaxMin
        cpInfoMerge.type      = column.dataType;
        cpInfoMerge.newExtent = iter->second.fNewExtent;
        brmReporter.addToCPInfo( cpInfoMerge );

        ++iter;
    }
    fMap.clear(); // don't need map anymore, so release memory
}
コード例 #15
0
unsigned VariantValue::getUnsigned() const {
  assert(isUnsigned());
  return Value.Unsigned;
}
コード例 #16
0
ファイル: tupleconstantstep.cpp プロジェクト: Kangmo/infinidb
void TupleConstantStep::constructContanstRow(const JobInfo& jobInfo)
{
	// construct a row with only the constant values
	fConstRowData.reset(new uint8_t[fRowConst.getSize()]);
	fRowConst.setData(fConstRowData.get());
	const vector<CalpontSystemCatalog::ColDataType>& types = fRowGroupOut.getColTypes();
	for (vector<uint64_t>::iterator i = fIndexConst.begin(); i != fIndexConst.end(); i++)
	{
		const ConstantColumn* cc =
						dynamic_cast<const ConstantColumn*>(jobInfo.deliveredCols[*i].get());
		const execplan::Result c = cc->result();

		if (cc->type() == ConstantColumn::NULLDATA)
		{
			if (types[*i] == CalpontSystemCatalog::CHAR ||
				types[*i] == CalpontSystemCatalog::VARCHAR)
			{
				fRowConst.setStringField("", *i);
			}
			else if (isUnsigned(types[*i]))
			{
				fRowConst.setUintField(fRowConst.getNullValue(*i), *i);
			}
			else
			{
				fRowConst.setIntField(fRowConst.getSignedNullValue(*i), *i);
			}

			continue;
		}


		switch (types[*i])
		{
			case CalpontSystemCatalog::TINYINT:
			case CalpontSystemCatalog::SMALLINT:
			case CalpontSystemCatalog::MEDINT:
			case CalpontSystemCatalog::INT:
			case CalpontSystemCatalog::BIGINT:
			case CalpontSystemCatalog::DATE:
			case CalpontSystemCatalog::DATETIME:
			{
				fRowConst.setIntField(c.intVal, *i);
				break;
			}

			case CalpontSystemCatalog::DECIMAL:
			case CalpontSystemCatalog::UDECIMAL:
			{
				fRowConst.setIntField(c.decimalVal.value, *i);
				break;
			}

			case CalpontSystemCatalog::FLOAT:
			case CalpontSystemCatalog::UFLOAT:
			{
				fRowConst.setFloatField(c.floatVal, *i);
				break;
			}

			case CalpontSystemCatalog::DOUBLE:
			case CalpontSystemCatalog::UDOUBLE:
			{
				fRowConst.setDoubleField(c.doubleVal, *i);
				break;
			}

			case CalpontSystemCatalog::CHAR:
			case CalpontSystemCatalog::VARCHAR:
			{
				fRowConst.setStringField(c.strVal, *i);
				break;
			}

			case CalpontSystemCatalog::UTINYINT:
			case CalpontSystemCatalog::USMALLINT:
			case CalpontSystemCatalog::UMEDINT:
			case CalpontSystemCatalog::UINT:
			case CalpontSystemCatalog::UBIGINT:
			{
				fRowConst.setUintField(c.uintVal, *i);
				break;
			}

			default:
			{
				throw runtime_error("un-supported constant column type.");
				break;
			}
		} // switch
	} // for constant columns
}
コード例 #17
0
ファイル: umysql.c プロジェクト: LeeXiaolan/ultramysql
int API_resultRowValue(void *result, int column, UMTypeInfo *ti, char *value, size_t cbValue)
{
  PyObject *valobj = NULL;

  PRINTMARK();
  //fprintf (stderr, "%s: Got %p (%08x) %08x\n", __FUNCTION__, value, ti->type, cbValue);

  if (value == NULL)
  {
    valobj = Py_None;
    Py_IncRef(valobj);
  }
  else
  {

    switch (ti->type)
    {
      //PyNone:
    case MFTYPE_NULL:
      valobj = Py_None;
      Py_IncRef(valobj);
      break;

      // Use PyLong for "INT UNSIGNED".
    case MFTYPE_LONG:
      if(isUnsigned(ti->flags)){
        // XXX: No overflow detected.
        valobj = PyLong_FromLongLong(parseINT64 (value, ((char *) value) + cbValue));
        break;
      }
      // "INT" only, let it fall through to PyInt.

      //PyInt
    case MFTYPE_TINY:
    case MFTYPE_SHORT:
    case MFTYPE_INT24:
      {
        valobj = PyInt_FromLong(parseINT32 (value, ((char *) value) + cbValue));
        break;
      }

      //PyLong
    case MFTYPE_LONGLONG:
      {
        if(isUnsigned(ti->flags)){
          valobj = PyLong_FromUnsignedLongLong(parseUINT64 (value, ((char *) value) + cbValue));
        }else{
          valobj = PyLong_FromLongLong(parseINT64 (value, ((char *) value) + cbValue));
        }
        break;
      }

      //PyFloat
    case MFTYPE_FLOAT:
    case MFTYPE_DOUBLE:
      {
        //FIXME: Too f*****g slow
        PyObject *sobj = PyString_FromStringAndSize((char *) value, cbValue);
        valobj = PyFloat_FromString (sobj, NULL);
        Py_DECREF(sobj);
        break;
      }

    case MFTYPE_DATE:
      {
        int year;
        int month;
        int day;

        year = parseINT32 (value, value + 4);

        if (year < 1)
        {
          valobj = Py_None;
          Py_IncRef(valobj);
          break;
        }

        value += 5;
        month = parseINT32 (value, value + 2);
        value += 3;
        day = parseINT32 (value, value + 2);
        value += 3;

        valobj = PyDate_FromDate (year, month, day);
        break;
      }

    case MFTYPE_TIMESTAMP:
    case MFTYPE_DATETIME:
      {
        int year;
        int month;
        int day;
        int hour;
        int minute;
        int second;

        //9999-12-31 23:59:59
        char temp[20];
        memcpy (temp, value, cbValue);
        temp[cbValue] = '\0';

        year = parseINT32 (value, value + 4);
        value += 5;
        month = parseINT32 (value, value + 2);
        value += 3;
        day = parseINT32 (value, value + 2);
        value += 3;
        hour = parseINT32 (value, value + 2);
        value += 3;
        minute = parseINT32 (value, value + 2);
        value += 3;
        second = parseINT32 (value, value + 2);
        value += 3;

        if (year < 1)
        {
          valobj = Py_None;
          Py_IncRef(valobj);
          break;
        }


        valobj = PyDateTime_FromDateAndTime (year, month, day, hour, minute, second, 0);
        break;
      }

      // We ignore these

    case MFTYPE_TIME:
    case MFTYPE_YEAR:
    case MFTYPE_NEWDATE:
      // Fall through for string encoding

      //Blob goes as String
    case MFTYPE_TINY_BLOB:
    case MFTYPE_MEDIUM_BLOB:
    case MFTYPE_LONG_BLOB:
    case MFTYPE_BLOB:
      if (ti->flags & MFFLAG_BINARY_FLAG) {
        valobj = PyString_FromStringAndSize( (const char *) value, cbValue);
      } else {
        valobj = DecodeString (ti, value, cbValue);
      }
      break;

      //PyString family
    case MFTYPE_VAR_STRING:
    case MFTYPE_VARCHAR:
    case MFTYPE_STRING:
      valobj = DecodeString (ti, value, cbValue);
      break;

    case MFTYPE_ENUM:
    case MFTYPE_GEOMETRY:
    case MFTYPE_BIT:
    case MFTYPE_NEWDECIMAL:
    case MFTYPE_SET:
    case MFTYPE_DECIMAL:
      // Fall through for string encoding
      valobj = PyString_FromStringAndSize( (const char *) value, cbValue);
      break;

    }
  }

  if (valobj == NULL)
  {
    if (PyErr_Occurred())
    {
      return FALSE;
    }

    PyErr_Format (umysql_Error, "Unable to convert field of type %d", ti->type);
    return FALSE;
  }

  PyTuple_SET_ITEM(((ResultSet *)result)->currRow, column, valobj);
  PRINTMARK();

  return TRUE;
}
コード例 #18
0
ファイル: JsonSerializer.cpp プロジェクト: Thalhammer/EasyCpp
		Json::Value JsonSerializer::toValue(AnyValue val) const
		{
			auto info = val.type_info();
			if (val.isType<bool>())
			{
				bool v = val.as<bool>();
				return Json::Value(v);
			}
			else if (info.isIntegral())
			{
				if (info.isUnsigned())
				{
					uint64_t v = val.as<uint64_t>();
					return Json::Value((Json::Value::UInt64)v);
				}
				else {
					int64_t v = val.as<int64_t>();
					return Json::Value((Json::Value::Int64)v);
				}
			}
			else if (info.isFloatingPoint())
			{
				double v = val.as<double>();
				return Json::Value(v);
			}
			else if (val.isType<std::vector<AnyValue>>())
			{
				Json::Value res = Json::arrayValue;
				std::vector<AnyValue> v = val.as < std::vector<AnyValue>>();
				for (AnyValue any : v)
					res.append(this->toValue(any));
				return res;
			}
			else if (val.isType<Bundle>())
			{
				Json::Value res = Json::objectValue;
				Bundle b = val.as<Bundle>();
				for (const auto& val : b)
				{
					res[val.first] = this->toValue(val.second);
				}
				return res;
			}
			else if (val.isType<std::nullptr_t>())
			{
				return Json::nullValue;
			}
			else if (val.isSerializable())
			{
				return this->toValue(val.serialize());
			}
			else if (val.isConvertibleTo<std::string>())
			{
				std::string v = val.as<std::string>();
				return Json::Value(v);
			}
			else
			{
				throw std::logic_error("Type is not convertible.");
			}
		}