hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Buttler, David" <buttl...@llnl.gov>
Subject RE: I can't get many versions of the specified column,but only get the latest version of the specified column
Date Thu, 24 Feb 2011 01:27:45 GMT
What is your table schema set to?  By default it holds 3 versions.
Also, you might iterating over KeyValues instead of using the Map since you don't really care
about the organization, just the time.

Dave

-----Original Message-----
From: 陈加俊 [mailto:cjjvictory@gmail.com] 
Sent: Wednesday, February 23, 2011 5:22 PM
To: user@hbase.apache.org
Cc: Stack
Subject: Re: I can't get many versions of the specified column,but only get the latest version
of the specified column

I execute it five times at diffrent time.

//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);

So I can get five versions ,right?

On Thu, Feb 24, 2011 at 2:06 AM, Stack <stack@duboce.net> wrote:

> 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
> >
>



-- 
Thanks & Best regards
jiajun
Mime
View raw message