Hadoop 在JobContext中找不到作业信息

Hadoop 在JobContext中找不到作业信息,hadoop,hive,hcatalog,Hadoop,Hive,Hcatalog,我正在远程计算机上运行一个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);

我正在远程计算机上运行一个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对象时,在作业配置对象中搜索key:HCAT_key_JOB_INFO的值时失败

如何设置此值?任何提示都会有帮助


谢谢。

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

我遇到了相同的问题,您应该使用:

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

因为,当您使用
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());
}
/**
*从另一个克隆的具有相同设置的新配置。
* 
*@param other从中克隆设置的配置。
*/
@抑制警告(“未选中”)
公共配置(其他配置){
this.resources=(ArrayList)other.resources.clone();
已同步(其他){
if(other.properties!=null){
this.properties=(properties)other.properties.clone();
}
if(other.overlay!=null){
this.overlay=(Properties)other.overlay.clone();
}
this.updateingResource=新的ConcurrentHashMap(
其他(来源);;
this.finalParameters=Collections.newSetFromMap(
新的ConcurrentHashMap());
this.finalParameters.addAll(其他.finalParameters);
}
已同步(Configuration.class){
REGISTRY.put(this,null);
}
this.classLoader=other.classLoader;
this.loadDefaults=other.loadDefaults;
setQuietMode(other.getQuietMode());
}
 /** 
 * 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());
}