r9891 - helma/helma/trunk/src/helma/objectmodel/db
[email protected] Mon, 14 Sep 2009 22:04:31 +0200 (CEST)
| Newsgroups | gmane.comp.java.helma.cvs |
|---|---|
| Message-ID | <20090914200431.2DCB83D0E3@mia> |
Author: hannes
Date: 2009-09-14 22:04:31 +0200 (Mon, 14 Sep 2009)
New Revision: 9891
Modified:
helma/helma/trunk/src/helma/objectmodel/db/SegmentedSubnodeList.java
Log:
Detach counting of subnodes from the size() method to exactly mirror the behaviour of SubnodeList.
Details at http://dev.helma.org/trac/helma/changeset/9891
Modified: helma/helma/trunk/src/helma/objectmodel/db/SegmentedSubnodeList.java
===================================================================
--- helma/helma/trunk/src/helma/objectmodel/db/SegmentedSubnodeList.java 2009-09-14 20:02:14 UTC (rev 9890)
+++ helma/helma/trunk/src/helma/objectmodel/db/SegmentedSubnodeList.java 2009-09-14 20:04:31 UTC (rev 9891)
@@ -15,18 +15,17 @@
public class SegmentedSubnodeList extends SubnodeList {
- transient Segment[] segments;
+ transient Segment[] segments = null;
static int SEGLENGTH = 1000;
- transient long lastSubnodeCount = 0;
- transient int subnodeCount = -1;
+ transient private int subnodeCount = -1;
/**
* Creates a new subnode list
* @param node the node we belong to
*/
public SegmentedSubnodeList(Node node) {
- super(node);
+ super(node);
}
/**
@@ -207,14 +206,17 @@
protected synchronized void update() {
if (!hasRelationalNodes()) {
+ segments = null;
super.update();
return;
}
// also reload if the type mapping has changed.
long lastChange = getLastSubnodeChange();
if (lastChange != lastSubnodeFetch) {
- float size = size();
- if (size > SEGLENGTH) {
+ // count nodes in db without fetching anything
+ subnodeCount = node.nmgr.countNodes(node, getSubnodeRelation());
+ if (subnodeCount > SEGLENGTH) {
+ float size = subnodeCount;
int nsegments = (int) Math.ceil(size / SEGLENGTH);
int remainder = (int) size % SEGLENGTH;
segments = new Segment[nsegments];
@@ -239,15 +241,6 @@
if (!hasRelationalNodes() || segments == null) {
return super.size();
}
-
- Relation rel = getSubnodeRelation();
- long lastChange = getLastSubnodeChange();
-
- if (lastChange != lastSubnodeCount || subnodeCount < 0) {
- // count nodes in db without fetching anything
- subnodeCount = node.nmgr.countNodes(node, rel);
- lastSubnodeCount = lastChange;
- }
return subnodeCount;
}