Hive数子IP与字符串IP之间的转换

字符串IP:247.164.62.58  对应的   数字IP:4154736186

数子IP=>字符串IP
select concat_ws('.',conv(substr(hex(4154736186),1,2),16,10),conv(substr(hex(4154736186),3,2),16,10),conv(substr(hex(4154736186),5,2),16,10),conv(substr(hex(4154736186),7,2),16,10))


字符串IP=>数字IP
cast(split("247.164.62.58","\\.")[0] as bigint)*256*256*256+cast(split("247.164.62.58","\\.")[1] as bigint)*256*256+cast(split("247.164.62.58","\\.")[2] as bigint)*256+cast(split("247.164.62.58","\\.")[3] as bigint)
上一篇:Xenia and Colorful Gems CodeForces - 1337D[binary search +data structures implementation+ math sorti


下一篇:Python - 装机系列66 pandas读取excel的问题