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 da...@apache.org on 2014/07/15 12:08:19 UTC
svn commit: r1610634 - in /jackrabbit/oak/trunk:
oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/OrderedContentMirrorStoreStrategy.java
oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/OrderedIndexBaseTest.java
Author: davide
Date: Tue Jul 15 10:08:19 2014
New Revision: 1610634
URL: http://svn.apache.org/r1610634
Log:
OAK-1892 - OrderedIndexConcurrentClusterIT takes too long
gained an average 130% improvement of speed towards the 1.0 branch
version.
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/OrderedContentMirrorStoreStrategy.java
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/OrderedIndexBaseTest.java
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/OrderedContentMirrorStoreStrategy.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/OrderedContentMirrorStoreStrategy.java?rev=1610634&r1=1610633&r2=1610634&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/OrderedContentMirrorStoreStrategy.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/OrderedContentMirrorStoreStrategy.java Tue Jul 15 10:08:19 2014
@@ -1070,41 +1070,32 @@ public class OrderedContentMirrorStoreSt
* @return the next value
*/
static String getPropertyNext(@Nonnull final NodeState state, final int lane) {
- String next = "";
- PropertyState ps = state.getProperty(NEXT);
- if (ps != null) {
- if (ps.isArray()) {
- next = ps.getValue(Type.STRING, Math.min(ps.count() - 1, lane));
- } else {
- next = ps.getValue(Type.STRING);
- }
- }
- return next;
+ return getPropertyNext(new ReadOnlyBuilder(state), lane);
}
/**
* short-cut for using NodeBuilder. See {@code getNext(NodeState)}
*/
static String getPropertyNext(@Nonnull final NodeBuilder node) {
- return getPropertyNext(node.getNodeState());
+ return getPropertyNext(node, 0);
}
/**
* short-cut for using NodeBuilder. See {@code getNext(NodeState)}
*/
static String getPropertyNext(@Nonnull final NodeBuilder node, final int lane) {
- return getPropertyNext(node.getNodeState(), lane);
- }
-
- /**
- * short-cut for using ChildNodeEntry. See {@code getNext(NodeState)}
- */
- static String getPropertyNext(@Nonnull final ChildNodeEntry child) {
- return getPropertyNext(child.getNodeState());
- }
-
- static String getPropertyNext(@Nonnull final ChildNodeEntry child, int lane) {
- return getPropertyNext(child.getNodeState(), lane);
+ checkNotNull(node);
+
+ String next = "";
+ PropertyState ps = node.getProperty(NEXT);
+ if (ps != null) {
+ if (ps.isArray()) {
+ next = ps.getValue(Type.STRING, Math.min(ps.count() - 1, lane));
+ } else {
+ next = ps.getValue(Type.STRING);
+ }
+ }
+ return next;
}
/**
Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/OrderedIndexBaseTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/OrderedIndexBaseTest.java?rev=1610634&r1=1610633&r2=1610634&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/OrderedIndexBaseTest.java (original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/OrderedIndexBaseTest.java Tue Jul 15 10:08:19 2014
@@ -30,49 +30,57 @@ import org.apache.jackrabbit.oak.plugins
import org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants;
/**
- *
+ * Base class used for benchmarking insert of nodes
*/
+@SuppressWarnings("rawtypes")
public abstract class OrderedIndexBaseTest extends AbstractTest {
/**
* the number of nodes created per iteration
*/
- static final int NODES_PER_ITERATION = Integer.parseInt(System.getProperty("nodesPerIteration", "100"));
-
+ static final int NODES_PER_ITERATION = Integer.parseInt(System.getProperty("nodesPerIteration",
+ "100"));
+
/**
* number of nodes that has to be added before performing the actual test
*/
static final int PRE_ADDED_NODES = Integer.parseInt(System.getProperty("preAddedNodes", "0"));
/**
- * type of the created node
- */
- static final String NODE_TYPE = NodeTypeConstants.NT_OAK_UNSTRUCTURED;
-
- /**
- * property that will be indexed
- */
- static final String INDEXED_PROPERTY = "indexedProperty";
-
+ * type of the created node
+ */
+ static final String NODE_TYPE = NodeTypeConstants.NT_OAK_UNSTRUCTURED;
+
+ /**
+ * property that will be indexed
+ */
+ static final String INDEXED_PROPERTY = "indexedProperty";
+
/**
* size of the batch for saving
*/
- static final int BATCH_SAVING_SIZE = 1024;
-
- /**
- * node name below which creating the test data
- */
- final String DUMP_NODE = this.getClass().getSimpleName() + TEST_ID;
-
- /**
- * session used for operations throughout the test
- */
- Session session;
-
- /**
- * node under which all the test data will be filled in
- */
- Node dump;
-
+ static final int BATCH_SAVING_SIZE = Integer
+ .parseInt(System.getProperty("batchSaving", "1024"));
+
+ /**
+ * flags whether batch saving or not. Provide {@code -DbatchSaving=XYZ} where {@code XYZ} is
+ * greater than 0 to enable batch saving otherwise it will save every added nodes.
+ */
+ static final boolean BATCH_SAVING = BATCH_SAVING_SIZE > 0;
+
+ /**
+ * node name below which creating the test data
+ */
+ final String DUMP_NODE = this.getClass().getSimpleName() + TEST_ID;
+
+ /**
+ * session used for operations throughout the test
+ */
+ Session session;
+
+ /**
+ * node under which all the test data will be filled in
+ */
+ Node dump;
/**
* insert a {@code numberOfNode} random nodes in the repository
@@ -101,46 +109,47 @@ public abstract class OrderedIndexBaseTe
}
}
- /**
- * override when needed to define an index
- */
- void defineIndex() throws Exception {
- }
-
- Node defineStandardPropertyIndex(Session session) throws Exception {
- Node index = new OakIndexUtils.PropertyIndex().property(INDEXED_PROPERTY).create(session);
- if(index == null) {
- throw new RuntimeException("Error while creating the index definition. index node is null.");
- }
- if(!PropertyIndexEditorProvider.TYPE.equals(index.getProperty(IndexConstants.TYPE_PROPERTY_NAME).getString())) {
- throw new RuntimeException("The type of the index does not match the expected");
- }
- session.save();
- return index;
- }
-
- Node defineOrderedPropertyIndex(Session session) throws Exception {
- Node index = new OakIndexUtils.PropertyIndex().property(
- INDEXED_PROPERTY).create(session, OrderedIndex.TYPE);
+ /**
+ * override when needed to define an index
+ */
+ void defineIndex() throws Exception {
+ }
+
+ Node defineStandardPropertyIndex(Session session) throws Exception {
+ Node index = new OakIndexUtils.PropertyIndex().property(INDEXED_PROPERTY).create(session);
if (index == null) {
throw new RuntimeException(
- "Error while creating the index definition. index node is null.");
+ "Error while creating the index definition. index node is null.");
+ }
+ if (!PropertyIndexEditorProvider.TYPE.equals(index.getProperty(
+ IndexConstants.TYPE_PROPERTY_NAME).getString())) {
+ throw new RuntimeException("The type of the index does not match the expected");
}
- if (!OrderedIndex.TYPE.equals(index.getProperty(
- IndexConstants.TYPE_PROPERTY_NAME).getString())) {
+ session.save();
+ return index;
+ }
+
+ Node defineOrderedPropertyIndex(Session session) throws Exception {
+ Node index = new OakIndexUtils.PropertyIndex().property(INDEXED_PROPERTY).create(session,
+ OrderedIndex.TYPE);
+ if (index == null) {
throw new RuntimeException(
- "The index type does not match the expected");
+ "Error while creating the index definition. index node is null.");
+ }
+ if (!OrderedIndex.TYPE.equals(index.getProperty(IndexConstants.TYPE_PROPERTY_NAME)
+ .getString())) {
+ throw new RuntimeException("The index type does not match the expected");
}
session.save();
return index;
- }
-
+ }
+
/**
*
* @return true if you want batch saving during {@code insertRandomNodes} by
* {@code BATCH_SAVE_SIZE}
*/
boolean isBatchSaving() {
- return false;
+ return BATCH_SAVING;
}
}
\ No newline at end of file