在 JobContext 中找不到作业信息



我在远程计算机上运行一个Java程序,并尝试使用RecordReader对象读取拆分的数据,但得到:

Exception in thread "main" java.io.IOException: job information not found in JobContext. HCatInputFormat.setInput() not called?

我已经调用了以下内容:

 _hcatInputFmt = HCatInputFormat.setInput(_myJob, db,tbl);

然后将 RecordReader 对象创建为:

 _hcatInputFmt.createRecordReader(hSplit, taskContext)

在调试时,在尝试创建 RecordReader 对象时,在作业配置对象中搜索键:HCAT_KEY_JOB_INFO的值时失败。

如何设置此值?任何指针都会有所帮助。

谢谢。

我们必须使用getConfiguration()方法从作业对象获取配置。用于创建作业对象的配置对象不会执行此操作。

我有同样的问题,你舒尔德使用:

    HCatInputFormat.setInput(job, dbName, inputTableName);
    HCatSchema inputschema = HCatBaseInputFormat.getTableSchema(job.getConfiguration());

    HCatInputFormat.setInput(job, dbName, inputTableName);
    HCatSchema inputschema = HCatBaseInputFormat.getTableSchema(getConf());

因为,当你使用Job.getInstance(conf)时,它会复制 conf,你不能使用原来的 conf。这是代码:

 /** 
 * A new configuration with the same settings cloned from another.
 * 
 * @param other the configuration from which to clone settings.
 */
@SuppressWarnings("unchecked")
public Configuration(Configuration other) {
  this.resources = (ArrayList<Resource>) other.resources.clone();
  synchronized(other) {
 if (other.properties != null) {
   this.properties = (Properties)other.properties.clone();
 }
 if (other.overlay!=null) {
   this.overlay = (Properties)other.overlay.clone();
 }
 this.updatingResource = new ConcurrentHashMap<String, String[]>(
     other.updatingResource);
 this.finalParameters = Collections.newSetFromMap(
     new ConcurrentHashMap<String, Boolean>());
 this.finalParameters.addAll(other.finalParameters);
}
 synchronized(Configuration.class) {
  REGISTRY.put(this, null);
}
this.classLoader = other.classLoader;
this.loadDefaults = other.loadDefaults;
setQuietMode(other.getQuietMode());
}

最新更新