From 01edf5460390f4fc3c5d1b7d806b6699873acc56 Mon Sep 17 00:00:00 2001 From: hns Date: Fri, 5 Nov 2004 08:04:11 +0000 Subject: [PATCH] Catch up on the promise of separating child nodes from properties: do not set node properties for child nodes with groupby or accessname set. This means that lookups for groupby/accessname nodes becomes pretty expensive for the embedded database because we have to loop through child nodes, but the overhead seems acceptable, and the embedded db is not for high performance deployment anyhow. (Eventually we can implement some kind of caching mechanism here if necessary.) --- src/helma/objectmodel/db/Node.java | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/helma/objectmodel/db/Node.java b/src/helma/objectmodel/db/Node.java index d4306b46..2b5351c2 100644 --- a/src/helma/objectmodel/db/Node.java +++ b/src/helma/objectmodel/db/Node.java @@ -924,8 +924,6 @@ public final class Node implements INode, Serializable { old.remove(); this.removeNode(old); } - - setNode(prop, node); } } } @@ -1035,7 +1033,7 @@ public final class Node implements INode, Serializable { // getting this specific child element Relation rel = dbmap.getExactPropertyRelation(name); - if (rel != null) { + if (rel != null && !rel.isPrimitive()) { return getNode(name); } @@ -1045,7 +1043,18 @@ public final class Node implements INode, Serializable { if (state != TRANSIENT && rel.otherType != null && rel.otherType.isRelational()) { return nmgr.getNode(this, name, rel); } else { - INode node = getNode(name); + // Do what we have to do: loop through subnodes and + // check if any one matches + String propname = rel.groupby != null ? "groupname" : rel.accessName; + INode node = null; + Enumeration e = getSubnodes(); + while (e.hasMoreElements()) { + Node n = (Node) e.nextElement(); + if (name.equalsIgnoreCase(n.getString(propname))) { + node = n; + break; + } + } // set DbMapping for embedded db group nodes if (node != null && rel.groupby != null) { node.setDbMapping(dbmap.getGroupbyMapping()); @@ -1198,7 +1207,11 @@ public final class Node implements INode, Serializable { node.setDbMapping(groupbyMapping); if (!relational) { - setNode(sid, node); + // if we're not transient, make new node persistable + if (state != TRANSIENT) { + node.makePersistable(); + node.checkWriteLock(); + } subnodes.add(node.getHandle()); } @@ -1950,7 +1963,6 @@ public final class Node implements INode, Serializable { } } - parent.setNode(value, this); setName(value); } }