couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r835193 - /couchdb/trunk/share/www/script/test/erlang_views.js
Date Thu, 12 Nov 2009 02:15:30 GMT
Author: davisp
Date: Thu Nov 12 02:15:25 2009
New Revision: 835193

URL: http://svn.apache.org/viewvc?rev=835193&view=rev
Log:
ErlView test case with a larger data set.

I'm unable to reproduce COUCHDB-567


Modified:
    couchdb/trunk/share/www/script/test/erlang_views.js

Modified: couchdb/trunk/share/www/script/test/erlang_views.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/erlang_views.js?rev=835193&r1=835192&r2=835193&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/erlang_views.js (original)
+++ couchdb/trunk/share/www/script/test/erlang_views.js Thu Nov 12 02:15:25 2009
@@ -93,5 +93,40 @@
       var xhr = CouchDB.request("GET", url);
       T(xhr.status == 200, "standard get should be 200");
       T(xhr.responseText == "head2tail");
+
+      // Larger dataset
+
+      db.deleteDb();
+      db.createDb();
+      var words = "foo bar abc def baz xxyz".split(/\s+/);
+      
+      var docs = [];
+      for(var i = 0; i < 250; i++) {
+        var body = [];
+        for(var j = 0; j < 100; j++) {
+          body.push({
+            word: words[j%words.length],
+            count: j
+          });
+        }
+        docs.push({
+          "_id": "test-" + i,
+          "words": body
+        });
+      }
+      T(db.bulkSave(docs).length, 250, "Saved big doc set.");
+      
+      var mfun = 'fun({Doc}) -> ' +
+        'Words = proplists:get_value(<<"words">>, Doc), ' +
+        'lists:foreach(fun({Word}) -> ' +
+            'WordString = proplists:get_value(<<"word">>, Word), ' + 
+            'Count = proplists:get_value(<<"count">>, Word), ' + 
+            'Emit(WordString , Count) ' +
+          'end, Words) ' +
+        'end.';
+      
+      var rfun = 'fun(Keys, Values, RR) -> length(Values) end.';
+      var results = db.query(mfun, rfun, null, null, "erlang");
+      alert(JSON.stringify(results));
     });
 };



Mime
View raw message