Code Monkey home page Code Monkey logo

ipdb-spark's Introduction

ipdb-spark

新特性

  1. 可以兼容 IPv4 数据库与 IPv6 数据库查询
val ipdb = new City("dbv4.ipdb") 

或 

val ipdb = new City("dbv4.ipdb", "dbv6.ipdb")

ipdb.findInfo("2002:2dc5:9642::2dc5:9642")
ipdb.findInfo("112.64.64.43")

  1. 对 IPv6 6to4 地址转换后查询,解决了 6to4 地址无法查询到地理位置的问题

使用示例

//test.scala
import com.se162xg.City;
import org.apache.spark.SparkFiles;
sc.addFile("dbv4.ipdb");                                         
sc.addFile("dbv6.ipdb");
val db = sc.broadcast(new City(SparkFiles.get("dbv4.ipdb"),SparkFiles.get("dbv6.ipdb")));
spark.udf.register("getRegionName", (ip:String)=>{db.value.findInfo(ip).getRegionName()});
spark.sql("SELECT getRegionName(ip)");
$ spark-shell .. --conf spark.serializer=org.apache.spark.serializer.KryoSerializer --jars ipdbcity-assembly-1.0.1.jar -i test.scala 

编译

  1. 在 build.sbt 中修改为对应的 scala 版本
  2. 执行 sbt assembly

ipdb-spark's People

Contributors

se162xg avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.