stefan-egli commented on code in PR #1514:
URL: https://github.com/apache/jackrabbit-oak/pull/1514#discussion_r1634438449


##########
oak-run/src/main/js/oak-mongo.js:
##########
@@ -573,6 +595,201 @@ var oak = (function(global){
         }
     };
 
+    /**
+     * Prtints the sizes of all revisions by property.
+     * This is useful for large documents to quickly see which property/ies 
are affected
+     *
+     * @memberof oak
+     * @method propertySizes
+     * @param {string} path the path of a document
+     * @param {number} sizeLargerThan only show properteis larger than this, 
defaults to 1
+     */
+    api.propertySizes = function(path, sizeLargerThan) {
+        if (path === undefined) {
+            print("No path specified");
+            return;
+        }
+        if (sizeLargerThan == undefined) {
+            sizeLargerThan = 1;
+        }
+        print("loading document at " + path);
+        var doc = this.findOne(path);
+        if (!doc) {
+            print("No document for path: " + path);
+            return;
+        }
+        var overall = Object.bsonsize(doc);
+        print("overall size : " + overall);
+        var k;
+        for (k in doc) {
+            if (k == "_id") {
+                continue;
+            }
+            var hasown = doc.hasOwnProperty(k)
+            var subdoc = doc[k];
+            var thetype = Object.prototype.toString.call(subdoc);
+            var isBson = (thetype == "[object BSON]");
+            if (!isBson) {
+                //print("   (not a bson, skipping " + k + ")");
+                continue;
+            }
+            var subdocsize = Object.bsonsize(subdoc);
+            if (subdocsize <= sizeLargerThan) {
+                //print("   (too small to report " + k + ")");
+                continue;
+            }
+            print(" - property " + k + " size : " + subdocsize);
+        }
+    }
+
+    /**
+     * Prtints the count of property revisions by clusterId

Review Comment:
   should be prints



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to