625
阿裏雲
分區表輸入示例__示例程序_MapReduce_大數據計算服務-阿裏雲
代碼示例1,一段簡單的將Partition作為輸入輸出的例子,僅供參考:
public static void main(String[] args) throws Exception {
JobConf job = new JobConf();
...
LinkedHashMap<String, String> input = new LinkedHashMap<String, String>();
input.put("pt", "123456");
InputUtils.addTable(TableInfo.builder().tableName("input_table").partSpec(input).build(), job);
LinkedHashMap<String, String> output = new LinkedHashMap<String, String>();
output.put("ds", "654321");
OutputUtils.addTable(TableInfo.builder().tableName("output_table").partSpec(output).build(), job);
JobClient.runJob(job);
}
代碼示例2,僅供參考:
package com.aliyun.odps.mapred.open.example;
...
public static void main(String[] args) throws Exception {
if (args.length != 2) {
System.err.println("Usage: WordCount <in_table> <out_table>");
System.exit(2);
}
JobConf job = new JobConf();
job.setMapperClass(TokenizerMapper.class);
job.setCombinerClass(SumCombiner.class);
job.setReducerClass(SumReducer.class);
job.setMapOutputKeySchema(SchemaUtils.fromString("word:string"));
job.setMapOutputValueSchema(SchemaUtils.fromString("count:bigint"));
Account account = new AliyunAccount("my_access_id", "my_access_key");
Odps odps = new Odps(account);
odps.setEndpoint("odps_endpoint_url");
odps.setDefaultProject("my_project");
Table table = odps.tables().get(tblname);
TableInfoBuilder builder = TableInfo.builder().tableName(tblname);
for (Partition p : table.getPartitions()) {
if (applicable(p)) {
LinkedHashMap<String, String> partSpec = new LinkedHashMap<String, String>();
for (String key : p.getPartitionSpec().keys()) {
partSpec.put(key, p.getPartitionSpec().get(key));
}
InputUtils.addTable(builder.partSpec(partSpec).build(), conf);
}
}
OutputUtils.addTable(TableInfo.builder().tableName(args[1]).build(), job);
JobClient.runJob(job);
}
備注:
- 這是一段使用ODPS SDK和MapReduce SDK組合實現MapReduce任務讀取範圍Partitoin的示例。此段代碼不能夠編譯執行, 僅給出了main函數的示例。示例中applicable函數是用戶邏輯,用來決定該Partition是否符合作為該MapReduce作業的輸入。
最後更新:2016-05-06 10:43:08
上一篇:
sort示例__示例程序_MapReduce_大數據計算服務-阿裏雲
下一篇:
pipeline示例__示例程序_MapReduce_大數據計算服務-阿裏雲
Docker鏡像製作__Docker_操作指南_批量計算-阿裏雲
名詞解釋__產品簡介_彈性伸縮-阿裏雲
產品簡介___高性能計算-阿裏雲
獲取主題的訂閱列表__主題使用幫助_控製台使用幫助_消息服務-阿裏雲
iOS SDK手冊__SDK手冊_HTTPDNS-阿裏雲
拖拽播放__視頻相關配置_用戶指南_CDN-阿裏雲
為什麼出現很多 10 和 100 段 IP 訪問 ECS__常見問題_負載均衡-阿裏雲
資源(Resources)__模板語法_資源編排-阿裏雲
搜索集群__集群管理_用戶指南_容器服務-阿裏雲
ALIYUN::RDS::DBInstanceParameterGroup__資源列表_資源編排-阿裏雲
相關內容
常見錯誤說明__附錄_大數據計算服務-阿裏雲
發送短信接口__API使用手冊_短信服務-阿裏雲
接口文檔__Android_安全組件教程_移動安全-阿裏雲
運營商錯誤碼(聯通)__常見問題_短信服務-阿裏雲
設置短信模板__使用手冊_短信服務-阿裏雲
OSS 權限問題及排查__常見錯誤及排除_最佳實踐_對象存儲 OSS-阿裏雲
消息通知__操作指南_批量計算-阿裏雲
設備端快速接入(MQTT)__快速開始_阿裏雲物聯網套件-阿裏雲
查詢API調用流量數據__API管理相關接口_API_API 網關-阿裏雲
使用STS訪問__JavaScript-SDK_SDK 參考_對象存儲 OSS-阿裏雲