public abstract class ExecutionContext extends Object
包括UDF所在的StageID,WorkerID等信息。
| Constructor and Description |
|---|
ExecutionContext() |
public String getInstanceID()
public String getStageID()
public int getWorkerID()
public String getRunningProject()
public int getRetryCount()
public int getBackupWorkerID()
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)@Deprecated public abstract Iterable<Object[]> readResourceTable(String resourceName) throws IOException
读取表类型资源,返回Iterable
resourceName - 资源名称IOException - 资源未声明、资源类型不匹配以及其他读取错误抛异常public TableRecordReader getResourceTableReader(String resourceName) throws IOException
IOExceptionpublic abstract Iterable<BufferedInputStream> readCacheArchiveAsStream(String resourceName) throws IOException
resourceName - 资源名称IOException - 资源未声明、资源类型不匹配以及其他读取错误抛异常public abstract Iterable<BufferedInputStream> readCacheArchiveAsStream(String resourceName, String relativePath) throws IOException
resourceName - 资源名称relativePath - 读取资源的相对路径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
IOExceptionpublic abstract Properties getConfigurations()
public abstract FileSystem getTempFileSystem() throws IOException
IOExceptionCopyright © 2021 Alibaba Cloud Computing. All rights reserved.