1
클러스터에서 프로그램을 실행하는 중에 문제가 발생하여 함수 맵에서 hdfs 파일을 읽고이를 줄이기로 결정했습니다. 줄 단위로 hdfs 파일을 읽고 ArrayList의 행을 읽는 방법? 데모에 대한Java hdfs에서 파일 읽기
클러스터에서 프로그램을 실행하는 중에 문제가 발생하여 함수 맵에서 hdfs 파일을 읽고이를 줄이기로 결정했습니다. 줄 단위로 hdfs 파일을 읽고 ArrayList의 행을 읽는 방법? 데모에 대한Java hdfs에서 파일 읽기
그냥 코드 :
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();
기본 InputSplit가 FileInputSplit이며, 전체 라인을 나타냅니다 TextInputFormat 사용. 당신이 가진 문제는 정확히 무엇입니까? – rretzbach