Client javadoc suggestion:  add code examples about obtaining historical values
-------------------------------------------------------------------------------

                 Key: HBASE-2004
                 URL: https://issues.apache.org/jira/browse/HBASE-2004
             Project: Hadoop HBase
          Issue Type: Improvement
          Components: client
    Affects Versions: 0.20.1
            Reporter: Doug Meil
            Priority: Minor


The implicit support HBase provides for versioning of values is very powerful, 
but it's not all that obvious for application programmers to use it to obtain 
the historical values.

I would like to suggest adding some comments and sample code to the Result 
class (org.apache.hadoop.hbase.client.Result) Javadoc.  I know this seems sort 
of obvious to people that regularly use HBase, but I think that for new folks 
having code examples available in Javadoc is helpful because it's "one stop 
shopping" for documentation (i.e., as opposed to looking to an external 
writeup).  Arguably, this type of example could also go in the HTable class 
javadoc.

e.g.,....

    HTable table = new HTable(config, "mytable");
    Scan scan = new Scan();   // no arguments indicates will scan all rows
    scan.setMaxVersions( 5 );         // setting this to 1 only returns current 
version
    ResultScanner rs = table.getScanner(scan);

    for (Iterator<Result> i = rs.iterator(); i.hasNext(); ) {
        Result r = i.next();

        // obtains current value from 'family:column'
        byte b[] = r.getValue( Bytes.toBytes("family"), Bytes.toBytes("column") 
);

        KeyValue kv[] = r.raw();
        for (int j = 0; j < kv.length; j++) {
                
               byte bv[] = kv[j].getValue();
              // this loop returns both current and historical values

               byte bc[] = kv[j].getColumn();
               // returns 'family:column'

         }
   }    
 


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to