@@ -18,9 +18,17 @@ template <unsigned Precision> class ColumnDateTime64 : public clickhouse::Column
1818 ColumnDateTime64 () : clickhouse::ColumnDateTime64(Precision) {}
1919};
2020
21- DataType type_from_ipfix (fds_iemgr_element_type type )
21+ DataType type_from_ipfix (const fds_iemgr_elem *elem )
2222{
23- switch (type) {
23+ // Special cases
24+ static constexpr uint32_t PEN_CESNET = 8057 ;
25+ static constexpr uint16_t ID_FLOWUUID = 1300 ;
26+ if (elem->scope ->pen == PEN_CESNET && elem->id == ID_FLOWUUID) {
27+ return DataType::Uuid;
28+ }
29+
30+ // Otherwise
31+ switch (elem->data_type ) {
2432 case FDS_ET_STRING: return DataType::String;
2533 case FDS_ET_SIGNED_8: return DataType::Int8;
2634 case FDS_ET_SIGNED_16: return DataType::Int16;
@@ -36,7 +44,7 @@ DataType type_from_ipfix(fds_iemgr_element_type type)
3644 case FDS_ET_DATE_TIME_MILLISECONDS: return DataType::DatetimeMillisecs;
3745 case FDS_ET_DATE_TIME_MICROSECONDS: return DataType::DatetimeMicrosecs;
3846 case FDS_ET_DATE_TIME_NANOSECONDS: return DataType::DatetimeNanosecs;
39- default : throw Error (" unsupported IPFIX data type {}" , type );
47+ default : throw Error (" unsupported IPFIX data type {}" , elem-> data_type );
4048 }
4149}
4250
@@ -91,9 +99,9 @@ DataType find_common_type(const fds_iemgr_alias &alias)
9199 throw Error (" alias \" {}\" has no sources" , alias.name );
92100 }
93101
94- DataType common_type = type_from_ipfix (alias.sources [0 ]-> data_type );
102+ DataType common_type = type_from_ipfix (alias.sources [0 ]);
95103 for (size_t i = 1 ; i < alias.sources_cnt ; i++) {
96- common_type = unify_type (common_type, type_from_ipfix (alias.sources [i]-> data_type ));
104+ common_type = unify_type (common_type, type_from_ipfix (alias.sources [i]));
97105 }
98106 return common_type;
99107}
@@ -199,6 +207,19 @@ static int64_t get_datetime64(fds_drec_field field)
199207 value = (static_cast <int64_t >(ts.tv_sec ) * 1'000'000'000 + static_cast <int64_t >(ts.tv_nsec )) / Divisor;
200208 return value;
201209}
210+
211+ static std::pair<uint64_t , uint64_t > get_uuid (fds_drec_field field)
212+ {
213+ if (field.size != 16 ) {
214+ throw Error (" invalid uuid field size. expected 16, got {}" , field.size );
215+ }
216+
217+ return {
218+ *reinterpret_cast <uint64_t *>(&field.data [0 ]),
219+ *reinterpret_cast <uint64_t *>(&field.data [8 ])
220+ };
221+ }
222+
202223}
203224
204225template <DataType> struct DataTypeTraits {};
@@ -299,6 +320,12 @@ template<> struct DataTypeTraits<DataType::DatetimeNanosecs> {
299320 static constexpr auto Getter = &getters::get_datetime64<1 >;
300321};
301322
323+ template <> struct DataTypeTraits <DataType::Uuid> {
324+ using ColumnType = clickhouse::ColumnUUID;
325+ static constexpr std::string_view ClickhouseTypeName = " UUID" ;
326+ static constexpr auto Getter = &getters::get_uuid;
327+ };
328+
302329template <typename Func>
303330static void visit (DataType type, Func func)
304331{
@@ -319,6 +346,7 @@ static void visit(DataType type, Func func)
319346 case DataType::IPv4: func (DataTypeTraits<DataType::IPv4>{}); break ;
320347 case DataType::IPv6: func (DataTypeTraits<DataType::IPv6>{}); break ;
321348 case DataType::IP: func (DataTypeTraits<DataType::IP>{}); break ;
349+ case DataType::Uuid: func (DataTypeTraits<DataType::Uuid>{}); break ;
322350 case DataType::Invalid: throw std::runtime_error (" invalid data type" );
323351 }
324352}
0 commit comments