private String[] getContent(Configuration conf, Path path) throws Exception {
ClassLoader prevClassLoader = ClassLoaderStack.addJarFile(
new Path(new Path(new SqoopOptions().getJarOutputDir()), getTableName() + ".jar").toString(),
getTableName());
FileSystem fs = FileSystem.getLocal(conf);
FileStatus[] stats = fs.listStatus(path);
Path[] paths = new Path[stats.length];
for (int i = 0; i < stats.length; i++) {
paths[i] = stats[i].getPath();
}
// Read all the files adding the value lines to the list.
List<String> strings = new ArrayList<String>();
for (Path filePath : paths) {
if (filePath.getName().startsWith("_") || filePath.getName().startsWith(".")) {
continue;
}
// Need to use new configuration object so that it has the proper classloaders.
SequenceFile.Reader reader = new SequenceFile.Reader(fs, filePath, new Configuration());
WritableComparable key = (WritableComparable)
reader.getKeyClass().newInstance();
Writable value = (Writable) reader.getValueClass().newInstance();
while (reader.next(key, value)) {
strings.add(value.toString());
}
}
ClassLoaderStack.setCurrentClassLoader(prevClassLoader);
return strings.toArray(new String[0]);
}
TestImportJob.java 文件源码
java
阅读 30
收藏 0
点赞 0
评论 0
项目:aliyun-maxcompute-data-collectors
作者:
评论列表
文章目录