Java 如何从Mapreduce作业查询存储在hdfs中的嵌入式数据库?

Java 如何从Mapreduce作业查询存储在hdfs中的嵌入式数据库?,java,hadoop,geolocation,hdfs,Java,Hadoop,Geolocation,Hdfs,我试图从Hadoop MapReduce mapper查询GeoLite数据库,以解析IP地址所在的国家。我尝试了两种方法: 1.使用文件仅在本地文件系统中有效,我收到一个文件未找到异常 File database = new File("hdfs://localhost:9000/input/GeoLite2-City.mmdb"); // <<< HERE DatabaseReader reader = new DatabaseReader.Builder(database

我试图从Hadoop MapReduce mapper查询GeoLite数据库,以解析IP地址所在的国家。我尝试了两种方法:

1.使用
文件
仅在本地文件系统中有效,我收到一个文件未找到异常

File database = new File("hdfs://localhost:9000/input/GeoLite2-City.mmdb"); // <<< HERE
DatabaseReader reader = new DatabaseReader.Builder(database).build();
我的问题是:如何在Hadoop中从mapper查询geolite数据库?

我通过分布式缓存方法解决了这个问题,将geolite数据库文件缓存到MapReduce作业中的每个mapper。 我通过分布式缓存方法解决了这个问题,将GeoLite数据库文件缓存到MapReduce作业中的每个映射器中。
错误:Java堆空间
那么为什么不给映射器更多堆空间呢?
错误:Java堆空间
那么为什么不给映射器更多堆空间呢?
Path pt = new Path("hdfs://localhost:9000/input/GeoLite2-City.mmdb");
FileSystem fs = FileSystem.get(new Configuration());

FSDataInputStream stream = fs.open(pt);
DatabaseReader reader = new DatabaseReader.Builder(stream).build();

InetAddress ipAddress = InetAddress.getByName(address.getHostAddress());
CityResponse response = null;
try {
    response = reader.city(ipAddress);
} catch (GeoIp2Exception ex) {
    ex.printStackTrace();
    return;
}
    @Override
      public void setup(Context context)
    
      {
        Configuration conf = context.getConfiguration();
    
        try {
    
          cachefiles = DistributedCache.getLocalCacheFiles(conf);
    
          File database = new File(cachefiles[0].toString()); //
    
          reader = new DatabaseReader.Builder(database).build();
    
        } catch (IOException e) {
          e.printStackTrace();
        }
    
      }
public void map(Object key, Text line, Context context) throws IOException,
      InterruptedException {

                     .....

InetAddress ipAddress = InetAddress.getByName(address.getHostAddress());
      CityResponse response = null;
      try {
        response = reader.city(ipAddress);
      } catch (GeoIp2Exception ex) {
        ex.printStackTrace();
        return;
      }
                     ......