如何通过扩展文件输入格式的新 API 来获取拆分主机详细信息



嗨,我正在尝试通过扩展org.apache.pig.LoadFunc为 pig 创建自定义加载程序,它需要实现

public abstract org.apache.hadoop.mapreduce.InputFormat getInputFormat() throws java.io.IOException;

现在上面的格式org.apache.hadoop.mapreduce.InputFormat是新的 API,所以我必须通过扩展创建自定义文件格式org.apache.hadoop.mapreduce.InputFormat我已经使用新的 API 创建自定义文件格式,但我需要使用以下代码找出拆分主机的详细信息

String[] splitHosts = getSplitHosts(blkLocations, 0, length, clusterMap);

getSplitHosts() 在较旧的 API org.apache.hadoop.mapred.FileInputFormat 中可用,但在 org.apache.hadoop.mapreduce.lib.input.FileInputFormat 中不可用

我的问题是我如何使用新的 API 找出 getSplitHosts(org.apache.hadoop.mapreduce.lib.input.FileInputFormat

请提前指导我是Hadoop的新手。

Hadoop 2具有向后兼容性和旧API仍然可以使用,并且在新版本中也可用。不会有问题。
因此,您可以在此处使用Hadoop 2.6版本api中给出的该类

希望对您有所帮助!

最新更新