gpt4 book ai didi

hadoop - hadoop输入数据问题

转载 作者:行者123 更新时间:2023-12-02 21:40:21 25 4
gpt4 key购买 nike

我在使用 map 功能时遇到了麻烦:
原始数据存储在tsv文件中:
我只想保存最后两列:
第一个是原始节点(383),第二个是目标节点(4575),第三个是权重(1)

383 4575 1

383 4764 1

383 5458 1

383 5491 1

         public void map(LongWritable key, Text value,OutputCollector output, Reporter reporter) throws IOException {
String line = value.toString();
String[] tokens = line.split("t");

int weight = Integer.parseInt(tokens[2]);
int target = Integer.parseInt(tokens[0]);

}

这是我的代码:
public void map(LongWritable key, Text value, Context context) throws IOException  InterruptedException
{
String line = value.toString();
//split the tsv file
String[] tokens = line.split("/t");
//save the weight and target
private Text target = Integer.parsetxt(tokens[0]);
int weight = Integer.parseInt(tokens[2]);
context.write(new Text(target), new Intwritable(weight) );
}
}


public class Reduce extends Reducer<Text, IntWritable, Text, IntWritable>
{
@Override
public void reduce(Text key, Iterable<IntWritable> values,Context context)
throws IOException, InterruptedException
{
//initialize the count variable
int weightsum = 0;
for (IntWritable value : values) {
weightsum += value.get();
}
context.write(key, new IntWritable(weightsum));
}

}

最佳答案

String [] token = line.split(“t”);

应该

String [] token = line.split(“\ t”);

关于hadoop - hadoop输入数据问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29203196/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com