Author: manik.surtani(a)jboss.com
Date: 2008-09-23 11:23:57 -0400 (Tue, 23 Sep 2008)
New Revision: 6783
Modified:
core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java
core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java
Log:
Optimised memory footprint
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 2008-09-23
14:58:35 UTC (rev 6782)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 2008-09-23
15:23:57 UTC (rev 6783)
@@ -45,10 +45,8 @@
protected volatile InternalNode backup;
protected byte flags = 0;
- protected Fqn fqn;
protected InternalNode parent;
- protected Fqn parentFqn;
protected static enum Flags
{
@@ -66,7 +64,6 @@
{
super(node);
this.parent = parent;
- if (parent != null) parentFqn = parent.getFqn();
}
public InternalNode getInternalParent()
@@ -111,13 +108,6 @@
return false;
}
- // convenience fqn retrieval method
- protected final Fqn fqn()
- {
- if (fqn == null) fqn = getFqn();
- return fqn;
- }
-
@Override
public void markForUpdate(DataContainer container, boolean writeSkewCheck)
{
@@ -140,7 +130,7 @@
// only do stuff if there are changes.
if (isFlagSet(CHANGED))
{
- Fqn fqn = fqn();
+ Fqn fqn = getFqn();
if (trace)
log.trace("Updating node [" + fqn + "]. deleted=" +
isDeleted() + " valid=" + isValid() + " changed=" + isChanged() +
" created=" + isFlagSet(CREATED));
@@ -152,7 +142,7 @@
InternalNode parent = lookupParent(fqn, ctx, container);
parent.removeChild(fqn.getLastElement());
setValid(false, false);
- updateNode(ctx, container);
+ updateNode(fqn, ctx, container);
}
else
{
@@ -169,7 +159,7 @@
else
{
// Only content has been updated, just update refs.
- updateNode(ctx, container);
+ updateNode(fqn, ctx, container);
}
// reset internal flags and refs to backups, etc.
@@ -198,7 +188,7 @@
if (parent != null) return parent;
InternalNode retval;
- Fqn parentFqn = this.parentFqn == null ? fqn.getParent() : this.parentFqn; // use
the class-level parentFqn where possible since this will already have a hashcode
computed.
+ Fqn parentFqn = fqn.getParent();
NodeSPI parent = ctx.lookUpNode(parentFqn);
// first check if the parent is cached in the context.
if (parent != null)
@@ -222,7 +212,7 @@
* @param dataContainer data container
*/
@SuppressWarnings("unchecked")
- protected void updateNode(InvocationContext ctx, DataContainer dataContainer)
+ protected void updateNode(Fqn fqn, InvocationContext ctx, DataContainer
dataContainer)
{
// swap refs
if (!isFlagSet(CREATED)) ((NodeReference) backup).setDelegate(node);
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2008-09-23
14:58:35 UTC (rev 6782)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2008-09-23
15:23:57 UTC (rev 6783)
@@ -51,7 +51,7 @@
{
if (isFlagSet(CHANGED)) return; // already copied
- Fqn fqn = fqn();
+ Fqn fqn = getFqn();
// mark node as changed.
setFlag(CHANGED);
@@ -76,9 +76,8 @@
@Override
@SuppressWarnings("unchecked")
- protected void updateNode(InvocationContext ctx, DataContainer dataContainer)
+ protected void updateNode(Fqn fqn, InvocationContext ctx, DataContainer
dataContainer)
{
- Fqn fqn = fqn();
if (fqn.isRoot())
{
dataContainer.setRoot(node);
Show replies by date