Mam następujący kod i nie rozumiem, dlaczego użyto metody get()
w podświetlonej linii. Jeśli usuniemy tę metodę get()
, wyśle mi błąd.Konwertowanie IntWritatble na int
To, co mogę z niego wyciągnąć to: get()
Metoda zwraca wartość int IntWritable. Popraw mnie, jeśli się mylę.
public void reduce(IntWritable key, Iterator<IntWritable> values, OutputCollector<IntWritable, IntWritable> output, Reporter reporter) throws IOException {
int sum = 0;
while (values.hasNext()) {
sum += values.next().get(); //error when removing the get()
}
}
Dziękuję bardzo za sprawdzenie go !! – Sri