Hi Jiajun, Make sure you don't have the same timestamp on every versions of puts; try to put Thread.sleep() in your test(?) codes when necessary.
You might not want to specify the timestamp by yourself but want to let HBase to store appropriate ones. -- Tatsuya Kawano (Mr.) Tokyo, Japan On Feb 24, 2011, at 11:30 AM, Ryan Rawson <[email protected]> wrote: > There are test cases for this, the functionality DOES work, something is up... > > Without full code and full descriptions of your tables, debugging is > harder than it needs to be. It's probably a simple typo or something, > check your code and table descriptions again. Many people rely on the > multi version query capabilities and it is very unlikely to be broken > in a released version of hbase. > > On Wed, Feb 23, 2011 at 6:27 PM, 陈加俊 <[email protected]> wrote: >> final List<KeyValue> list = result.list(); >> for (final KeyValue it : list) >> { >> System.out.println(Bytes.toString(it.getKey())); >> System.out.println(Bytes.toString(it.getValue())); >> } >> I can only get the last version! why ? Is there any testcase in Hbase? >> >> On Thu, Feb 24, 2011 at 9:56 AM, 陈加俊 <[email protected]> wrote: >> >>> /** >>> * Create a sorted list of the KeyValue's in this result. >>> * >>> * @return The sorted list of KeyValue's. >>> */ >>> public List<KeyValue> list() { >>> if(this.kvs == null) { >>> readFields(); >>> } >>> return isEmpty()? null: Arrays.asList(sorted()); >>> } >>> >>> I will try it . Thank you very much! >>> >>> On Thu, Feb 24, 2011 at 9:45 AM, Buttler, David <[email protected]> wrote: >>> >>>> Result.list() ? >>>> Putting the hbase source into your IDE of choice (yay Eclipse!) is really >>>> helpful >>>> >>>> Dave >>>> >>>> >>>> -----Original Message----- >>>> From: 陈加俊 [mailto:[email protected]] >>>> Sent: Wednesday, February 23, 2011 5:42 PM >>>> To: [email protected] >>>> Cc: Buttler, David >>>> Subject: Re: I can't get many versions of the specified column,but only >>>> get the latest version of the specified column >>>> >>>> Thank you David ! >>>> >>>> I alter the table schema as follow: >>>> >>>>> alter 'cjjIndexPageModify', {NAME => 'log' , VERSIONS => 5 , METHOD => >>>> 'add'} >>>> >>>> How to iterate over KeyValues? which method in Result? >>>> >>>> On Thu, Feb 24, 2011 at 9:27 AM, Buttler, David <[email protected]> >>>> wrote: >>>> >>>>> 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:[email protected]] >>>>> Sent: Wednesday, February 23, 2011 5:22 PM >>>>> To: [email protected] >>>>> 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 <[email protected]> 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, 陈加俊 <[email protected]> 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 >>>>> >>>> >>>> >>>> >>>> -- >>>> Thanks & Best regards >>>> jiajun >>>> >>> >>> >>> >>> -- >>> Thanks & Best regards >>> jiajun >>> >>> >> >> >> -- >> Thanks & Best regards >> jiajun >>
