Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Any efficient way to save table item(I/O) ??
Any efficient way to save table item(I/O) ?? [message #465951] Mon, 26 December 2005 02:24 Go to next message
Johnson is currently offline JohnsonFriend
Messages: 13
Registered: July 2009
Junior Member
I encountered a problem in efficieny while saving data from a tree to the
file.
The bottleneck is that there are about 12000 (600 * 20) entries in this huge
table.
And it causes lots of time in the following for loop!!

I wonder is there any way to avoid this problem?
Can I access the table line by line instead of iterating each table item?



for(int i = 0 ; i < items.length; i++}
for(int j = 0 ; j < = table.getColumnCount(); j++
content += items[i].getText(j) + " , " ;



Thanks
Re: Any efficient way to save table item(I/O) ?? [message #465952 is a reply to message #465951] Mon, 26 December 2005 03:04 Go to previous messageGo to next message
Johnson is currently offline JohnsonFriend
Messages: 13
Registered: July 2009
Junior Member
I share some different methods to save a huge table. Here are my
experiments:

1. the slowest way, about 28 seconds
for(int i = 0 ; i < items.length; i++}
for(int j = 0 ; j < = table.getColumnCount(); j++
content += items[i].getText(j) + " , " ;

2. a little bit faster, about 20 seconds
for(int i = 0 ; i < items.length; i++){
StaticText o = (StaticText)items[i].getData();
content += o.getIndex() + " , ";
content += o.getObjID() + " , ";
content += o.getWidth() + " , ";;
content += o.getHeight() + " , ";;
content += o.getX() + " , ";;
content += o.getY() + " , ";;
content += o.getIsShow() + " , ";;
content += o.getIsFillBgColor() + " , ";;
content += o.getIsUseOwnBgColor() + " , ";;
.................
}
3. the fastest way, about 5 seconds
for(int i = 0 ; i < items.length; i++){
StaticText o = (StaticText)items[i].getData();
content += o.getIndex() + " , " + o.getObjID() + " , " + o.getWidth()
+ " , "
+ o.getHeight() + " , " + o.getX() + " , " + o.getY() + " , " +
o.getIsShow() + " , "
+ o.getIsFillBgColor() + " , " + o.getIsUseOwnBgColor() + " , " +
o.getIsUseOwnTextColor() + " , "
+ o.getIsUseOwnString() + " , " + o.getIsMultiLine() + " , " +
o.getIsAutoWordwrap() + " , " + o.getOwnBgColor() + " , "
+ o.getOwnTextColor() + " , " + o.getOwnFontSizeIdx() + " , " +
o.getHoriTextAlignStyleIdx() + " , "
+ o.getVertTextAlignStyleIdx() + " , " + o.getResID() + " , " +
o.getResID();
}


It is fastest if I use getData() and one line to get whole the item.
Is there any way faster? Users would feel uncomfortable to save a table with
4 more seconds. Thanks



"Johnson" <ljshuenn@realtek.com.tw>
Re: Any efficient way to save table item(I/O) ?? [message #465955 is a reply to message #465952] Mon, 26 December 2005 07:23 Go to previous messageGo to next message
venkataramana m is currently offline venkataramana mFriend
Messages: 86
Registered: July 2009
Member
As I can infer, you are using SWT's Table directly. How about switching to JFace based API wherein the table-model abstraction could be something like this ...

class TableInputData /* name it in your interest */
{
	TableRowData[] rows;
}

class TableRowData /* name it in your interest */
{
	String column1;
	int column2;
	boolean column3;
	...
	...	
}


So as you can see now, each row can be accessed entirely with one instance of TableRowData. Also since the model classes are non-UI classes, you can afford to access these in a non-UI thread to save the table in a different thread. So that will take away the response lag from the UI thread.

Thanks
~Venkat
Re: Any efficient way to save table item(I/O) ?? [message #465963 is a reply to message #465952] Tue, 27 December 2005 05:02 Go to previous message
Johnson is currently offline JohnsonFriend
Messages: 13
Registered: July 2009
Junior Member
The problem is solved by using StringBuffer instead of String. No more than
1 second to load the data!!




"Johnson" <ljshuenn@realtek.com.tw>
Previous Topic:Table updating problems
Next Topic:Composite on TabFolder transparency
Goto Forum:
  


Current Time: Tue Sep 17 04:48:02 GMT 2019

Powered by FUDForum. Page generated in 0.02323 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top