stats: development [#CONV-2546].

This commit is contained in:
Alexey Milovidov 2011-07-04 18:22:37 +00:00
parent 1ea8120bb0
commit 8eb6ebbbc5
3 changed files with 18 additions and 2 deletions

View File

@ -28,13 +28,13 @@ public:
{
/// ColumnType::value_type - более узкий тип. Например, UInt8, когда тип Field - UInt64
typename ColumnType::value_type x = boost::get<FieldType>(field);
ostr.write(reinterpret_cast<const char *>(&x), sizeof(x));
writeIntBinary(x, ostr);
}
void deserializeBinary(Field & field, ReadBuffer & istr) const
{
typename ColumnType::value_type x;
istr.readStrict(reinterpret_cast<char *>(&x), sizeof(x));
readIntBinary(x, istr);
field = typename NearestFieldType<FieldType>::Type(x);
}

View File

@ -46,6 +46,14 @@ static inline void throwReadAfterEOF()
}
/// Чтение числа в native формате
template <typename T>
inline void readIntBinary(T & x, ReadBuffer & buf)
{
buf.readStrict(reinterpret_cast<char *>(&x), sizeof(x));
}
inline void readChar(char & x, ReadBuffer & buf)
{
if (!buf.eof())

View File

@ -32,6 +32,14 @@ inline void writeChar(char x, WriteBuffer & buf)
}
/// Запись числа в native формате
template <typename T>
inline void writeIntBinary(T & x, WriteBuffer & buf)
{
buf.write(reinterpret_cast<const char *>(&x), sizeof(x));
}
template <typename T>
void writeIntText(T x, WriteBuffer & buf)
{