625
iPhone_iPad_Mac_手机_平板_苹果apple
分区表输入示例__示例程序_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-阿里云