* Reenable prefetchChildren() for grouped subnodes.
* Make Subnodelist.add()/get() type-safe by using NodeHandle instead of java.lang.Object.
This commit is contained in:
parent
d781142af1
commit
a56cdaee59
4 changed files with 39 additions and 52 deletions
|
@ -1119,7 +1119,7 @@ public final class Node implements INode, Serializable {
|
||||||
|
|
||||||
for (int i = 0; i < l; i++)
|
for (int i = 0; i < l; i++)
|
||||||
try {
|
try {
|
||||||
NodeHandle shandle = (NodeHandle) subnodes.get(i);
|
NodeHandle shandle = subnodes.get(i);
|
||||||
|
|
||||||
if (subid.equals(shandle.getID())) {
|
if (subid.equals(shandle.getID())) {
|
||||||
// System.err.println ("FOUND SUBNODE: "+shandle);
|
// System.err.println ("FOUND SUBNODE: "+shandle);
|
||||||
|
|
|
@ -1039,7 +1039,7 @@ public final class NodeManager {
|
||||||
protected List collectMissingKeys(SubnodeList list, int start, int length) {
|
protected List collectMissingKeys(SubnodeList list, int start, int length) {
|
||||||
List retval = null;
|
List retval = null;
|
||||||
for (int i = start; i < start + length; i++) {
|
for (int i = start; i < start + length; i++) {
|
||||||
NodeHandle handle = (NodeHandle) list.get(i);
|
NodeHandle handle = list.get(i);
|
||||||
if (handle != null && !cache.containsKey(handle.getKey())) {
|
if (handle != null && !cache.containsKey(handle.getKey())) {
|
||||||
if (retval == null) {
|
if (retval == null) {
|
||||||
retval = new ArrayList();
|
retval = new ArrayList();
|
||||||
|
@ -1121,18 +1121,25 @@ public final class NodeManager {
|
||||||
// group nodes.
|
// group nodes.
|
||||||
String groupName = null;
|
String groupName = null;
|
||||||
|
|
||||||
/* if (groupbyProp != null) {
|
if (groupbyProp != null) {
|
||||||
groupName = node.getString(groupbyProp);
|
groupName = node.getString(groupbyProp);
|
||||||
|
if (groupName != null) {
|
||||||
|
Node groupNode = (Node) groupbySubnodes.get(groupName);
|
||||||
|
|
||||||
SubnodeList sn = (SubnodeList) groupbySubnodes.get(groupName);
|
if (groupNode == null) {
|
||||||
|
groupNode = home.getGroupbySubnode(groupName, true);
|
||||||
|
groupbySubnodes.put(groupName, groupNode);
|
||||||
|
}
|
||||||
|
|
||||||
if (sn == null) {
|
SubnodeList subnodes = groupNode.getSubnodeList();
|
||||||
sn = new SubnodeList(safe, rel);
|
if (subnodes == null) {
|
||||||
groupbySubnodes.put(groupName, sn);
|
subnodes = groupNode.createSubnodeList();
|
||||||
|
// mark subnodes as up-to-date
|
||||||
|
subnodes.lastSubnodeFetch = subnodes.getLastSubnodeChange();
|
||||||
|
}
|
||||||
|
subnodes.add(new NodeHandle(key));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
sn.add(new NodeHandle(key));
|
|
||||||
} */
|
|
||||||
|
|
||||||
// if relation doesn't use primary key as accessName, get secondary key
|
// if relation doesn't use primary key as accessName, get secondary key
|
||||||
if (accessProp != null) {
|
if (accessProp != null) {
|
||||||
|
@ -1151,28 +1158,9 @@ public final class NodeManager {
|
||||||
// register new nodes with the cache. If an up-to-date copy
|
// register new nodes with the cache. If an up-to-date copy
|
||||||
// existed in the cache, use that.
|
// existed in the cache, use that.
|
||||||
registerNewNode(node, secondaryKey);
|
registerNewNode(node, secondaryKey);
|
||||||
|
|
||||||
fetchJoinedNodes(rs, joins, columns.length);
|
fetchJoinedNodes(rs, joins, columns.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If these are grouped nodes, build the intermediary group nodes
|
|
||||||
// with the subnod lists we created
|
|
||||||
/* if (groupbyProp != null) {
|
|
||||||
for (Iterator i = groupbySubnodes.keySet().iterator();
|
|
||||||
i.hasNext();) {
|
|
||||||
String groupname = (String) i.next();
|
|
||||||
|
|
||||||
if (groupname == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Node groupnode = home.getGroupbySubnode(groupname, true);
|
|
||||||
|
|
||||||
groupnode.setSubnodes((SubnodeList) groupbySubnodes.get(groupname));
|
|
||||||
groupnode.lastSubnodeFetch =
|
|
||||||
groupnode.getLastSubnodeChange(groupnode.dbmap.getSubnodeRelation());
|
|
||||||
}
|
|
||||||
} */
|
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
app.logError("Error in prefetchNodes()", x);
|
app.logError("Error in prefetchNodes()", x);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -33,34 +33,34 @@ public class SegmentedSubnodeList extends SubnodeList {
|
||||||
* Adds the specified object to this list performing
|
* Adds the specified object to this list performing
|
||||||
* custom ordering
|
* custom ordering
|
||||||
*
|
*
|
||||||
* @param obj element to be inserted.
|
* @param handle element to be inserted.
|
||||||
*/
|
*/
|
||||||
public synchronized boolean add(Object obj) {
|
public synchronized boolean add(NodeHandle handle) {
|
||||||
if (!hasRelationalNodes() || segments == null) {
|
if (!hasRelationalNodes() || segments == null) {
|
||||||
return super.add(obj);
|
return super.add(handle);
|
||||||
}
|
}
|
||||||
if (subnodeCount == -1) {
|
if (subnodeCount == -1) {
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
subnodeCount++;
|
subnodeCount++;
|
||||||
segments[segments.length - 1].length += 1;
|
segments[segments.length - 1].length += 1;
|
||||||
return list.add(obj);
|
return list.add(handle);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Adds the specified object to the list at the given position
|
* Adds the specified object to the list at the given position
|
||||||
* @param index the index to insert the element at
|
* @param index the index to insert the element at
|
||||||
* @param obj the object t add
|
* @param handle the object to add
|
||||||
*/
|
*/
|
||||||
public synchronized void add(int index, Object obj) {
|
public synchronized void add(int index, NodeHandle handle) {
|
||||||
if (!hasRelationalNodes() || segments == null) {
|
if (!hasRelationalNodes() || segments == null) {
|
||||||
super.add(index, obj);
|
super.add(index, handle);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (subnodeCount == -1) {
|
if (subnodeCount == -1) {
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
subnodeCount++;
|
subnodeCount++;
|
||||||
list.add(index, obj);
|
list.add(index, handle);
|
||||||
// shift segment indices by one
|
// shift segment indices by one
|
||||||
int s = getSegment(index);
|
int s = getSegment(index);
|
||||||
segments[s].length += 1;
|
segments[s].length += 1;
|
||||||
|
@ -69,7 +69,7 @@ public class SegmentedSubnodeList extends SubnodeList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object get(int index) {
|
public NodeHandle get(int index) {
|
||||||
if (!hasRelationalNodes() || segments == null) {
|
if (!hasRelationalNodes() || segments == null) {
|
||||||
return super.get(index);
|
return super.get(index);
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ public class SegmentedSubnodeList extends SubnodeList {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
loadSegment(getSegment(index), false);
|
loadSegment(getSegment(index), false);
|
||||||
return list.get(index);
|
return (NodeHandle) list.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean contains(Object object) {
|
public synchronized boolean contains(Object object) {
|
||||||
|
|
|
@ -50,30 +50,30 @@ public class SubnodeList implements Serializable {
|
||||||
* Adds the specified object to this list performing
|
* Adds the specified object to this list performing
|
||||||
* custom ordering
|
* custom ordering
|
||||||
*
|
*
|
||||||
* @param obj element to be inserted.
|
* @param handle element to be inserted.
|
||||||
*/
|
*/
|
||||||
public boolean add(Object obj) {
|
public boolean add(NodeHandle handle) {
|
||||||
return list.add(obj);
|
return list.add(handle);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Adds the specified object to the list at the given position
|
* Adds the specified object to the list at the given position
|
||||||
* @param idx the index to insert the element at
|
* @param idx the index to insert the element at
|
||||||
* @param obj the object t add
|
* @param handle the object to add
|
||||||
*/
|
*/
|
||||||
public void add(int idx, Object obj) {
|
public void add(int idx, NodeHandle handle) {
|
||||||
list.add(idx, obj);
|
list.add(idx, handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object get(int index) {
|
public NodeHandle get(int index) {
|
||||||
if (index < 0 || index >= list.size()) {
|
if (index < 0 || index >= list.size()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return list.get(index);
|
return (NodeHandle) list.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Node getNode(int index) {
|
public Node getNode(int index) {
|
||||||
Node retval = null;
|
Node retval = null;
|
||||||
NodeHandle handle = (NodeHandle) get(index);
|
NodeHandle handle = get(index);
|
||||||
|
|
||||||
if (handle != null) {
|
if (handle != null) {
|
||||||
retval = handle.getNode(node.nmgr);
|
retval = handle.getNode(node.nmgr);
|
||||||
|
@ -149,12 +149,11 @@ public class SubnodeList implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
DbMapping dbmap = getSubnodeMapping();
|
DbMapping dbmap = getSubnodeMapping();
|
||||||
Relation rel = getSubnodeRelation();
|
|
||||||
|
|
||||||
if (!dbmap.isRelational() || rel.getGroup() != null) {
|
if (dbmap.isRelational()) {
|
||||||
return;
|
Relation rel = getSubnodeRelation();
|
||||||
|
node.nmgr.prefetchNodes(node, rel, this, start, length);
|
||||||
}
|
}
|
||||||
node.nmgr.prefetchNodes(node, rel, this, start, length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue