From 8d7a1c6c21fc253a5772350b159d6c2a273f197a Mon Sep 17 00:00:00 2001 From: "Damien F. Katz" Date: Mon, 14 Sep 2009 22:33:05 +0000 Subject: View refactoring and addition of raw collationoption. Significant performance improvements in view indexer. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@814893 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/couch_tests.js | 1 + share/www/script/test/design_docs.js | 2 +- share/www/script/test/list_views.js | 2 +- share/www/script/test/view_collation_raw.js | 123 ++++++++++++++++++++++++++++ 4 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 share/www/script/test/view_collation_raw.js (limited to 'share') diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js index e5426ade..5c1e2bc3 100644 --- a/share/www/script/couch_tests.js +++ b/share/www/script/couch_tests.js @@ -74,6 +74,7 @@ loadTest("update_documents.js"); loadTest("utf8.js"); loadTest("uuids.js"); loadTest("view_collation.js"); +loadTest("view_collation_raw.js"); loadTest("view_conflicts.js"); loadTest("view_errors.js"); loadTest("view_include_docs.js"); diff --git a/share/www/script/test/design_docs.js b/share/www/script/test/design_docs.js index 25c36424..82c186f8 100644 --- a/share/www/script/test/design_docs.js +++ b/share/www/script/test/design_docs.js @@ -55,7 +55,7 @@ function() { var vinfo = dinfo.view_index; TEquals(51, vinfo.disk_size); TEquals(false, vinfo.compact_running); - TEquals("64625dce94960fd5ca116e42aa9d011a", vinfo.signature); + TEquals("3f88e53b303e2342e49a66c538c30679", vinfo.signature); db.bulkSave(makeDocs(1, numDocs + 1)); diff --git a/share/www/script/test/list_views.js b/share/www/script/test/list_views.js index d845f926..55d34acc 100644 --- a/share/www/script/test/list_views.js +++ b/share/www/script/test/list_views.js @@ -317,7 +317,7 @@ couchTests.list_views = function(debug) { T(!(/Key: 1 /.test(xhr.responseText))); T(/Key: 2/.test(xhr.responseText)); T(/FirstKey: 2/.test(xhr.responseText)); - T(/LastKey: 11/.test(xhr.responseText)); + T(/LastKey: 7/.test(xhr.responseText)); // no multi-key fetch allowed when group=false xhr = CouchDB.request("POST", "/test_suite_db/_design/lists/_list/simpleForm/withReduce?group=false", { diff --git a/share/www/script/test/view_collation_raw.js b/share/www/script/test/view_collation_raw.js new file mode 100644 index 00000000..08f37fae --- /dev/null +++ b/share/www/script/test/view_collation_raw.js @@ -0,0 +1,123 @@ +// Licensed 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. + +couchTests.view_collation_raw = function(debug) { + var db = new CouchDB("test_suite_db", {"X-Couch-Full-Commit":"false"}); + db.deleteDb(); + db.createDb(); + if (debug) debugger; + + // NOTE, the values are already in their correct sort order. Consider this + // a specification of collation of json types. + + var values = []; + + // numbers + values.push(1); + values.push(2); + values.push(3); + values.push(4); + + values.push(false); + values.push(null); + values.push(true); + + // then object, compares each key value in the list until different. + // larger objects sort after their subset objects. + values.push({a:1}); + values.push({a:2}); + values.push({b:1}); + values.push({b:2}); + values.push({b:2, a:1}); // Member order does matter for collation. + // CouchDB preserves member order + // but doesn't require that clients will. + // (this test might fail if used with a js engine + // that doesn't preserve order) + values.push({b:2, c:2}); + + // then arrays. compared element by element until different. + // Longer arrays sort after their prefixes + values.push(["a"]); + values.push(["b"]); + values.push(["b","c"]); + values.push(["b","c", "a"]); + values.push(["b","d"]); + values.push(["b","d", "e"]); + + + // then text, case sensitive + values.push("A"); + values.push("B"); + values.push("a"); + values.push("aa"); + values.push("b"); + values.push("ba"); + values.push("bb"); + + for (var i=0; i