Index: src/uk/ac/gla/terrier/applications/HadoopIndexing.java
===================================================================
RCS file: /usr/local/cvs/javair/terrier/src/uk/ac/gla/terrier/applications/HadoopIndexing.java,v
retrieving revision 1.3
diff -u -r1.3 HadoopIndexing.java
--- src/uk/ac/gla/terrier/applications/HadoopIndexing.java	28 Jan 2009 20:16:43 -0000	1.3
+++ src/uk/ac/gla/terrier/applications/HadoopIndexing.java	28 Jan 2009 21:29:38 -0000
@@ -37,6 +37,9 @@
 import org.apache.hadoop.mapred.FileOutputFormat;
 import org.apache.hadoop.mapred.JobClient;
 import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapred.JobID;
+import org.apache.hadoop.mapred.RunningJob;
+import org.apache.hadoop.mapred.TaskID;
 import org.apache.hadoop.mapred.lib.NullOutputFormat;
 import org.apache.log4j.Logger;
 
@@ -106,7 +109,7 @@
 		conf.setInputFormat(MultiFileCollectionInputFormat.class);
 		conf.setOutputFormat(NullOutputFormat.class);
 		conf.setOutputKeyComparatorClass(MapEmittedTerm.TermMapFlushComparator.class);
-        conf.setOutputValueGroupingComparator(MapEmittedTerm.TermComparator.class);
+		conf.setOutputValueGroupingComparator(MapEmittedTerm.TermComparator.class);
 
 		//parse the collection.spec
 		BufferedReader specBR = Files.openFileReader(ApplicationSetup.COLLECTION_SPEC);
@@ -129,13 +132,36 @@
 		{
 			conf.setNumReduceTasks(1);
 		}
+		
+		JobID jobId = null;
 		try{
-			JobClient.runJob(conf);
+			RunningJob rj = JobClient.runJob(conf);
+			jobId = rj.getID();
 		} catch (Exception e) { 
 			logger.error("Problem running job", e);
 		}
+		if (jobId != null)
+		{
+			deleteTaskFiles(ApplicationSetup.TERRIER_INDEX_PATH, jobId);
+		}
 		System.out.println("Time Taken = "+((System.currentTimeMillis()-time)/1000)+" seconds");
 		jf.close();
 	}
 
+	public static void deleteTaskFiles(String path, JobID job)
+	{
+		String[] fileNames = Files.list(path);
+		for(String filename : fileNames)
+		{
+			String periodParts[] = filename.split("\\.");
+			try{
+				TaskID tid = TaskID.forName(periodParts[0]);
+				if (tid.getJobID().compareTo(job) == 0)
+				{
+					if (! Files.delete(path + "/" + filename))
+						logger.warn("Could not delete temporary map side-effect file "+ path + "/" + filename);
+				}
+			} catch (Exception e) {}
+		}   
+	 }
 }
Index: src/uk/ac/gla/terrier/indexing/hadoop/Hadoop_BasicSinglePassIndexer.java
===================================================================
RCS file: /usr/local/cvs/javair/terrier/src/uk/ac/gla/terrier/indexing/hadoop/Hadoop_BasicSinglePassIndexer.java,v
retrieving revision 1.3
diff -u -r1.3 Hadoop_BasicSinglePassIndexer.java
--- src/uk/ac/gla/terrier/indexing/hadoop/Hadoop_BasicSinglePassIndexer.java	28 Jan 2009 20:16:47 -0000	1.3
+++ src/uk/ac/gla/terrier/indexing/hadoop/Hadoop_BasicSinglePassIndexer.java	28 Jan 2009 21:29:38 -0000
@@ -504,7 +504,7 @@
 
 	/** finishes the reduce step, by closing the lexicon and inverted file output,
  	  * building the lexicon hash and index, and merging the document indices created
-	  * by the map tasks. All temporary map-phase files are deleted and the output index finalised */
+	  * by the map tasks. The output index finalised */
 	protected void closeReduce() throws IOException {
 		
 		if (! reduceStarted)
@@ -540,15 +540,12 @@
 					+Index.getLastIndexLoadError());
 		}
 		this.mergeDocumentIndex(sourceIndices);
-		//4. close the map phase indices, and delete them
+		//4. close the map phase indices
 		for(Index i : sourceIndices)
 		{
 			String path = i.getPath();
 			String prefix = i.getPrefix();
 			i.close();
-			Files.delete(path + ApplicationSetup.FILE_SEPARATOR + prefix + ".runs");
-			Files.delete(path + ApplicationSetup.FILE_SEPARATOR + prefix + ApplicationSetup.DOC_INDEX_SUFFIX);
-			Files.delete(path + ApplicationSetup.FILE_SEPARATOR + prefix + ".properties");
 		}
 		//5. finalise the lexicon
 		int numTerms;

