public abstract class UTContext extends Object
MapUTContext 和 ReduceUTContext 的基类,定义一些共同的方法。
| Constructor and Description |
|---|
UTContext() |
| Modifier and Type | Method and Description |
|---|---|
int |
getTaskId()
返回设置的TaskId,不设默认为 0.
|
boolean |
isCleanUtDir() |
void |
setArchiveResource(String resourceName,
File path)
定义压缩档案资源.
|
void |
setCleanUtDir(boolean isClean) |
void |
setFileResource(String resourceName,
byte[] content)
给定文件内容,设置文件类型资源.
|
void |
setFileResource(String resourceName,
File file)
给定本地资源文件,设置文件类型资源.
|
void |
setFileResource(String resourceName,
String content)
给定文件内容,设置文件类型资源.
|
void |
setOutputSchema(String schema,
com.aliyun.odps.conf.Configuration conf)
设置默认输出的 schema.
|
void |
setOutputSchema(String label,
String schema,
com.aliyun.odps.conf.Configuration conf)
给定输出的标签,设置 schema.
|
void |
setTableResource(String resourceName,
File dir)
给定本地表目录,设置表类型资源.
|
void |
setTableResource(String resourceName,
TableInfo info,
String schema,
List<Record> records)
给定记录列表和表信息,设置表类型资源.
|
void |
setTaskId(int taskId)
设置 TaskId,不设默认为 0.
|
public int getTaskId()
public void setTaskId(int taskId)
运行时可以从 TaskAttemptID#getTaskId() 取得。
taskId - public void setFileResource(String resourceName, File file) throws IOException
resourceName - 资源名称file - 本地资源文件IOExceptionpublic void setFileResource(String resourceName, String content) throws IOException
resourceName - 资源名称content - 文件内容IOExceptionpublic void setFileResource(String resourceName, byte[] content) throws IOException
resourceName - 资源名称content - 文件内容IOExceptionpublic void setArchiveResource(String resourceName, File path) throws IOException
resourceName - 资源名称path - 本地压缩文件或本地压缩文件解压的文件目录IOExceptionpublic void setTableResource(String resourceName, TableInfo info, String schema, List<Record> records) throws IOException
如果在 Mapper 或 Reducer 里用到表类型资源,可以通过本方法预先定义。
给定 schema 的格式为:[
例如:
resourceName - 资源名称info - 表信息schema - 表 schemarecords - 表的记录集合IOExceptionpublic void setTableResource(String resourceName, File dir) throws IOException
一个本地表目录至少包含一个名为"__schema__"的 schema 文件,其他文件都为数据文件,格式为标准的csv格式。
resourceName - 资源名称dir - 本地表目录IOExceptionpublic void setOutputSchema(String schema, com.aliyun.odps.conf.Configuration conf) throws IOException
schema 的格式为:
如果通过
例如:a:string,b:bigint,c:double
TableOutputFormat#addOutput(TableInfo, com.aliyun.odps.conf.Configuration)
设置了默认输出,则需要使用本方法设置默认输出的 schema。
schema - 默认输出的 schemaIOExceptionpublic void setOutputSchema(String label, String schema, com.aliyun.odps.conf.Configuration conf) throws IOException
schema 的格式为:
如果通过
例如:a:string,b:bigint,c:double
TableOutputFormat#addOutput(TableInfo, String, com.aliyun.odps.conf.Configuration)
设置了给定标签的输出,则需要使用本方法设置其 schema。
label - 输出的标签schema - 输出的 schemaIOExceptionpublic boolean isCleanUtDir()
public void setCleanUtDir(boolean isClean)
Copyright © 2020 Alibaba Cloud Computing. All rights reserved.