@@ -40,39 +40,27 @@ template <>
4040struct IPTrait <IPKind::IPv4>
4141{
4242 using ColumnType = DB::ColumnIPv4;
43- using ElementType = UInt32;
44- static ElementType getElement (const ColumnType * col, size_t n)
45- {
46- return col->getElement (n);
47- }
43+ using ElementType = DB::IPv4;
4844};
4945
5046template <>
5147struct IPTrait <IPKind::IPv6>
5248{
5349 using ColumnType = DB::ColumnIPv6;
5450 using ElementType = DB::UInt128;
55- static ElementType getElement (const ColumnType * col, size_t n)
56- {
57- return col->getElement (n);
58- }
5951};
6052
6153template <>
6254struct IPTrait <IPKind::String>
6355{
6456 using ColumnType = DB::ColumnString;
6557 using ElementType = std::string_view;
66- static ElementType getElement (const ColumnType * col, size_t n)
67- {
68- return col->getDataAt (n).toView ();
69- }
7058};
7159
7260class IPAddressVariant
7361{
7462public:
75- explicit IPAddressVariant (UInt32 addr_): addr(addr_)
63+ explicit IPAddressVariant (DB::IPv4 addr_): addr(addr_)
7664 {
7765 }
7866
@@ -180,7 +168,11 @@ namespace DB
180168 template <IPKind kind>
181169 static inline IPAddressVariant parseIP (const IPTrait<kind>::ColumnType * col_addr, size_t n)
182170 {
183- return IPAddressVariant (IPTrait<kind>::getElement (col_addr, n));
171+ if constexpr (kind == IPKind::IPv4 || kind == IPKind::IPv6)
172+ {
173+ return IPAddressVariant (col_addr->getElement (n));
174+ }
175+ return IPAddressVariant (col_addr->getDataAt (n).toView ());
184176 }
185177
186178 #pragma clang diagnostic ignored "-Wshadow"
0 commit comments