from functools import reduce
from odps.udf import annotate

@annotate("string->bigint")
class IPtoInt(object):
    def evaluate(self, ip):
        try:
            return reduce(lambda x, y: (x << 8) + y, map(int, ip.split('.')))
        except:
            return 0