GWT RPC with large data arrays

2011-07-21 Thread Daniel Peterson
I'm trying to transmit large amounts of data from my server to my
client using the Asynchronous RPC calls. I've noticed that for these
arrays often take quite a long period of time to transmit. I'm only
sending four sets of data, but containing several hundred (to perhaps
a thousand) points each. I'm transmitting a simple class that holds
four parallel double arrays that will be used to populate a DataTable
for a visualization (from the Google Visualization API).

I could restructure my classes and doubtless get a little speed up (by
only having one array that I am transferring), but the entire
transmission process occurs three to four times faster if I parse the
data on the server from a byte array to a string using a string
buffer, than transmit a single string across the RPC.

I've seen that I could manually code the serialing interface for the
RPC call, but, unless I can find a way to send a large blob of data
and escape the arrays, I don't think that will speed up the process
too much.

I been looking into the JSON queries, but am not sure how much faster
they could be since it seems the point of that is to transmit a long
string across as well. As I understand it, the parsing would be faster
because JavaScript natively reads it.

Finally, I've glanced over HTTP requests, but I'm not sure about speed
gains there either, and I don't want to have to entirely retool my
server.

My question is thus: I'm fairly inexperienced at web development and
these sorts of client/server interactions. What would be the best way
to encode this data for quick transmission to the client?

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: Auto refresh data grid after x seconds

2011-07-21 Thread Daniel Peterson
You might try setting all your data into Labels and keeping the
references to the labels in a vector, arraylist, map, whatever.

Attach the labels to the grid using the setWidget method. Updating the
labels you have stored will update the grid entries.

I've done that with a FlexTable, though without the storage structure
for the labels. Hope this helps:

public class OverviewPanel extends Composite {

private FlexTable table;

private Label valFlow;
private Label valPower;
private Label valSource;
private Label valTarget;

public OverviewPanel(double flow, double power, doube source, double
target) {

overviewPanel = new HorizontalPanel();
overviewPanel.setStyleName(gwt-sb-label-no-bkgd);
overviewPanel.setWidth(600px);
initWidget(overviewPanel);

table = new FlexTable();
table.setCellSpacing(5);
overviewPanel.add(table);

valFlow = addDataSet(Flow:, gal, flow, 0, 0);
valPower = addDataSet(Power:, kW, power, 0, 4);
valSource = addDataSet(Source:, ft, source, 0, 6);
valTarget = addDataSet(Target:, ft, target, 0, 8);
}

public void updateData(double flow, double power, double source,
double target) {

valPower.setText(power.value);
valFlow.setText(flow.);
valSource.setText(source);
valTarget.setText(target);
}

public void add(Widget widget) {
overviewPanel.add(widget);
}

private Label addDataSet(String name, String units, double value, int
row, int startColumn) {
Label nameLabel = new Label(name);
table.setWidget(row, startColumn, nameLabel);

nameLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);

Label value = new Label(Double.toString(value));

value.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
value.setStyleName(gwt-sb-tag-value);
value.setWidth(50px);
table.setWidget(row, startColumn + 1, value);

Label unitsLabel = new Label(units);
table.setWidget(row, startColumn + 2, unitsLabel);

return value;
}
}

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.