0
我试图将reducer
的输出添加到list
中,然后在读取所有值后访问并打印列表。将Reducer的输出添加到Hadoop中的列表中
下面是我在做什么: -
public class Reducer extends Reducer<Text, BooleanWritable, Text, BooleanWritable> {
public static final Logger LOG = LoggerFactory.getLogger(Reducer.class);
public List<String> keys= new ArrayList<>(1000);
public void reduce(Text key, Iterable<BooleanWritable> values, Context context) throws IOException, InterruptedException {
for (BooleanWritable value : values) {
keys.add(key.toString());
context.write(key, value);
}
print(keys);
}
private void print(String keys) {
for (String key : keys) {
LOG.info(key);
}
}
但是,按预期的方式是行不通的。 我想在减速器的所有值都添加到list