jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From meteata...@apache.org
Subject svn commit: r1445737 - /jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/prototype/MongoDocumentStoreTest.java
Date Wed, 13 Feb 2013 16:58:16 GMT
Author: meteatamel
Date: Wed Feb 13 16:58:16 2013
New Revision: 1445737

URL: http://svn.apache.org/r1445737
Log:
OAK-619 Lock-free MongoMK implementation

Added a batch insert test for comparison

Modified:
    jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/prototype/MongoDocumentStoreTest.java

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/prototype/MongoDocumentStoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/prototype/MongoDocumentStoreTest.java?rev=1445737&r1=1445736&r2=1445737&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/prototype/MongoDocumentStoreTest.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/prototype/MongoDocumentStoreTest.java
Wed Feb 13 16:58:16 2013
@@ -28,6 +28,11 @@ import org.apache.jackrabbit.mongomk.pro
 import org.junit.Ignore;
 import org.junit.Test;
 
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.DBObject;
+import com.mongodb.WriteResult;
+
 public class MongoDocumentStoreTest {
 
     private static boolean MONGO_DB = false;
@@ -106,6 +111,54 @@ public class MongoDocumentStoreTest {
 
     }
 
+    @Test
+    @Ignore
+    public void batchInsert() throws Exception {
+        if (!MONGO_DB) {
+            return;
+        }
+        doInsert(NODE_COUNT, true);
+        doInsert(NODE_COUNT, false);
+    }
+
+    private void doInsert(int n, boolean batch) throws Exception {
+        dropCollections();
+
+        DBCollection collection = MongoUtils.getConnection().getDB().getCollection("batchInsertTest");
+        DBObject index = new BasicDBObject();
+        index.put("_path", 1L);
+        DBObject options = new BasicDBObject();
+        options.put("unique", Boolean.TRUE);
+        collection.ensureIndex(index, options);
+
+        log("Inserting " + n + " batch? " + batch);
+        long start = System.currentTimeMillis();
+
+        if (batch) {
+            DBObject[] arr = new BasicDBObject[n];
+            for (int i = 0; i < n; i++) {
+                arr[i] = new BasicDBObject("_path", "/a" + i);
+            }
+            WriteResult result = collection.insert(arr);
+            if (result.getError() != null) {
+                log("Error: " + result.getError());
+            }
+        } else {
+            for (int i = 0; i < n; i++) {
+                WriteResult result = collection.insert(new BasicDBObject("_path", "/a" +
i));
+                if (result.getError() != null) {
+                    log("Error: " + result.getError());
+                }
+            }
+
+        }
+
+        long end = System.currentTimeMillis();
+        log("Done: " + (end - start) + "ms");
+
+        dropCollections();
+    }
+
     private static void log(String s) {
         if (NODE_COUNT < 100) {
             return;



Mime
View raw message