hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Devaraja Swami <devarajasw...@gmail.com>
Subject Re: Iterate hbase resultscanner
Date Thu, 11 Jun 2015 01:04:56 GMT
Can you provide the full code for Conver() and Listclass?
Giving snippets of code is insufficient.....
My suspicion is a bug in your code.
You might want to print out the output of Conver(next) before passing to
Listclass.add()
and print out the entire list of Listclass elements, during each iteration.
Please also note that the byte arrays inside the Result class are also
recycled.
You have to use APIs from CellUtils to correctly access the byte arrays.

On Wed, Jun 10, 2015 at 9:39 AM, beeshma r <beeshma48@gmail.com> wrote:

> HI Devaraj
>
>  Thanks for your suggestion.
>
> Yes i coded like this as per your suggestion.
>
> public static void put_result(ResultScanner input) throws IOException
> {
>
>     Iterator<Result> iterator = input.iterator();
>     while(iterator.hasNext())
>     {
>
>         Result next = iterator.next();
>
>         Listclass.add(Conver(next));
>
>
>     }
> }
>
>
>  But still have same problem:( .can you please suggest any changes in this
> ? or how do i overcome this?
>
> Thanks
> Beeshma
>
>
>
>
>
>
>
>
>
>
>
> On Tue, Jun 9, 2015 at 10:31 AM, Devaraja Swami <devarajaswami@gmail.com>
> wrote:
>
> > Beeshma,
> >
> > HBase recycles the same Result instance in the ResultScanner iterator, to
> > save on memory allocation costs.
> > With each iteration, you get the same Result object reference,
> re-populated
> > internally by HBase with the new values for each iteration.
> > If you add the Result loop variable instance to your list during the
> > iteration, you are adding the same instance each time to your list, but
> > internally the values change. At the end of your loop, all the elements
> > will therefore be the same, and the values will be that of the last
> > iteration.
> > The correct way to use the ResultScanner iteration is to extract the data
> > you want from the Result loop variable within the iteration and collect
> the
> > extracted data in your list, or alternately to create a new Result
> instance
> > from the Result loop variable, and add the new instance to your list.
> >
> >
> > On Mon, Jun 8, 2015 at 10:03 AM, beeshma r <beeshma48@gmail.com> wrote:
> >
> > > Hi Ted
> > >
> > > I declared Listclass as
> > > public static List<Listclass> map_list_main=new ArrayList<Listclass>();
> > >
> > > i know my logic is correct .only issue is adding my result to this
> > > Listclass.Also my conversion works perfectly .i checked  this based on
> > > print out put results.
> > >
> > > only issue is why final element of Listclass updated for all elements
> in
> > > list
> > >
> > > I am using hbase version hbase-0.98.6.1
> > > Hadoop -2.5.1
> > >
> > > Also i using finagle client ,server module.So can u advise  How do i
> > debug
> > > this?
> > >
> > > Thanks
> > > Beeshma
> > >
> > >
> > >
> > >
> > >
> > > On Mon, Jun 8, 2015 at 9:24 AM, Ted Yu <yuzhihong@gmail.com> wrote:
> > >
> > > > From your description, the conversion inside for(Result
> > rs:ListofResult)
> > > > loop was correct.
> > > >
> > > > Since Listclass is custom, probably you need to show us how it is
> > > > implemented.
> > > >
> > > > Which hbase release are you using ?
> > > >
> > > > On Mon, Jun 8, 2015 at 9:19 AM, beeshma r <beeshma48@gmail.com>
> wrote:
> > > >
> > > > > HI
> > > > >
> > > > > I have weired issue with Hbase Result Scanner
> > > > >
> > > > > This is my scenario
> > > > >
> > > > >     i have a list of Resultscanner(ListofScanner)
> > > > >     from this Resultscanner list i want extract all results as list
> > of
> > > > > result(ListofResult)
> > > > >     and from result list i want iterate all cell values add to
> custom
> > > > class
> > > > > list (Listclass)
> > > > >
> > > > > So i coded like this
> > > > >
> > > > > for(ResultScanner resca:ListofScanner)
> > > > > {
> > > > > for(Result Res:resca)
> > > > >     {
> > > > >
> > > > >     ListofResult.add(Res);
> > > > >
> > > > >
> > > > >     }
> > > > > }
> > > > >
> > > > >
> > > > > for(Result rs:ListofResult)
> > > > > {
> > > > >
> > > > >    Listclass.add(Conver(rs));//Conver is function that converts
> > results
> > > > and
> > > > > return as a my class object
> > > > >
> > > > > }
> > > > >
> > > > > Here is the O/p
> > > > >
> > > > > suppose i expect this result form Listclass if a print a all values
> > > > >
> > > > > gattner
> > > > > lisa
> > > > > Miely
> > > > > luzz
> > > > >
> > > > > But actual list i got
> > > > >
> > > > > luzz
> > > > > luzz
> > > > > luzz
> > > > > luzz
> > > > >
> > > > > The last element of Listclass is got updated to all values
> > > > >
> > > > > I checked for each Result output after conversion ( Conver(rs) )
it
> > > > returns
> > > > > as expected. But only issue adding Listofclass.
> > > > >
> > > > > Also i run with maven exec:java  command(org.codehaus.mojo) .Break
> > > point
> > > > > also not working for me  :(
> > > > > Please give me advice how to debug this.
> > > > >
> > > > >
> > > > >
> > > > > Thanks
> > > > > Beeshma
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > >
> >
>
>
>
> --
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message