When in doubt, printf() can be your friend. Yeah its primitive (old school) but effective.
Then you will know what you’re adding to your list for sure. > On Jun 10, 2015, at 12:39 PM, beeshma r <[email protected]> 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 <[email protected]> > 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 <[email protected]> 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 <[email protected]> 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 <[email protected]> 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 >>>>> >>>> >>> >>> >>> >>> -- >>> >> > > > > --
