#ifndef DBMS_CORE_FIELD_H #define DBMS_CORE_FIELD_H #include #include #include #include #include namespace DB { /** Типы данных для представления единичного значения произвольного типа в оперативке. * Внимание! Предпочтительно вместо единичных значений хранить кусочки столбцов. См. Column.h */ typedef boost::make_recursive_variant< Null, UInt64, Int64, Float64, String, std::vector /// Array, Tuple >::type Field; typedef std::vector Array; /// Значение типа "массив" /** Числовое значение конкретного типа Field */ namespace FieldType { enum Enum { Null = 0, UInt64, Int64, Float64, String, Array }; } /** Возвращает true, если вариант - Null */ class FieldVisitorIsNull : public boost::static_visitor { public: template bool operator() (const T & x) const { return false; } bool operator() (const Null & x) const { return true; } }; /** Возвращает числовое значение типа */ class FieldVisitorGetType : public boost::static_visitor { public: FieldType::Enum operator() (const Null & x) const { return FieldType::Null; } FieldType::Enum operator() (const UInt64 & x) const { return FieldType::UInt64; } FieldType::Enum operator() (const Int64 & x) const { return FieldType::Int64; } FieldType::Enum operator() (const Float64 & x) const { return FieldType::Float64; } FieldType::Enum operator() (const String & x) const { return FieldType::String; } FieldType::Enum operator() (const Array & x) const { return FieldType::Array; } }; template struct NearestFieldType; template <> struct NearestFieldType { typedef UInt64 Type; }; template <> struct NearestFieldType { typedef UInt64 Type; }; template <> struct NearestFieldType { typedef UInt64 Type; }; template <> struct NearestFieldType { typedef UInt64 Type; }; template <> struct NearestFieldType { typedef Int64 Type; }; template <> struct NearestFieldType { typedef Int64 Type; }; template <> struct NearestFieldType { typedef Int64 Type; }; template <> struct NearestFieldType { typedef Int64 Type; }; template <> struct NearestFieldType { typedef Float64 Type; }; template <> struct NearestFieldType { typedef Float64 Type; }; } #endif