hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 陈加俊 <cjjvict...@gmail.com>
Subject 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 10:54:15 GMT
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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message