|
@@ -1587,6 +1587,7 @@ public class MapTask extends Task {
|
|
|
final long size = distanceTo(bufstart, bufend, bufvoid) +
|
|
|
partitions * APPROX_HEADER_LENGTH;
|
|
|
FSDataOutputStream out = null;
|
|
|
+ FSDataOutputStream partitionOut = null;
|
|
|
try {
|
|
|
// create spill file
|
|
|
final SpillRecord spillRec = new SpillRecord(partitions);
|
|
@@ -1607,7 +1608,7 @@ public class MapTask extends Task {
|
|
|
IFile.Writer<K, V> writer = null;
|
|
|
try {
|
|
|
long segmentStart = out.getPos();
|
|
|
- FSDataOutputStream partitionOut = CryptoUtils.wrapIfNecessary(job, out);
|
|
|
+ partitionOut = CryptoUtils.wrapIfNecessary(job, out, false);
|
|
|
writer = new Writer<K, V>(job, partitionOut, keyClass, valClass, codec,
|
|
|
spilledRecordsCounter);
|
|
|
if (combinerRunner == null) {
|
|
@@ -1642,6 +1643,10 @@ public class MapTask extends Task {
|
|
|
|
|
|
// close the writer
|
|
|
writer.close();
|
|
|
+ if (partitionOut != out) {
|
|
|
+ partitionOut.close();
|
|
|
+ partitionOut = null;
|
|
|
+ }
|
|
|
|
|
|
// record offsets
|
|
|
rec.startOffset = segmentStart;
|
|
@@ -1670,6 +1675,9 @@ public class MapTask extends Task {
|
|
|
++numSpills;
|
|
|
} finally {
|
|
|
if (out != null) out.close();
|
|
|
+ if (partitionOut != null) {
|
|
|
+ partitionOut.close();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1682,6 +1690,7 @@ public class MapTask extends Task {
|
|
|
int partition) throws IOException {
|
|
|
long size = kvbuffer.length + partitions * APPROX_HEADER_LENGTH;
|
|
|
FSDataOutputStream out = null;
|
|
|
+ FSDataOutputStream partitionOut = null;
|
|
|
try {
|
|
|
// create spill file
|
|
|
final SpillRecord spillRec = new SpillRecord(partitions);
|
|
@@ -1696,7 +1705,7 @@ public class MapTask extends Task {
|
|
|
try {
|
|
|
long segmentStart = out.getPos();
|
|
|
// Create a new codec, don't care!
|
|
|
- FSDataOutputStream partitionOut = CryptoUtils.wrapIfNecessary(job, out);
|
|
|
+ partitionOut = CryptoUtils.wrapIfNecessary(job, out, false);
|
|
|
writer = new IFile.Writer<K,V>(job, partitionOut, keyClass, valClass, codec,
|
|
|
spilledRecordsCounter);
|
|
|
|
|
@@ -1708,6 +1717,10 @@ public class MapTask extends Task {
|
|
|
mapOutputByteCounter.increment(out.getPos() - recordStart);
|
|
|
}
|
|
|
writer.close();
|
|
|
+ if (partitionOut != out) {
|
|
|
+ partitionOut.close();
|
|
|
+ partitionOut = null;
|
|
|
+ }
|
|
|
|
|
|
// record offsets
|
|
|
rec.startOffset = segmentStart;
|
|
@@ -1735,6 +1748,9 @@ public class MapTask extends Task {
|
|
|
++numSpills;
|
|
|
} finally {
|
|
|
if (out != null) out.close();
|
|
|
+ if (partitionOut != null) {
|
|
|
+ partitionOut.close();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1846,6 +1862,7 @@ public class MapTask extends Task {
|
|
|
|
|
|
//The output stream for the final single output file
|
|
|
FSDataOutputStream finalOut = rfs.create(finalOutputFile, true, 4096);
|
|
|
+ FSDataOutputStream finalPartitionOut = null;
|
|
|
|
|
|
if (numSpills == 0) {
|
|
|
//create dummy files
|
|
@@ -1854,10 +1871,15 @@ public class MapTask extends Task {
|
|
|
try {
|
|
|
for (int i = 0; i < partitions; i++) {
|
|
|
long segmentStart = finalOut.getPos();
|
|
|
- FSDataOutputStream finalPartitionOut = CryptoUtils.wrapIfNecessary(job, finalOut);
|
|
|
+ finalPartitionOut = CryptoUtils.wrapIfNecessary(job, finalOut,
|
|
|
+ false);
|
|
|
Writer<K, V> writer =
|
|
|
new Writer<K, V>(job, finalPartitionOut, keyClass, valClass, codec, null);
|
|
|
writer.close();
|
|
|
+ if (finalPartitionOut != finalOut) {
|
|
|
+ finalPartitionOut.close();
|
|
|
+ finalPartitionOut = null;
|
|
|
+ }
|
|
|
rec.startOffset = segmentStart;
|
|
|
rec.rawLength = writer.getRawLength() + CryptoUtils.cryptoPadding(job);
|
|
|
rec.partLength = writer.getCompressedLength() + CryptoUtils.cryptoPadding(job);
|
|
@@ -1866,6 +1888,9 @@ public class MapTask extends Task {
|
|
|
sr.writeToFile(finalIndexFile, job);
|
|
|
} finally {
|
|
|
finalOut.close();
|
|
|
+ if (finalPartitionOut != null) {
|
|
|
+ finalPartitionOut.close();
|
|
|
+ }
|
|
|
}
|
|
|
sortPhase.complete();
|
|
|
return;
|
|
@@ -1909,7 +1934,7 @@ public class MapTask extends Task {
|
|
|
|
|
|
//write merged output to disk
|
|
|
long segmentStart = finalOut.getPos();
|
|
|
- FSDataOutputStream finalPartitionOut = CryptoUtils.wrapIfNecessary(job, finalOut);
|
|
|
+ finalPartitionOut = CryptoUtils.wrapIfNecessary(job, finalOut, false);
|
|
|
Writer<K, V> writer =
|
|
|
new Writer<K, V>(job, finalPartitionOut, keyClass, valClass, codec,
|
|
|
spilledRecordsCounter);
|
|
@@ -1922,6 +1947,10 @@ public class MapTask extends Task {
|
|
|
|
|
|
//close
|
|
|
writer.close();
|
|
|
+ if (finalPartitionOut != finalOut) {
|
|
|
+ finalPartitionOut.close();
|
|
|
+ finalPartitionOut = null;
|
|
|
+ }
|
|
|
|
|
|
sortPhase.startNextPhase();
|
|
|
|
|
@@ -1933,6 +1962,9 @@ public class MapTask extends Task {
|
|
|
}
|
|
|
spillRec.writeToFile(finalIndexFile, job);
|
|
|
finalOut.close();
|
|
|
+ if (finalPartitionOut != null) {
|
|
|
+ finalPartitionOut.close();
|
|
|
+ }
|
|
|
for(int i = 0; i < numSpills; i++) {
|
|
|
rfs.delete(filename[i],true);
|
|
|
}
|