hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ishaaq Chandy <ish...@gmail.com>
Subject Re: Try to get qualifier collection
Date Tue, 07 Jul 2009 02:53:41 GMT

Thanks for the quick responses guys.

Yes, I did look at RowResult but its not very obvious what its supposed to
do when dealing with a column family that consists of multiple qualifiers.
Does each column family get a single key or does each qualifier get a single
key in the entry set?

I'm sorry, I guess I could run a test and check what it does but I am
physically away from my machine which has HBase installed so I can't verify
this - so I resorted to the documentation which didn't seem too clear to me.

Thanks again,
Ishaaq



stack-3 wrote:
> 
> On Mon, Jul 6, 2009 at 6:39 PM, Ishaaq Chandy <ishaaq@gmail.com> wrote:
> 
>>
>> Hmm, I have a similar requirement. However, when looking at the API I
>> cannot
>> see these classes: Get and Result. Are these 0.20.0 classes? If so, what
>> would be the equivalent for 0.19.3?
> 
> 
> 
> Yes.  These are 0.20.0 classes.
> 
> In 0.19.3, use RowResult.  Iterate entrySet:
> http://hadoop.apache.org/hbase/docs/r0.19.3/api/org/apache/hadoop/hbase/io/RowResult.html#entrySet().
> Its keyed by column.
> 
> St.Ack
> 
> 
> Thanks,
>> Ishaaq
>>
>>
>> Jonathan Gray-2 wrote:
>> >
>> > Fleming,
>> >
>> > Of course there is!
>> >
>> > Look at some of the different methods in Result that return various
>> Maps
>> > in different format.  For your example, you might do:
>> >
>> > =======
>> >
>> > HTable table = new HTable("Table1");
>> > Get g = new Get(Bytes.toBytes("Key1"));
>> > Result r = table.get(g);
>> >
>> > // Get a Map<qualifier,value> for Family
>> >
>> > Map<byte[],byte[]> family = r.getFamilyMap(Bytes.toBytes("Family"));
>> >
>> > // You can get a value knowing the qualifier
>> >
>> > byte [] value1 = family.get(Bytes.toBytes("qualifier1"));
>> >
>> > // Or you can just iterate all the qualifiers and values
>> >
>> > for(Map.Entry<byte[],byte[]> entry : family.entrySet()) {
>> >    byte [] qualifier = entry.getKey();
>> >    byte [] value = entry.getValue();
>> > }
>> >
>> > =======
>> >
>> > All the maps that are returned by Result are NavigableMaps, so they are
>> > sorted and allow a number of operations on them.
>> >
>> > Hope that helps.
>> >
>> > JG
>> >
>> > y_823910@tsmc.com wrote:
>> >> Hi there,
>> >>
>> >> I have a table "Table1" with one Family and 10 qualifier.
>> >> Any ways that I can get these qualifier's name in Table1,
>> >> then I can loop qualifier collection to fetch each qualifier's value.
>> >> Thank you
>> >>
>> >> Fleming
>> >>
>> >>
>> ====================================================================================
>> >>
>> >> HTable table = new HTable(config, "Table1");
>> >> Get g = new Get(Bytes.toBytes("Key1"));
>> >> Result r = table.get(g);
>> >> byte [] value1 = r.getValue(Bytes.toBytes("Family"),
>> >> Bytes.toBytes("qualifier1"));
>> >> String valueStr1 = Bytes.toString(value1);
>> >> byte [] value2 = r.getValue(Bytes.toBytes("Family"),
>> >> Bytes.toBytes("qualifier2"));
>> >> String valueStr2 = Bytes.toString(value2);
>> >>                       .
>> >>                       .
>> >>                       .
>> >>
>> >> byte [] value10 = r.getValue(Bytes.toBytes("Family"),
>> >> Bytes.toBytes("qualifier10"));
>> >> String valueStr10 = Bytes.toString(value10);
>> >>
>> >>
>> ---------------------------------------------------------------------------
>> >>                                                          TSMC PROPERTY
>> >>  This email communication (and any attachments) is proprietary
>> >> information
>> >>  for the sole use of its
>> >>  intended recipient. Any unauthorized review, use or distribution by
>> >> anyone
>> >>  other than the intended
>> >>  recipient is strictly prohibited.  If you are not the intended
>> >> recipient,
>> >>  please notify the sender by
>> >>  replying to this email, and then delete this email and any copies of
>> it
>> >>  immediately. Thank you.
>> >>
>> >>
>> ---------------------------------------------------------------------------
>> >>
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Try-to-get-qualifier-collection-tp24217280p24365806.html
>> Sent from the HBase User mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Try-to-get-qualifier-collection-tp24217280p24366338.html
Sent from the HBase User mailing list archive at Nabble.com.


Mime
View raw message