hadoop-common-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lukas Vlcek" <lukas.vl...@gmail.com>
Subject Re: FileOutputFormat which does not write key value?
Date Wed, 20 Feb 2008 13:56:01 GMT
Owen,

This is still not clear to me. I see the following code in TextOutputFormat
class:

...
public synchronized void write(K key, V value)
      throws IOException {

      boolean nullKey = key == null || key instanceof NullWritable;
      boolean nullValue = value == null || value instanceof NullWritable;
      if (nullKey && nullValue) {
        return;
      }
      if (!nullKey) {
        writeObject(key);
      }
      if (!(nullKey || nullValue)) {
        out.write(tab);
      }
      if (!nullValue) {
        writeObject(value);
      }
      out.write(newline);
    }

This seems to me as if the tab is always output if the value is not null
regardless key being null or not.
Am I missing something?

Lukas

On Feb 19, 2008 11:55 PM, Owen O'Malley <oom@yahoo-inc.com> wrote:

>
> On Feb 19, 2008, at 1:52 PM, Lukas Vlcek wrote:
>
> > Hi,
> >
> > I don't care about key value in the output file. Is there any way
> > how I can
> > suppress key in the output?
> > Is there a way how to tell (Text)OutputFormat not to write key but
> > value
> > only? Or can I pass my own implementation of RecordWriter into
> > FileOutputFormat?
>
> The easiest way is to put either null or a NullWritable in for the
> key coming out of the reduce. The TextOutputFormat will drop the tab
> character. You can also define your own OutputFormat and encode them
> as you wish.
>
> -- Owen
>



-- 
http://blog.lukas-vlcek.com/

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message