Facing problem in adding Rows in TreeTableModel

This forum is used by users to request and discuss new product features. Please do not use this forum for technical support including bug reports.

Moderator: JIDE Support

Forum rules
Product suggestions only. Please do not use this forum for technical support including bug reports.

Facing problem in adding Rows in TreeTableModel

Postby Nachiyappan » Thu Dec 03, 2009 11:56 pm

Hi..

While adding more than 8000rows using addRows() & addRow() in TreeTableModel class, it takes huge time.
How to avoid this problem?

eg:
while(iterator.hasNext()){
String key = (String) iterator.next();
Object order = ordersMap.get(key);
LoggerRow row = new LoggerRow(columnList,order);
row.setKey(key);
fTableModel.addRow(row);
}

Thanks & Regards
Nachiyappan
Nachiyappan
 
Posts: 32
Joined: Tue Oct 06, 2009 9:10 pm

Re: Facing problem in adding Rows in TreeTableModel

Postby JIDE Support » Fri Dec 04, 2009 8:44 am

We did fix a performance issue in 2.7.0. Would you please give the latest release a try if you are on a release earlier than 2.7.0.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: Facing problem in adding Rows in TreeTableModel

Postby Nachiyappan » Sun Dec 06, 2009 8:49 pm

Thanks for your reply. I tried this using Jide 2.8.0 release only. Still I am facing this problem.

It took more 15mts to load 20,000 lines.
Nachiyappan
 
Posts: 32
Joined: Tue Oct 06, 2009 9:10 pm

Re: Facing problem in adding Rows in TreeTableModel

Postby Nachiyappan » Mon Dec 07, 2009 2:45 am

Hi...

1. I am creating and adding rows in main thread itself. My table have to support for more than 2lakhs rows and 200columns.
So, I would like to addrows using background thread (swing thread) to addrows in table model.
If so, can you pls let me know how to implement?


Thanks & Regards
Nachiyappan
 
Posts: 32
Joined: Tue Oct 06, 2009 9:10 pm

Re: Facing problem in adding Rows in TreeTableModel

Postby JIDE Support » Mon Dec 07, 2009 9:35 am

Thanks for bug report. We found another trick to improve performance and will fix it in 2.7.7 and 2.8.2.

To add rows in background thread, you have to make sure that it will not trigger UI update. Is it possible that you add those rows to a node first, then add that parent node to the TreeTableModel once? If so, the first step which consuming time could be put in the background thread and the next step should be put into the EDT anyway.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: Facing problem in adding Rows in TreeTableModel

Postby Nachiyappan » Tue Dec 08, 2009 7:32 am

Hi

We are facing the same performance problem in removeRow() in TreeTableModel.

We are doing R&D to use your product for our project. We are very much satisfied to use.

Since, we are planning to purchase your product, I need to complete my R&D. So, Let me know the trick to solve this problem to complete my R&D and produce the report.

Thanks & Regards
Nachiyappan.
Nachiyappan
 
Posts: 32
Joined: Tue Oct 06, 2009 9:10 pm

Re: Facing problem in adding Rows in TreeTableModel

Postby JIDE Support » Tue Dec 08, 2009 8:15 am

I cannot notice the performance issue for removeRow(). Did you ever invoke JideTable#setVariousRowHeights(true)? If so, please try comment out that line.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: Facing problem in adding Rows in TreeTableModel

Postby Nachiyappan » Tue Dec 08, 2009 8:39 pm

Thanks for your reply.

I tried to remove 2,000 rows using removeRow() by iterating them. That time, I am facing performance issue.

Is there any method like removeAllRows() or a way to remove 2,000 rows at a strach without performance problem.

Thanks
Nachiyappan
Nachiyappan
 
Posts: 32
Joined: Tue Oct 06, 2009 9:10 pm

Re: Facing problem in adding Rows in TreeTableModel

Postby JIDE Support » Tue Dec 08, 2009 10:12 pm

I couldn't see the issue by testing more than 30,000 rows. Can you please send us a test case to demonstrate the issue? I don't think removeRows() will help much because we have to iterate the row internally considering the potential complex hierarchy.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: Facing problem in adding Rows in TreeTableModel

Postby Nachiyappan » Wed Dec 09, 2009 12:01 am

Hi...

Scenario:
1. Just I have removed all the rows from the table.
2. Again add some of the row in the same table.

Please try the above case and let me know. If you didnt face any performance problem. Kindly let me know logic / code.
Nachiyappan
 
Posts: 32
Joined: Tue Oct 06, 2009 9:10 pm

Re: Facing problem in adding Rows in TreeTableModel

Postby Walter Laan » Wed Dec 09, 2009 2:35 am

Since I recently test for GroupTableModel (which is-a TreeTableModel), I made test case for the remove case:
-AbstractExpandable#removeAllChildren is slow because children.removeAll(new ArrayList(childen)) doesn't scale and in the removeAll case it is not necessary.
-removeRow also suffers from list#remove(Object), but can't be solved as generically. My implementation can access the children by index and as a result is faster by removing all rows and then setting the children to those that are not removed.
-removeRow iter is faster than batch because it means the children list gets smaller during the iteration (and list.remove(Object) becomes faster)

Code: Select all
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.List;

import javax.swing.*;

import com.jidesoft.grid.*;

public class TestTreeTableModel {
    public static void main(String[] args) {

        EventQueue.invokeLater(new Runnable() {
            public void run() {
                final List<Row> list = new ArrayList<Row>();
                for(int i = 0; i < 20000; i++) {
                    final int value = i;
                    list.add(new AbstractRow() {
                        @Override
                        public Object getValueAt(int columnIndex) {
                            return value;
                        }
                    });
                }
                final TreeTableModel<Row> model = new TreeTableModel<Row>() {
                    @Override
                    public int getColumnCount() {
                        return 1;
                    }
                };

                model.setOriginalRows(new ArrayList<Row>(list));

                final JLabel label = new JLabel("Row count: " + list.size());
                JFrame frame = new JFrame("Test");
                frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                frame.getContentPane().add(label, BorderLayout.PAGE_START);
                frame.getContentPane().add(new JScrollPane(new TreeTable(model)));
                JPanel buttons = new JPanel();
                buttons.add(new JButton(new AbstractAction("Reset") {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        long start = System.currentTimeMillis();
                        model.setOriginalRows(new ArrayList<Row>(list));
                        label.setText("Duration: " + (System.currentTimeMillis() - start));
                    }
                }));

                buttons.add(new JButton(new AbstractAction("Default row remove all") {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        long start = System.currentTimeMillis();
                        RootExpandableRow root = (RootExpandableRow) model.getRoot();
                        root.removeAllChildren();
                        label.setText("Duration: " + (System.currentTimeMillis() - start));
                    }
                }));

                buttons.add(new JButton(new AbstractAction("Custom row remove all") {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        long start = System.currentTimeMillis();
                        RootExpandableRow root = (RootExpandableRow) model.getRoot();
                        List<Object> children = new ArrayList<Object>(root.getChildren());
                        for (Object child : children) {
                            if (child instanceof Node) {
                                ((Node) child).setParent(null);
                            }
                        }
                        root.setChildren(new ArrayList<Row>());
                        root.notifyChildrenDeleted((List<? extends Row>) children);
                        label.setText("Duration: " + (System.currentTimeMillis() - start));
                    }
                }));

                buttons.add(new JButton(new AbstractAction("Row remove half iter") {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        long start = System.currentTimeMillis();
                        RootExpandableRow root = (RootExpandableRow) model.getRoot();
                        List<Object> children = new ArrayList<Object>(root.getChildren());
                        for (int i = 0; i < children.size(); i += 2) {
                            model.removeRow((Row) children.get(i));
                        }
                        label.setText("Duration: " + (System.currentTimeMillis() - start));
                    }
                }));

                buttons.add(new JButton(new AbstractAction("Row remove half batch") {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        long start = System.currentTimeMillis();
                        RootExpandableRow root = (RootExpandableRow) model.getRoot();
                        List<Object> children = new ArrayList<Object>(root.getChildren());
                        List<Row> remove = new ArrayList<Row>();
                        for (int i = 0; i < children.size(); i += 2) {
                            remove.add((Row) children.get(i));
                        }
                        root.removeChildren(remove);
                        label.setText("Duration: " + (System.currentTimeMillis() - start));
                    }
                }));

                buttons.add(new JButton(new AbstractAction("Custom row remove half") {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        long start = System.currentTimeMillis();
                        RootExpandableRow root = (RootExpandableRow) model.getRoot();
                        List<Row> keep = new ArrayList<Row>();
                        List<Object> children = new ArrayList<Object>(root.getChildren());
                        for (int i = 0; i < children.size(); i += 2) {
                            keep.add((Row) children.get(i));
                        }
                        for (Object child : children) {
                            if (child instanceof Node) {
                                ((Node) child).setParent(null);
                            }
                        }
                        root.setChildren(new ArrayList<Row>());
                        root.notifyChildrenDeleted((List<? extends Row>) children);
                        root.setChildren(keep);
                        root.notifyChildrenInserted(keep, 0);
                        label.setText("Duration: " + (System.currentTimeMillis() - start));
                    }
                }));

                frame.getContentPane().add(buttons, BorderLayout.PAGE_END);
                frame.pack();
                frame.setLocationRelativeTo(null);
                frame.setVisible(true);
            }
        });
    }
}
Walter Laan
 
Posts: 383
Joined: Mon May 01, 2006 12:13 am

Re: Facing problem in adding Rows in TreeTableModel

Postby JIDE Support » Wed Dec 09, 2009 11:43 am

Thanks Walter. Please Nachiyappan give Walter's custom solution a try.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: Facing problem in adding Rows in TreeTableModel

Postby JIDE Support » Wed Dec 23, 2009 8:02 am

Just so you know, performance for TreeTableModel#addRows() is improved in both 2.8.2 and 2.7.7.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am


Return to Product Suggestions

Who is online

Users browsing this forum: No registered users and 14 guests

cron