Oh, well spotted Tatsuya, didn't even see his use of "tablename" there!

On Thu, Jan 6, 2011 at 4:22 AM, Tatsuya Kawano <[email protected]> wrote:
>
> Hi,
>
>>  byte [] by = rs.getValue(Bytes.toBytes(tablename));
>
> Result#getValue() doesn't take a table name but a column name in 
> "family:qualifier" format, so you shouldn't give it the table name here. Also 
> be aware that single result object represents a row and it will have multiple 
> columns, so you might want to use Result#row() or Result#list() to iterate 
> them. (a KeyValue represents a column.)
>
> for (Result result : rscanner) {
>    for (KeyValue kv : result.row()) {
>        String vt = Bytes.toString(kv.getValue());
>        System.out.println("The value is "+ vt);
>    }
> }
>
> Thanks,
>
> --
> Tatsuya Kawano (Mr.)
> Tokyo, Japan
>
> http://twitter.com/#!/tatsuya6502
>
>
>
> On 01/05/2011, at 5:45 PM, how to get the cell value wrote:
>
>> I would like to get specified value from the table which don't mind its 
>> family
>> and column.
>>   I used ValueFilter to make it ,but i get nothing .
>>   My code is :
>>
>>               try
>>               {
>>                          HTable htable = new
>> HTable(hconf,Bytes.toBytes(tablename));
>>
>>                          ValueFilter vfilter = new
>> ValueFilter(CompareOp.EQUAL,new BinaryComparator(Bytes.toBytes(value)));
>>
>>                          Scan s =new Scan();
>>                          s.setFilter(vfilter);
>>                          ResultScanner rscanner = htable.getScanner(s);
>>                          for(Result rs : rscanner)
>>                          {
>>                                  byte [] by =
>> rs.getValue(Bytes.toBytes(tablename));
>>
>>                                       String vt= Bytes.toString(by);
>>                                        System.out.println("The value is "+ 
>> vt);
>>                          }
>>
>>               }
>>               catch(IOException e)
>>               {
>>                       e.printStackTrace();
>>               }
>>
>
>
>
>
>

Reply via email to