The exact problem I'm facing is the following: entry.getKey() and entry.getValue() return Writable types. How do I extract the buried Int and Double? In case of IntWritable and DoubleWritable return types, I could have used entry.getKey().get() and entry.getValue.get() and it would have been fine.
On Tue, Jun 21, 2011 at 4:18 PM, Alberto Andreotti < [email protected]> wrote: > Never worked with maps before, btw what are you trying to calculate? > > There is no calculation in this loop, it is just a conversion from one type (MapWritable) produced by the reducer(s) to another type (Vector) which can be consumed by some legacy code for actual processing. > > alberto. > > On 21 June 2011 17:14, Dhruv Kumar <[email protected]> wrote: > > > I want to extract the key-value pairs from a MapWritable, cast them into > > Integer (key) and Double (value) types, and add them to another > collection. > > I'm attempting the following but this code is incorrect. > > > > // initialDistributionStripe is a MapWritable<IntWritable, > DoubleWritable> > > // initialProbabilities is of type Vector which can have (Integer, > Double) > > entries in it > > > > for (Map.Entry<Writable, Writable> entry : initialDistributionStripe. > > entrySet()) { > > initialProbabilities.set(entry.getKey(), entry.getValue()); > > } > > > > > > Is there a convenient way to do this? > > > > > > -- > José Pablo Alberto Andreotti. > Tel: 54 351 4730292 > Móvil: 54351156526363. > MSN: [email protected] > Skype: andreottialberto >
