Hi John, thanks for the reply. But I'm not asking about the key memory
allocation here. I'm just saying what's the difference between:

Next(key,value) and Next(key) .  Is the later one still reading the value of
the key to reach the next key? or does it read the key then using the
recordSize skips to the next key?

Thanks,
Mark



On Thu, Jun 2, 2011 at 3:49 PM, John Armstrong <john.armstr...@ccri.com>wrote:

> On Thu, 2 Jun 2011 15:43:37 -0700, Mark question <markq2...@gmail.com>
> wrote:
> >  Does anyone knows if :  SequenceFile.next(key) is actually not reading
> > value into memory????
>
> I think what you're confused by is something I stumbled upon quite by
> accident.  The secret is that there is actually only ONE Key object that
> the RecordReader presents to you.  The next() method doesn't create a new
> Key object (containing the new data) but actually just loads the new data
> into the existing Key object.
>
> The only place I've seen that you absolutely must remember these unusual
> semantics is when you're trying to copy keys or values for some reason, or
> to iterate over the Iterable of values more than once.  In these cases you
> must make defensive copies because otherwise you'll just git a big list of
> copies of the same Key, containing the last Key data you saw.
>
> hth
>

Reply via email to