저는 MapReduce를 사용하여 텍스트 파일을 시퀀스 파일로 변환합니다. 각 줄의 시작 부분에 숫자가 표시됩니다. 어떻게 그들을 제거하거나 내 산출물에서 오는 것을 막을 수 있습니까?MapReduce를 사용하여 텍스트를 시퀀스로 변환하면 정크 문자가 생성됩니다.
텍스트 :
d001 Marketing
d002 Finance
d003 Human Resources
변환 된 시퀀스 파일 : 시퀀스 파일
0 d001 Marketing
15 d002 Finance
28 d003 Human Resources
에서
0 d001 Marketing
15 d002 Finance\n
28 d003 Human Resources
변환 된 텍스트는 내가 0 15 28 값을 제거해야합니다.
나는 다음과 같은 코드를 사용하고 있습니다 :
public class FormatConverterTextToSequenceDriver extends Configured implements Tool {
@Override
public int run(String[] args) throws Exception {
if (args.length != 2) {
System.out.printf("Two parameters are required for FormatConverterTextToSequenceDriver-<input dir> <output dir>\n");
return -1;
}
Job job = new Job(getConf());
job.setJarByClass(FormatConverterTextToSequenceDriver.class);
job.setJobName("Create Sequence File, from text file");
FileInputFormat.setInputPaths(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
job.setMapperClass(FormatConverterMapper.class);
job.setOutputFormatClass(SequenceFileOutputFormat.class);
job.setNumReduceTasks(0);
boolean success = job.waitForCompletion(true);
return success ? 0 : 1;
}
-----------------------------------------------------------------
public class FormatConverterSequenceToTextDriver extends Configured implements Tool {
@Override
public int run(String[] args) throws Exception {
if (args.length != 2) {
System.out
.printf("Two parameters need to be supplied - <input dir> and <output dir>\n");
return -1;
}
Job job = new Job(getConf());
job.setJarByClass(FormatConverterSequenceToTextDriver.class);
job.setJobName("Convert Sequence File and Output as Text");
FileInputFormat.setInputPaths(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
job.setInputFormatClass(SequenceFileInputFormat.class);
job.setMapperClass(FormatConverterMapper.class);
job.setNumReduceTasks(0);
boolean success = job.waitForCompletion(true);
return success ? 0 : 1;
}
-----------------------------------------------------------------
public class FormatConverterMapper extends
Mapper<LongWritable, Text, LongWritable, Text> {
@Override
public void map(LongWritable key, Text value, Context context)
throws IOException, InterruptedException {
context.write(key, value);
}
}
어떤 도움에 감사드립니다.
이것은 정크가 아니므로'FormatConverterMapper'에 숫자를 쓰고 있습니다 (줄 번호 또는 바이트 오프셋과 같음). 이 클래스의 코드가 없으면 귀하를 도울 수 없습니다. –
요청한 클래스의 코드를 질문에 추가하고 있습니다. –