Hive Java Ip Today

public class IpToLong extends UDF public LongWritable evaluate(Text ipString) if (ipString == null) return null; String ip = ipString.toString(); long result = 0; String[] parts = ip.split("\."); if (parts.length != 4) return null; try for (int i = 0; i < 4; i++) = (Long.parseLong(parts[i]) << (24 - (8 * i)));

To execute this connection, your Java project needs the appropriate Hive JDBC driver and its transitive dependencies. Using a build tool like is highly recommended to manage these: hive java ip

In this example, we're connecting to a Hive instance running on localhost at port 10000 with an empty username and password. String ip = ipString.toString()