Personally, when I need to dig into a complex result with multiple columns and versions, I iterate over the KeyValues directly rather than messing with the Map-based return formats from Result.

In your example, are you just returning versions/values for a single column? Maybe we could add some methods that returned subsets of the total set of KeyValues (for example, Result.getKeyValues(family, qualifier) would return all versions of that column in the result in KeyValue format).

Going to drop a note in HBASE-1937.

JG

Doug Meil wrote:
Hi there-

Question:  how does one obtain older versions of values from Result?

As I understand it, the following Scan instance should return the last 5 
versions of values for a table, provided that the table is versioned.

    Scan scan = new Scan();
    scan.setMaxVersions(5);

From the Javadoc, it looks like what I want is in here (from Result)....
getMap

public 
NavigableMap<http://java.sun.com/javase/6/docs/api/java/util/NavigableMap.html?is-external=true><byte[],NavigableMap<http://java.sun.com/javase/6/docs/api/java/util/NavigableMap.html?is-external=true><byte[],NavigableMap<http://java.sun.com/javase/6/docs/api/java/util/NavigableMap.html?is-external=true><Long<http://java.sun.com/javase/6/docs/api/java/lang/Long.html?is-external=true>,byte[]>>>
 getMap()
Map of families to all versions of its qualifiers and values.

...  but there is a fair amount of gymnastics involved to get the data.

Suggestion:   can an example of iterating over this map (and contained maps) be 
added to the Javadoc?  Versioning is a powerful feature of HBase but using it 
isn't obvious in result processing.

Thanks!


Doug Meil
Director of Engineering
[email protected]


Reply via email to