pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Her...@sz.murata.com.cn
Subject Re: how to set large data using getquery and jsonserializer?
Date Fri, 10 Dec 2010 01:53:12 GMT
Thanks for your professional answer.

I' ll try it again.

Thanks and best regards

Hero.



Greg Brown <gk_brown@verizon.net> 
12/09/2010 09:13 PM
Please respond to
user@pivot.apache.org


To
user@pivot.apache.org
cc

Subject
Re: how to set large data using getquery and jsonserializer?






        I'd like to build a demo following the large data set sample in 
Apache Pivot official web site . 

        The sample is using CSVSerializer and calling a thead class [
AddRowsCallback] in method endList() and readitem(). 

Question: 
        1.Can any one demonstrate the 2 method of  endList() and 
readItem()? 

The code at the beginning of this file is the best example of how to use 
these methods:

http://svn.apache.org/repos/asf/pivot/trunk/demos/src/org/apache/pivot/demos/million/LargeData.java

The execute() method opens a stream from the given URL and wraps it in a 
MonitoredInputStream. MonitoredInputStream is an inner class of IOTask 
that will respect the abort flag if it is set by the caller.

It then reads the data from the input stream using CSVSerializer. 
CSVSerializer fires 3 events:

beginList() -- called when the list is created
endList() -- called after the last item has been read
readItem() -- called after each item is read

In this example, the listener implementation builds up pages of results 
before adding them to the table view, since this will generally perform 
better for a large number of rows. The add is done in a callback so the UI 
does not get bogged down.

        2.if using JSONSerializer and accept  ArrayList parameter.do i 
still have to overwrite endList() and readItem()?I tried 
      but it seams wrong. 

If you are reading JSON data, you will probably want to implement 
endList() and endDictionary() (assuming that your items are stored as JSON 
objects). endDictionary() will be called for each "row" in your data set.

I just want to set ArrayList  into tableview.As when the list'length is 
over about 500 hundreds,UI becomes 
frozen a few minutes. 

Yes, that is why we use the callback with the listeners. Make sure that 
you are calling the asynchronous version of Task#execute() (the one that 
takes a TaskListener). The synchronous one won't do you much good, since 
you'll be executing the actual query on the UI thread and it won't get any 
updates until the task is done.



Mime
View raw message