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 <st...@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, 陈加俊 <cjjvict...@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

Reply via email to