Integrated enhancement from Hengsin for FR#1659529 - Very bad performance with Tree management

This commit is contained in:
Carlos Ruiz 2007-02-14 07:02:19 +00:00
parent 12c6f4b858
commit 306a7b7578
1 changed files with 35 additions and 2 deletions

View File

@ -81,6 +81,8 @@ public class MTree extends MTree_Base
/** The tree is displayed on the Java Client (i.e. not web) */
private boolean m_clientTree = true;
private HashMap<Integer, ArrayList> m_nodeIdMap;
/** Logger */
private static CLogger s_log = CLogger.getCLogger(MTree.class);
@ -209,11 +211,13 @@ public class MTree extends MTree_Base
//closing the rowset will also close connection for oracle rowset implementation
//m_nodeRowSet.close();
m_nodeRowSet = null;
m_nodeIdMap = null;
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql.toString(), e);
m_nodeRowSet = null;
m_nodeIdMap = null;
}
// Done with loading - add remainder from buffer
@ -401,6 +405,28 @@ public class MTree extends MTree_Base
sourceTable, MRole.SQL_FULLYQUALIFIED, m_editable);
log.fine(sql);
m_nodeRowSet = DB.getRowSet (sql);
m_nodeIdMap = new HashMap<Integer, ArrayList>(50);
try
{
m_nodeRowSet.beforeFirst();
int i = 0;
while (m_nodeRowSet.next())
{
i++;
int node = m_nodeRowSet.getInt(1);
Integer nodeId = Integer.valueOf(node);
ArrayList list = m_nodeIdMap.get(nodeId);
if (list == null)
{
list = new ArrayList(5);
m_nodeIdMap.put(nodeId, list);
}
list.add(Integer.valueOf(i));
}
} catch (SQLException e)
{
log.log(Level.SEVERE, "", e);
}
} // getNodeDetails
/**
@ -417,9 +443,16 @@ public class MTree extends MTree_Base
MTreeNode retValue = null;
try
{
m_nodeRowSet.beforeFirst();
while (m_nodeRowSet.next())
//m_nodeRowSet.beforeFirst();
ArrayList nodeList = m_nodeIdMap.get(Integer.valueOf(node_ID));
int size = nodeList != null ? nodeList.size() : 0;
int i = 0;
//while (m_nodeRowSet.next())
while (i < size)
{
Integer nodeId = (Integer)nodeList.get(i);
i++;
m_nodeRowSet.absolute(nodeId.intValue());
int node = m_nodeRowSet.getInt(1);
if (node_ID != node) // search for correct one
continue;