Thanks, Tom -- that seems to work for the case where the "from" value I'm looking for exists in the MapFile. However, if I call get() on a "from" value that doesn't exist, then call next(), I would expect to get the first value that follows "from", but instead it seems to return the value after that.
However, after some experimenting I found that getClosest() followed by next() seems to work. I would suggest that for both get() and getClosest(), there is nothing in the javadoc to indicate that subsequent reads will get the values that follow, so perhaps this could stand a little cleanup or clarification in a later version. Also, I still don't see how the seek() method is of much use (except maybe internally). But thanks for leading me to a solution for my particular issue... Tom White-3 wrote: > > 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 > <[email protected]> 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. >> >> > > -- View this message in context: http://www.nabble.com/MapFile.Reader-and-seek-tp21737717p21802676.html Sent from the Hadoop core-user mailing list archive at Nabble.com.
