2014-03-03 64 views
1

我在遠程計算機上運行的Java程序,並試圖讀取使用RecordReader對象分割數據,而是讓沒有找到:工作信息JobContext

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。

如何設置此值?任何指針都會有幫助。

謝謝。

回答

0

我們必須使用getConfiguration()方法從作業對象中獲取配置。用於創建作業對象的配置對象不會這樣做。

0

我有同樣的問題,你shuold使用:

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()); 
}