If I have a constructor that requires a path to a file, how can I “fake” that if it is packaged into a jar?

前端 未结 6 1467
半阙折子戏
半阙折子戏 2020-12-17 05:09

The context of this question is that I am trying to use the maxmind java api in a pig script that I have written... I do not think that knowing about either is necessary to

6条回答
  •  难免孤独
    2020-12-17 05:35

    One recommended way is to use the Distributed Cache rather than trying to bundle it into a jar.

    If you zip GeoIP.dat and copy it on hdfs://host:port/path/GeoIP.dat.zip. Then add these options to the Pig command:

    pig ...
      -Dmapred.cache.archives=hdfs://host:port/path/GeoIP.dat.zip#GeoIP.dat 
      -Dmapred.create.symlink=yes
    ...
    

    And LookupService lookupService = new LookupService("./GeoIP.dat"); should work in your UDF as the file will be present locally to the tasks on each node.

提交回复
热议问题