Author: mduerig
Date: Wed Mar 19 16:22:58 2014
New Revision: 1579285

URL: http://svn.apache.org/r1579285
Log:
OAK-1454: Warn on huge multi-valued properties
Add benchmark for adding multi valued properties

Added:
    
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/SetMultiPropertyTest.java
Modified:
    
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java

Modified: 
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java?rev=1579285&r1=1579284&r2=1579285&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
 Wed Mar 19 16:22:58 2014
@@ -112,6 +112,7 @@ public class BenchmarkRunner {
             GetNodeTest.withAnonymous(),
             new GetDeepNodeTest(),
             new SetPropertyTest(),
+            new SetMultiPropertyTest(),
             new SmallFileReadTest(),
             new SmallFileWriteTest(),
             new ConcurrentReadTest(),

Added: 
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/SetMultiPropertyTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/SetMultiPropertyTest.java?rev=1579285&view=auto
==============================================================================
--- 
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/SetMultiPropertyTest.java
 (added)
+++ 
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/SetMultiPropertyTest.java
 Wed Mar 19 16:22:58 2014
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.jackrabbit.oak.benchmark;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+/**
+ * Test for measuring the performance of setting a single multi valued 
property and
+ * saving the change.
+ */
+public class SetMultiPropertyTest extends AbstractTest {
+    private static final String[] VALUES = createValues(100);
+
+    private static String[] createValues(int count) {
+        String[] values = new String[count];
+        for (int k = 0; k < values.length; k++) {
+            values[k] = "value" + k;
+        }
+        return values;
+    }
+
+    private Session session;
+
+    private Node node;
+    
+    String testNodeName = "test" + TEST_ID;
+
+    @Override
+    public void beforeSuite() throws RepositoryException {
+        session = getRepository().login(getCredentials());
+        node = session.getRootNode().addNode(testNodeName, "nt:unstructured");
+        session.save();
+    }
+
+    @Override
+    public void beforeTest() throws RepositoryException {
+        node.setProperty("count", new String[0]);
+        session.save();
+    }
+
+    @Override
+    public void runTest() throws Exception {
+        for (int i = 0; i < 1000; i++) {
+            node.setProperty("count", VALUES);
+            session.save();
+        }
+    }
+
+    @Override
+    public void afterTest() throws RepositoryException {
+    }
+
+    @Override
+    public void afterSuite() throws RepositoryException {
+        session.getRootNode().getNode(testNodeName).remove();
+        session.save();
+        session.logout();
+    }
+
+}


Reply via email to