hadoop-common-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark <static.void....@gmail.com>
Subject Re: Writable questions
Date Thu, 02 Sep 2010 14:34:50 GMT
  On 9/1/10 11:28 PM, Lance Norskog wrote:
> Wait- you want a print-to-user method or a 'serialize/deserialize' method?
>
> On Tue, Aug 31, 2010 at 2:42 PM, David Rosenstrauch<darose@darose.net>  wrote:
>> On 08/31/2010 02:09 PM, Mark wrote:
>>> On 8/31/10 10:07 AM, David Rosenstrauch wrote:
>>>> On 08/31/2010 12:58 PM, Mark wrote:
>>>>> I have a question regarding outputting Writable objects. I thought all
>>>>> Writables know how to serialize themselves to output.
>>>>>
>>>>> For example I have an ArrayWritable of strings (or Texts) but when I
>>>>> output it to a file it shows up as
>>>>> 'org.apache.hadoop.io.ArrayWritable@21f7186f'
>>>>>
>>>>> Am I missing something? I would have expected it to output "String1
>>>>> String2 String3" etc. If I am going about this the wrong way can someone
>>>>> explain the proper way for my reduce phase to output a key and a list
of
>>>>> values. Thanks
>>>> Writables know how to serialize and deserialize themselves (i.e., to a
>>>> binary I/O stream). But that doesn't necessarily mean that they have a
>>>> toString method for generating human-readable output.
>>>>
>>>> DR
>>> Ok that makes sense. How would I go about outputing an ArrayWritable
>>> then? Use a StringBuilder?
>> Hmmm ....
>>
>> Maybe something like this?
>>
>> Arrays.toString((TheArrayElementClass[])ArrayWritable.toArray())
>>
>> HTH,
>>
>> DR
>>
>
>
I wanted to output an ArrayWritable from my reducer to a human readable 
format... something like this

ArrayWritable values = new ArrayWritable(new String[] { "value1", 
"value2", "value3"});
context.write(new Text("My Key"), values);

I would have thought it would have output the values with some 
configurable delimeter.

Mime
View raw message