コード例 #1
0
void IndexForNativeFormat::read(ReadBuffer & istr, const NameSet & required_columns)
{
	while (!istr.eof())
	{
		blocks.emplace_back();
		IndexOfBlockForNativeFormat & block = blocks.back();

		readVarUInt(block.num_columns, istr);
		readVarUInt(block.num_rows, istr);

		if (block.num_columns < required_columns.size())
			throw Exception("Index contain less than required columns", ErrorCodes::INCORRECT_INDEX);

		for (size_t i = 0; i < block.num_columns; ++i)
		{
			IndexOfOneColumnForNativeFormat column_index;

			readBinary(column_index.name, istr);
			readBinary(column_index.type, istr);
			readBinary(column_index.location.offset_in_compressed_file, istr);
			readBinary(column_index.location.offset_in_decompressed_block, istr);

			if (required_columns.count(column_index.name))
				block.columns.push_back(std::move(column_index));
		}

		if (block.columns.size() < required_columns.size())
			throw Exception("Index contain less than required columns", ErrorCodes::INCORRECT_INDEX);
		if (block.columns.size() > required_columns.size())
			throw Exception("Index contain duplicate columns", ErrorCodes::INCORRECT_INDEX);

		block.num_columns = block.columns.size();
	}
}
コード例 #2
0
void
EnvironmentBase::RangeCheckParams( const ParamList* inParamList, const NameSet& inCheck )
{
  for( NameSetMap::const_iterator i = OwnedParams().begin(); i != OwnedParams().end(); ++i )
  {
    vector<string> inters( inCheck.size() );
    vector<string>::iterator inters_end = set_intersection(
      inCheck.begin(), inCheck.end(),
      i->second.begin(), i->second.end(),
      inters.begin(), Param::NameCmp()
    );
    for( vector<string>::const_iterator j = inters.begin(); j != inters_end; ++j )
    {
      const Param& p = ( *inParamList )[ *j ];
      const string& lowRangeStr = p.LowRange(),
                  & highRangeStr = p.HighRange();
      bool checkLowRange = ( !lowRangeStr.empty() ),
           checkHighRange = ( !highRangeStr.empty() );
      if( checkLowRange )
      {
        double lowRange = ::atof( lowRangeStr.c_str() );
        for( int j = 0; j < p.NumRows(); ++j )
          for( int k = 0; k < p.NumColumns(); ++k )
          {
            double value = ::atof( p.Value( j, k ).ToString().c_str() );
            if( value < lowRange )
              bcierr__ << DescribeValue( p, j, k )
                       << " is "
                       << value << ", exceeds lower range (" << lowRange << ")";
          }
      }
      if( checkHighRange )
      {
        double highRange = ::atof( highRangeStr.c_str() );
        for( int j = 0; j < p.NumRows(); ++j )
          for( int k = 0; k < p.NumColumns(); ++k )
          {
            double value = ::atof( p.Value( j, k ).ToString().c_str() );
            if( value > highRange )
              bcierr__ << DescribeValue( p, j, k )
                       << " is "
                       << value << ", exceeds high range (" << highRange << ")";
          }
      }
      if( checkLowRange || checkHighRange )
        ParamsRangeChecked().insert( p.Name() );
    }
  }
}