hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stack <st...@duboce.net>
Subject Re: I can't get many versions of the specified column,but only get the latest version of the specified column
Date Wed, 23 Feb 2011 18:06:03 GMT
What do you get for a result?

You are only entering a single version of each column, a single
version of FAMILY:q1, a single version FAMILY:q2, and a FAMILY:q3.

St.Ack

On Wed, Feb 23, 2011 at 2:54 AM, 陈加俊 <cjjvictory@gmail.com> wrote:
> I can't get many versions of the specified column,but only get the latest
> version of the specified column. Is there anyone  help me?
>
> //put data by version
>
>  final Put p = new Put(key); // key
> final long ts = System.currentTimeMillis();
>       p.add(FAMILY, q1, ts,v1);
>       p.add(FAMILY, q2, ts,v2);
>       p.add(FAMILY, q3, ts,v3);
>
>      table.put(p);
>
>
> //get all versions of data
>
> final Get get = new Get(key);
>           get.addFamily(FAMILY);
>           get.setMaxVersions(10);
>           final Result result = htable.get(get);
>
>           final NavigableMap<byte[], NavigableMap<byte[],
> NavigableMap<Long, byte[]>>> map = result.getMap();
>           final Set<Entry<byte[], NavigableMap<byte[],
> NavigableMap<Long, byte[]>>>> entrySet = map.entrySet();
>           final Iterator<Entry<byte[], NavigableMap<byte[],
> NavigableMap<Long, byte[]>>>> iterator = entrySet
>                   .iterator();
>           while (iterator.hasNext())
>           {
>               final Entry<byte[], NavigableMap<byte[],
> NavigableMap<Long, byte[]>>> next = iterator.next();
>               System.out.println(Bytes.toString(next.getKey())); //family
>               for (final Entry<byte[], NavigableMap<Long, byte[]>>
> item : next.getValue().entrySet())
>               {
>                   System.out.println(Bytes.toString(item.getKey()));
>                   for (final Entry<Long, byte[]> _item :
> item.getValue().entrySet())
>                   {
>                       System.out.println(_item.getKey()); //q
>                       System.out.println(Bytes.toString(_item.getValue()));
> //value
>                   }
>               }
>
>           }
>
> --
> Thanks & Best regards
> jiajun
>

Mime
View raw message