hadoop-common-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom White <...@cloudera.com>
Subject Re: MapFile.Reader and seek
Date Mon, 02 Feb 2009 12:10:08 GMT
You can use the get() method to seek and retrieve the value. It will
return null if the key is not in the map. Something like:

Text value = (Text) indexReader.get(from, new Text());
while (value != null && ...)

Tom

On Thu, Jan 29, 2009 at 10:45 PM, schnitzi
<mark.schnitzius@fastsearch.com> wrote:
>
> Greetings all...  I have a situation where I want to read a range of keys and
> values out of a MapFile.  So I have something like this:
>
>    MapFile.Reader indexReader = new MapFile.Reader(fs, path.toString(),
> configuration)
>    boolean seekSuccess = indexReader.seek(from);
>    boolean readSuccess = indexReader.next(keyValue, value);
>    while (readSuccess && ...)
>
> The problem seems to be that while seekSuccess is returning true, when I
> call next() to get the value there, it's returning the value *after* the key
> that I called seek() on.  So if, say, my keys are Text("id0") through
> Text("id9"), and I seek for Text("id3"), calling next() will return
> Text("id4") and its associated value, not Text("id3").
>
> I would expect next() to return the key/value at the seek location, not the
> one after it.  Am I doing something wrong?  Otherwise, what good is seek(),
> really?
> --
> View this message in context: http://www.nabble.com/MapFile.Reader-and-seek-tp21737717p21737717.html
> Sent from the Hadoop core-user mailing list archive at Nabble.com.
>
>

Mime
View raw message