[jboss-cvs] JBossCache/src/org/jboss/cache ...
Manik Surtani
msurtani at jboss.com
Wed Dec 13 11:01:47 EST 2006
User: msurtani
Date: 06/12/13 11:01:47
Modified: src/org/jboss/cache Tag: Branch_JBossCache_1_4_0
TreeCache.java Node.java
Log:
optimisations on casting nodes.
Revision Changes Path
No revision
No revision
1.195.2.34 +19 -23 JBossCache/src/org/jboss/cache/TreeCache.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TreeCache.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/TreeCache.java,v
retrieving revision 1.195.2.33
retrieving revision 1.195.2.34
diff -u -b -r1.195.2.33 -r1.195.2.34
--- TreeCache.java 10 Dec 2006 16:42:56 -0000 1.195.2.33
+++ TreeCache.java 13 Dec 2006 16:01:47 -0000 1.195.2.34
@@ -99,7 +99,7 @@
* @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
* @author Brian Stansberry
* @author Daniel Huang (dhuang at jboss.org)
- * @version $Id: TreeCache.java,v 1.195.2.33 2006/12/10 16:42:56 msurtani Exp $
+ * @version $Id: TreeCache.java,v 1.195.2.34 2006/12/13 16:01:47 msurtani Exp $
* <p/>
* @see <a href="http://labs.jboss.com/portal/jbosscache/docs">JBossCache doc</a>
*/
@@ -3467,7 +3467,7 @@
*/
public Node _get(Fqn fqn) throws CacheException
{
- return (Node) findNode(fqn);
+ return findNode(fqn);
}
/**
@@ -3623,9 +3623,9 @@
*
* @param fqn
*/
- private DataNode findInternal(Fqn fqn, boolean includeNodesMarkedAsRemoved)
+ private Node findInternal(Fqn fqn, boolean includeNodesMarkedAsRemoved)
{
- if (fqn == null || fqn.size() == 0) return root;
+ if (fqn == null || fqn.size() == 0) return (Node) root;
TreeNode n = root;
int fqnSize = fqn.size();
for (int i = 0; i < fqnSize; i++)
@@ -3637,7 +3637,7 @@
else if (!includeNodesMarkedAsRemoved && isMarkedForRemoval(n))
return null;
}
- return (DataNode) n;
+ return (Node) n;
}
@@ -4153,36 +4153,36 @@
return count;
}
- private void markForRemoval(TreeNode n)
+ private void markForRemoval(Node n)
{
n.put(REMOVAL_MARKER, null);
// mark children as well.
- Map children = n.getChildren();
+ Map children = n.getChildren(true);
if (children != null && !children.isEmpty())
{
// traverse children
Iterator i = children.values().iterator();
while (i.hasNext())
{
- markForRemoval((TreeNode) i.next());
+ markForRemoval((Node) i.next());
}
}
}
- public void scrubRemoveMarker(TreeNode n, boolean deep)
+ public void scrubRemoveMarker(Node n, boolean deep)
{
n.remove(REMOVAL_MARKER);
// unmark children as well.
if (deep)
{
- Map children = n.getChildren();
+ Map children = n.getChildren(true);
if (children != null && !children.isEmpty())
{
// traverse children
Iterator i = children.values().iterator();
while (i.hasNext())
{
- scrubRemoveMarker((TreeNode) i.next(), true);
+ scrubRemoveMarker((Node) i.next(), true);
}
}
}
@@ -4199,7 +4199,7 @@
*/
public void realRemove(Fqn f, boolean skipMarkerCheck)
{
- DataNode n = findInternal(f, true);
+ Node n = findInternal(f, true);
if (n == null)
return;
@@ -4531,7 +4531,7 @@
public void _put(GlobalTransaction tx, Fqn fqn, Map data, boolean create_undo_ops, boolean erase_contents)
throws CacheException
{
- DataNode n;
+ Node n;
MethodCall undo_op = null;
Map old_data;
@@ -4606,7 +4606,7 @@
public Object _put(GlobalTransaction tx, Fqn fqn, Object key, Object value, boolean create_undo_ops)
throws CacheException
{
- DataNode n = null;
+ Node n = null;
MethodCall undo_op = null;
Object old_value = null;
@@ -4716,7 +4716,7 @@
throws CacheException
{
- DataNode n;
+ Node n;
TreeNode parent_node;
MethodCall undo_op = null;
@@ -5061,7 +5061,7 @@
}
tmp.addChild(child_name, old_node);
// make sure any deleted markers are removed from this child.
- scrubRemoveMarker(old_node, true);
+ scrubRemoveMarker((Node) old_node, true);
notifyNodeCreated(new Fqn(parent_fqn, child_name));
}
@@ -5791,7 +5791,7 @@
* @param fqn Fully qualified name for the corresponding node.
* @return DataNode
*/
- private DataNode findNode(Fqn fqn)
+ private Node findNode(Fqn fqn)
{
try
{
@@ -5807,15 +5807,11 @@
/**
* Finds a node given a fully qualified name and DataVersion.
*/
- private DataNode findNode(Fqn fqn, DataVersion version) throws CacheException
+ private Node findNode(Fqn fqn, DataVersion version) throws CacheException
{
- TreeNode n, child_node = null;
- Object child_name;
- int treeNodeSize;
-
if (fqn == null) return null;
- DataNode toReturn = findInternal(fqn, false);
+ Node toReturn = findInternal(fqn, false);
if (version != null)
{
1.38.2.3 +25 -0 JBossCache/src/org/jboss/cache/Node.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Node.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/Node.java,v
retrieving revision 1.38.2.2
retrieving revision 1.38.2.3
diff -u -b -r1.38.2.2 -r1.38.2.3
--- Node.java 27 Nov 2006 16:12:14 -0000 1.38.2.2
+++ Node.java 13 Dec 2006 16:01:47 -0000 1.38.2.3
@@ -165,6 +165,31 @@
this.lock_ = null;
}
+ public Map getChildren(boolean includeMarkedForRemoval)
+ {
+ return includeMarkedForRemoval ? children : getChildren();
+ }
+
+ public Map getChildren()
+ {
+ if (children == null) return null;
+ if (children.isEmpty()) return children;
+
+ // make sure we remove all children that are marked for removal ...
+ Map toReturn = new HashMap();
+ Iterator c = children.values().iterator();
+ while (c.hasNext())
+ {
+ Node ch = (Node) c.next();
+ if (!cache.isMarkedForRemoval(ch))
+ {
+ toReturn.put(ch.getName(), ch);
+ }
+ }
+
+ return toReturn;
+ }
+
/**
* Set the tree cache instance recursively down to the children as well.
* Note that this method is not currently thread safe.
More information about the jboss-cvs-commits
mailing list