|
@@ -41,7 +41,8 @@ import org.apache.hadoop.util.Progressable;
|
|
|
public class ReduceContext<KEYIN,VALUEIN,KEYOUT,VALUEOUT>
|
|
|
extends TaskInputOutputContext<KEYIN,VALUEIN,KEYOUT,VALUEOUT> {
|
|
|
private RawKeyValueIterator input;
|
|
|
- private Counter inputCounter;
|
|
|
+ private Counter inputKeyCounter;
|
|
|
+ private Counter inputValueCounter;
|
|
|
private RawComparator<KEYIN> comparator;
|
|
|
private KEYIN key; // current key
|
|
|
private VALUEIN value; // current value
|
|
@@ -57,7 +58,8 @@ public class ReduceContext<KEYIN,VALUEIN,KEYOUT,VALUEOUT>
|
|
|
|
|
|
public ReduceContext(Configuration conf, TaskAttemptID taskid,
|
|
|
RawKeyValueIterator input,
|
|
|
- Counter inputCounter,
|
|
|
+ Counter inputKeyCounter,
|
|
|
+ Counter inputValueCounter,
|
|
|
RecordWriter<KEYOUT,VALUEOUT> output,
|
|
|
OutputCommitter committer,
|
|
|
StatusReporter reporter,
|
|
@@ -67,7 +69,8 @@ public class ReduceContext<KEYIN,VALUEIN,KEYOUT,VALUEOUT>
|
|
|
) throws InterruptedException, IOException{
|
|
|
super(conf, taskid, output, committer, reporter);
|
|
|
this.input = input;
|
|
|
- this.inputCounter = inputCounter;
|
|
|
+ this.inputKeyCounter = inputKeyCounter;
|
|
|
+ this.inputValueCounter = inputValueCounter;
|
|
|
this.comparator = comparator;
|
|
|
SerializationFactory serializationFactory = new SerializationFactory(conf);
|
|
|
this.keyDeserializer = serializationFactory.getDeserializer(keyClass);
|
|
@@ -83,6 +86,9 @@ public class ReduceContext<KEYIN,VALUEIN,KEYOUT,VALUEOUT>
|
|
|
nextKeyValue();
|
|
|
}
|
|
|
if (hasMore) {
|
|
|
+ if (inputKeyCounter != null) {
|
|
|
+ inputKeyCounter.increment(1);
|
|
|
+ }
|
|
|
return nextKeyValue();
|
|
|
} else {
|
|
|
return false;
|
|
@@ -109,7 +115,6 @@ public class ReduceContext<KEYIN,VALUEIN,KEYOUT,VALUEOUT>
|
|
|
buffer.reset(next.getData(), next.getPosition(), next.getLength());
|
|
|
value = valueDeserializer.deserialize(value);
|
|
|
hasMore = input.next();
|
|
|
- inputCounter.increment(1);
|
|
|
if (hasMore) {
|
|
|
next = input.getKey();
|
|
|
nextKeyIsSame = comparator.compare(currentRawKey.getBytes(), 0,
|
|
@@ -121,6 +126,7 @@ public class ReduceContext<KEYIN,VALUEIN,KEYOUT,VALUEOUT>
|
|
|
} else {
|
|
|
nextKeyIsSame = false;
|
|
|
}
|
|
|
+ inputValueCounter.increment(1);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -189,4 +195,4 @@ public class ReduceContext<KEYIN,VALUEIN,KEYOUT,VALUEOUT>
|
|
|
Iterable<VALUEIN> getValues() throws IOException, InterruptedException {
|
|
|
return iterable;
|
|
|
}
|
|
|
-}
|
|
|
+}
|