Question: I have a Datagridview which I populate from a Dataset created from an XML file. This part works and I can get the entire contents of the Dataset to display in a datagrid. I have the added functionality to filter the datagridview based upon a date and sold flag. This also works OK as the datagridview updates as you cycle through the dates. However I need to do some calculations on the "filtered" datagridview. These calculations are need to convert various currencies into GBP. So after some research on the best way to do this I decided to loop through the visible datagridview and test each of the visible. This is the code I cam up with. Unfortunately when run it all the tests fail and it try to carry out the else clause which then fails with a "Input string was not in a correct format" Exception. However I do not think that is the issue as I put a watch on the Price and Currency values and they "Do not Exist in the current Context"...now im stuck and would appreciate some help. Perhaps im going about this wrong way...

Thanks

Harry

```
for (int i = 1; i < dataGridView1.Rows.Count; i++)
            {
                if (dataGridView1["currency", i].ToString() == "USD")
                {
                    myCommission += double.Parse(dataGridView1["commission", i].ToString()) * (double.Parse(dataGridView1["price", i].ToString()) * UStoGB);
                }
                else if (dataGridView1["currency", i].ToString() == "EURO")
                {
                    myCommission += double.Parse(dataGridView1["commission", i].ToString()) * (double.Parse(dataGridView1["price", i].ToString()) * EUtoGB);
                }
                else
                {
                    myCommission += double.Parse(dataGridView1["commission", i].ToString()) * double.Parse(dataGridView1["price", i].ToString());
                }

            }

```

Answer: 
`map.input.file` environment parameter has the file name which the mapper is processing. Get this value in the mapper and use this as the output key for the mapper and then all the k/v from a single file to go to one reducer.

The code in the mapper. BTW, I am using the old MR API

```
@Override
public void configure(JobConf conf) {
    this.conf = conf;
}

@Override.
public void map(................) throws IOException {

        String filename = conf.get("map.input.file");
        output.collect(new Text(filename), value);
}

```

And use MultipleOutputFormat, this allows to write multiple output files for the job. The file names can be derived from the output keys and values.
Hadoop 'chunks' data into blocks of a configured size. Default is 64MB blocks. You may see where this causes issues for your approach; Each mapper may get only a piece of a file. If the file is less than 64MB (or whatever value is configured), then each mapper will get only 1 file.

I've had a very similar constraint; I needed a set of files (output from previous reducer in chain) to be entirely processed by a single mapper. I use the <64MB fact in my solution
The main thrust of my solution is that I set it up to provide the mapper with the file name it needed to process, and internal to the mapper had it load/read the file. This allows a single mapper to process an entire file - It's not distributed processing of the file, but with the constraint of "I don't want individual files distributed" - it works. :)

I had the process that launched my MR write out the file names of the files to process into individual files. Where those files were written was the input directory. As each file is <64MB, then a single mapper will be generated for each file. The `map` process will be called exactly once (as there is only 1 entry in the file).  

I then take the value passed to the mapper and can open the file and do whatever mapping I need to do.
Since hadoop tries to be smart about how it does Map/Reduce processes, it may be required to specify the number of reducers to use so that each mapper goes to a single reducer. This can be set via the `mapred.reduce.tasks` configuration. I do this via `job.setNumReduceTasks("mapred.reduce.tasks",[NUMBER OF FILES HERE]);`

My process had some additional requirements/constraints that may have made this specific solution appealing; but for an example of a 1:in to 1:out; I've done it, and the basics are laid out above.

HTH