public abstract class ExecutionContext extends Object
包括UDF所在的StageID,WorkerID等信息。
| 构造器和说明 |
|---|
ExecutionContext() |
| 限定符和类型 | 方法和说明 |
|---|---|
abstract void |
claimAlive()
在
UDF运行期调用此方法防止worker因超时被强制终止。 |
Counter |
getCounter(Enum<?> name)
|
Counter |
getCounter(String group,
String name)
|
abstract FileSystem |
getInputVolumeFileSystem() |
abstract FileSystem |
getInputVolumeFileSystem(String label) |
abstract VolumeInfo |
getInputVolumeInfo() |
abstract VolumeInfo |
getInputVolumeInfo(String label) |
abstract FileSystem |
getOutputVolumeFileSystem() |
abstract FileSystem |
getOutputVolumeFileSystem(String label) |
abstract VolumeInfo |
getOutputVolumeInfo() |
abstract VolumeInfo |
getOutputVolumeInfo(String label) |
String |
getStageID()
获取运行时StageID
|
String |
getTableInfo()
获取运行时处理的数据块所属的表或分区信息。
|
int |
getWorkerID()
获取运行时WorkerID
|
abstract byte[] |
readResourceFile(String resourceName)
读取文件类型资源,一次全部读取到内存,返回 byte[].
|
abstract BufferedInputStream |
readResourceFileAsStream(String resourceName)
读取文件类型资源,返回一个带缓存的输入流。
|
abstract Iterable<Object[]> |
readResourceTable(String resourceName)
读取表类型资源,返回Iterable
|
public String getStageID()
public int getWorkerID()
public String getTableInfo()
非分区表返回:"项目名.表名"。分区表返回:"项目名.表名/分区名=分区值"。如果有多级分区,按照分区结构返回相应的目录结构。
当UDF运行在非Map端时,调用此方法会抛出
- InvalidInvocationException 异常。public abstract void claimAlive()
UDF运行期调用此方法防止worker因超时被强制终止。
UDF在运行期每一次调用(UDF#evaluate()、UDTF.process(Object[])等方法)
最多能消耗的时间有一定限制,当超出这个限制时,worker会被强制终止。
当UDF涉及计算密集型的任务时,可能一次调用需要消耗更多时间,调用此方法可以重置时间限制,防止被提前终止。
public Counter getCounter(Enum<?> name)
name - Counter标识Counter对象IllegalArgumentException - - name 不能为nullgetCounter(String, String)public Counter getCounter(String group, String name)
group - Group标识name - Counter标识Counter对象IllegalArgumentException - Group名和Counter名中不能 当所定义Counter数量超过100个时也会抛出异常
public abstract BufferedInputStream readResourceFileAsStream(String resourceName) throws IOException
readResourceFileAsStream(String)
该方法支持边读边处理(常见的场景是读取一行处理一行),适合读取比较大的文件资源,
防止Java内存溢出,如果文件资源比较小,也可以直接使用。
readResourceFile(String) 方法会把内容一次性读取到内存。
resourceName - 资源名称IOException - 资源未声明、资源类型不匹配以及其他读取错误抛异常readResourceFile(String)public abstract byte[] readResourceFile(String resourceName) throws IOException
如果资源文件比较大,应该使用readResourceFileAsStream(String)
获得一个带缓存的输入流,支持边读边处理,防止Java内存溢出。
resourceName - 资源名称IOException - 资源未声明、资源类型不匹配以及其他读取错误抛异常readResourceFileAsStream(String)public abstract Iterable<Object[]> readResourceTable(String resourceName) throws IOException
读取表类型资源,返回Iterable
resourceName - 资源名称IOException - 资源未声明、资源类型不匹配以及其他读取错误抛异常public abstract VolumeInfo getInputVolumeInfo() throws IOException
IOExceptionpublic abstract VolumeInfo getInputVolumeInfo(String label) throws IOException
IOExceptionpublic abstract VolumeInfo getOutputVolumeInfo() throws IOException
IOExceptionpublic abstract VolumeInfo getOutputVolumeInfo(String label) throws IOException
IOExceptionpublic abstract FileSystem getInputVolumeFileSystem() throws IOException
IOExceptionpublic abstract FileSystem getInputVolumeFileSystem(String label) throws IOException
IOExceptionpublic abstract FileSystem getOutputVolumeFileSystem() throws IOException
IOExceptionpublic abstract FileSystem getOutputVolumeFileSystem(String label) throws IOException
IOExceptionCopyright © 2015 Alibaba Cloud Computing. All rights reserved.