Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在JavaHDFS中读取文件_Java_Linux_Hadoop_Solaris_Hdfs - Fatal编程技术网

在JavaHDFS中读取文件

在JavaHDFS中读取文件,java,linux,hadoop,solaris,hdfs,Java,Linux,Hadoop,Solaris,Hdfs,我在集群上运行该程序时遇到了问题,决定从函数map和reduce中的hdfs文件中读取。如何逐行读取hdfs文件并刻录以读取ArrayList中的行?只需一段代码片段进行演示: Path path = new Path(filePath); FileSystem fs = path.getFileSystem(context.getConfiguration()); // context of mapper or reducer FSDataInputStream fdsis = fs.open

我在集群上运行该程序时遇到了问题,决定从函数map和reduce中的hdfs文件中读取。如何逐行读取hdfs文件并刻录以读取ArrayList中的行?

只需一段代码片段进行演示:

Path path = new Path(filePath);
FileSystem fs = path.getFileSystem(context.getConfiguration()); // context of mapper or reducer
FSDataInputStream fdsis = fs.open(path);
BufferedReader br = new BufferedReader(new InputStreamReader(fdsis));
String line = "";
ArrayList<String> lines = new ArrayList<String>();
while ((line = br.readLine()) != null) {
    lines.add(line);
}
br.close();
Path Path=新路径(filePath);
FileSystem fs=path.getFileSystem(context.getConfiguration());//映射器或还原器的上下文
FSDataInputStream fdsis=fs.open(路径);
BufferedReader br=新的BufferedReader(新的InputStreamReader(fdsis));
字符串行=”;
ArrayList行=新的ArrayList();
而((line=br.readLine())!=null){
行。添加(行);
}
br.close();

只需一段代码片段进行演示:

Path path = new Path(filePath);
FileSystem fs = path.getFileSystem(context.getConfiguration()); // context of mapper or reducer
FSDataInputStream fdsis = fs.open(path);
BufferedReader br = new BufferedReader(new InputStreamReader(fdsis));
String line = "";
ArrayList<String> lines = new ArrayList<String>();
while ((line = br.readLine()) != null) {
    lines.add(line);
}
br.close();
Path Path=新路径(filePath);
FileSystem fs=path.getFileSystem(context.getConfiguration());//映射器或还原器的上下文
FSDataInputStream fdsis=fs.open(路径);
BufferedReader br=新的BufferedReader(新的InputStreamReader(fdsis));
字符串行=”;
ArrayList行=新的ArrayList();
而((line=br.readLine())!=null){
行。添加(行);
}
br.close();

使用TextInputFormat默认的InputSplit是一个FileInputSplit,将代表一整行。您到底遇到了什么问题?使用TextInputFormat,默认的InputSplit是一个FileInputSplit,将代表一整行。你到底有什么问题?