You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by ch...@apache.org on 2016/12/06 04:42:29 UTC
svn commit: r1772831 - in /jackrabbit/oak/trunk/oak-core/src:
main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java
test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java
Author: chetanm
Date: Tue Dec 6 04:42:29 2016
New Revision: 1772831
URL: http://svn.apache.org/viewvc?rev=1772831&view=rev
Log:
OAK-5226 - Incorrect memory calculation for bundled node states
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java?rev=1772831&r1=1772830&r2=1772831&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java Tue Dec 6 04:42:29 2016
@@ -429,7 +429,7 @@ public class DocumentNodeState extends A
+ rootRevision.getMemory()
+ estimateMemoryUsage(path);
// rough approximation for properties
- for (Map.Entry<String, PropertyState> entry : properties.entrySet()) {
+ for (Map.Entry<String, PropertyState> entry : bundlingContext.getAllProperties().entrySet()) {
// name
size += estimateMemoryUsage(entry.getKey());
PropertyState propState = entry.getValue();
Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java?rev=1772831&r1=1772830&r2=1772831&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java Tue Dec 6 04:42:29 2016
@@ -74,13 +74,14 @@ import static org.apache.jackrabbit.oak.
import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
import static org.apache.jackrabbit.oak.spi.state.NodeStateUtils.getNode;
import static org.hamcrest.CoreMatchers.hasItems;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
public class DocumentBundlingTest {
@Rule
@@ -155,6 +156,31 @@ public class DocumentBundlingTest {
}
@Test
+ public void memory() throws Exception{
+ NodeBuilder builder = store.getRoot().builder();
+ NodeBuilder bundledFileNode = newNode("nt:file");
+ bundledFileNode.child("jcr:content").setProperty("jcr:data", "foo");
+ builder.child("test").setChildNode("book.jpg", bundledFileNode.getNodeState());
+
+ //Create a non bundled NodeState structure nt:File vs nt:file
+ NodeBuilder nonBundledFileNode = newNode("nt:File");
+ nonBundledFileNode.child("jcr:content").setProperty("jcr:data", "foo");
+ builder.child("test").setChildNode("book2.jpg", nonBundledFileNode.getNodeState());
+ merge(builder);
+
+ NodeState root = store.getRoot();
+ DocumentNodeState bundledFile = asDocumentState(getNode(root, "/test/book.jpg"));
+ DocumentNodeState nonBundledFile = asDocumentState(getNode(root, "/test/book2.jpg"));
+ DocumentNodeState nonBundledContent = asDocumentState(getNode(root, "/test/book2.jpg/jcr:content"));
+
+ int nonBundledMem = nonBundledFile.getMemory() + nonBundledContent.getMemory();
+ int bundledMem = bundledFile.getMemory();
+
+ assertEquals(1386, bundledMem);
+ assertThat(bundledMem, is(greaterThan(nonBundledMem)));
+ }
+
+ @Test
public void bundlorUtilsIsBundledMethods() throws Exception{
NodeBuilder builder = store.getRoot().builder();
NodeBuilder fileNode = newNode("nt:file");