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 02:47:35 GMT
Sorry for bothering you again.

I use JSONSerializer to read ArrayList.


                JSONSerializer jsonSerializer = new JSONSerializer();
new JSONSerializerListener.Adapter(){
                                private ArrayList<Object> page = new 
                    public void endList(JSONSerializer jsonSerializer) {
                    public void readItem(JSONSerializer jsonSerializer, 
Object item) {
                    public void endDictionary(JSONSerializer 
jsonSerializer) {
An exception is thrown out


Since I get data from db in a jsp(or from a servlet.).
        1.i can't use the callback class
        2.from jsonSerializer.getJSONSerializerListeners () throwing 

I am totally stranded..

Looking forward to the reply.Thanks very much


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


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(). 

        1.Can any one demonstrate the 2 method of  endList() and 

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


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.

View raw message