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 2013/10/28 10:48:59 UTC
svn commit: r1536296 - in /jackrabbit/oak/trunk:
oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/
oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/
oak-doc/src/site/markdown/
Author: chetanm
Date: Mon Oct 28 09:48:58 2013
New Revision: 1536296
URL: http://svn.apache.org/r1536296
Log:
OAK-1117 - [MongoMk]Flag document with children
Minor updates
* Change the new attribute name to `_children` from `_hasChildren`
* Now the boolean flag would only be added for nodes which have child
so by default a node doc would not have this flag set
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/Commit.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/Node.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/NodeDocument.java
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/OptimizedChildFetchTest.java
jackrabbit/oak/trunk/oak-doc/src/site/markdown/mongomk.md
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/Commit.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/Commit.java?rev=1536296&r1=1536295&r2=1536296&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/Commit.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/Commit.java Mon Oct 28 09:48:58 2013
@@ -294,22 +294,22 @@ public class Commit {
//Parent node all ready part of modification list
//Update it in place
if (op.isNew()) {
- NodeDocument.setChildNodesStatus(op, true);
+ NodeDocument.setChildrenFlag(op, true);
} else {
NodeDocument nd = store.getIfCached(Collection.NODES, Utils.getIdFromPath(parentPath));
- if (nd != null && nd.hasChildNodes()) {
+ if (nd != null && nd.hasChildren()) {
continue;
}
- NodeDocument.setChildNodesStatus(op, true);
+ NodeDocument.setChildrenFlag(op, true);
}
} else {
NodeDocument nd = store.getIfCached(Collection.NODES, Utils.getIdFromPath(parentPath));
- if (nd != null && nd.hasChildNodes()) {
- //Status already set to true. Nothing to do
+ if (nd != null && nd.hasChildren()) {
+ //Flag already set to true. Nothing to do
continue;
} else {
UpdateOp updateParentOp = getUpdateOperationForNode(parentPath);
- NodeDocument.setChildNodesStatus(updateParentOp, true);
+ NodeDocument.setChildrenFlag(updateParentOp, true);
}
}
}
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/Node.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/Node.java?rev=1536296&r1=1536295&r2=1536296&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/Node.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/Node.java Mon Oct 28 09:48:58 2013
@@ -98,7 +98,6 @@ public class Node implements CacheValue
op.set(Document.ID, id);
NodeDocument.setModified(op, rev);
NodeDocument.setDeleted(op, rev, false);
- NodeDocument.setChildNodesStatus(op,false);
for (String p : properties.keySet()) {
String key = Utils.escapePropertyName(p);
op.setMapEntry(key, rev, properties.get(p));
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/NodeDocument.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/NodeDocument.java?rev=1536296&r1=1536295&r2=1536296&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/NodeDocument.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/NodeDocument.java Mon Oct 28 09:48:58 2013
@@ -131,13 +131,13 @@ public class NodeDocument extends Docume
* not necessary that there are child nodes. It just means at some moment this
* node had a child node
*/
- private static final String HAS_CHILD_NODE = "_hasChildNodes";
+ private static final String CHILDREN_FLAG = "_children";
/**
* Properties to ignore when a document is split.
*/
private static final Set<String> IGNORE_ON_SPLIT = ImmutableSet.of(ID, MOD_COUNT, MODIFIED, PREVIOUS,
- LAST_REV, HAS_CHILD_NODE);
+ LAST_REV, CHILDREN_FLAG);
final DocumentStore store;
@@ -181,8 +181,9 @@ public class NodeDocument extends Docume
/**
* @return the approximate number of children for this node.
*/
- public boolean hasChildNodes() {
- return checkNotNull((Boolean) get(HAS_CHILD_NODE)).booleanValue();
+ public boolean hasChildren() {
+ Boolean childrenFlag = (Boolean) get(CHILDREN_FLAG);
+ return childrenFlag != null ? childrenFlag.booleanValue() : false;
}
/**
@@ -406,7 +407,7 @@ public class NodeDocument extends Docume
return null;
}
String path = Utils.getPathFromId(getId());
- Node n = new Node(path, readRevision, hasChildNodes());
+ Node n = new Node(path, readRevision, hasChildren());
for (String key : keySet()) {
if (!Utils.isPropertyName(key)) {
continue;
@@ -772,9 +773,9 @@ public class NodeDocument extends Docume
//-------------------------< UpdateOp modifiers >---------------------------
- public static void setChildNodesStatus(@Nonnull UpdateOp op,
- boolean hasChildNode) {
- checkNotNull(op).set(HAS_CHILD_NODE, Boolean.valueOf(hasChildNode));
+ public static void setChildrenFlag(@Nonnull UpdateOp op,
+ boolean hasChildNode) {
+ checkNotNull(op).set(CHILDREN_FLAG, Boolean.valueOf(hasChildNode));
}
public static void setModified(@Nonnull UpdateOp op,
Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/OptimizedChildFetchTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/OptimizedChildFetchTest.java?rev=1536296&r1=1536295&r2=1536296&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/OptimizedChildFetchTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/OptimizedChildFetchTest.java Mon Oct 28 09:48:58 2013
@@ -53,9 +53,9 @@ public class OptimizedChildFetchTest ext
"+\"/root/a/b\":{}\n",
head, "");
- assertTrue(getChildStatus("/root"));
- assertTrue(getChildStatus("/root/a"));
- assertFalse(getChildStatus("/root/a/b"));
+ assertTrue(hasChildren("/root"));
+ assertTrue(hasChildren("/root/a"));
+ assertFalse(hasChildren("/root/a/b"));
}
@Test
@@ -93,9 +93,9 @@ public class OptimizedChildFetchTest ext
}
- private boolean getChildStatus(String path) {
+ private boolean hasChildren(String path) {
NodeDocument nd = mk.getDocumentStore().find(Collection.NODES, Utils.getIdFromPath(path));
- return nd.hasChildNodes();
+ return nd.hasChildren();
}
Modified: jackrabbit/oak/trunk/oak-doc/src/site/markdown/mongomk.md
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-doc/src/site/markdown/mongomk.md?rev=1536296&r1=1536295&r2=1536296&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-doc/src/site/markdown/mongomk.md (original)
+++ jackrabbit/oak/trunk/oak-doc/src/site/markdown/mongomk.md Mon Oct 28 09:48:58 2013
@@ -41,6 +41,7 @@ The basic MongoDB document of a node in
},
"_modified" : NumberLong(274208361),
"_modCount" : NumberLong(1),
+ "_children" : Boolean(true),
"_revisions" : {
"r13f3875b5d1-0-1" : "c"
}
@@ -68,10 +69,18 @@ only information actually used by MongoM
sub-document is only updated for non-branch commits or on merge, when changes
become visible to all readers.
-The `_modified` field contains an indexed low-resolution timestamp when the node was last modified. The time resolution is five seconds. This field is also updated when
-a branch commit modifies a node.
-
-The `_modCount` field contains a modification counter, which is incremented with every change to the document. This field allows MongoMK to perform conditional updates without requesting the whole document.
+The `_modified` field contains an indexed low-resolution timestamp when the node
+was last modified. The time resolution is five seconds. This field is also updated
+when a branch commit modifies a node.
+
+The `_modCount` field contains a modification counter, which is incremented with
+every change to the document. This field allows MongoMK to perform conditional updates
+without requesting the whole document.
+
+The `_children` field is a boolean flag to indicate if this node has child nodes. By
+default a node would not have this field. If any node gets added as child of this node
+then it would be set to true. It is used to optimize access to child nodes and allows MongoMK
+to omit calls to fetch child nodes for leaf nodes.
Finally, the `_revisions` sub-document contains commit information about changes
marked with a revision. E.g. the single entry in the above document tells us