diff options
author | Damien F. Katz <damien@apache.org> | 2008-04-07 19:51:17 +0000 |
---|---|---|
committer | Damien F. Katz <damien@apache.org> | 2008-04-07 19:51:17 +0000 |
commit | 9c27e4d7db0e2e6a1b458f8545f584fcfaea4ef2 (patch) | |
tree | 94cf96af696ab3042d2afd1f4e4e7d83a98b1568 /share/www | |
parent | 4708e70c612a797b5d15774149ed589996d0c2e3 (diff) |
Compaction. Works, but still needs queueing and better handling for long reads/writes overlapping the compaction switchover.
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@645661 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www')
-rw-r--r-- | share/www/script/couch.js | 11 | ||||
-rw-r--r-- | share/www/script/couch_tests.js | 27 |
2 files changed, 37 insertions, 1 deletions
diff --git a/share/www/script/couch.js b/share/www/script/couch.js index 9815882a..f1544893 100644 --- a/share/www/script/couch.js +++ b/share/www/script/couch.js @@ -87,6 +87,9 @@ function CouchDB(name) { var result = JSON.parse(req.responseText); if (req.status != 201) throw result; + for(i in docs) { + docs[i]._rev = result.new_revs[i].rev; + } return result; } @@ -130,6 +133,14 @@ function CouchDB(name) { throw result; return result; } + + this.compact = function() { + var req = request("POST", this.uri + "_compact"); + var result = JSON.parse(req.responseText); + if (req.status != 202) + throw result; + return result; + } // Convert a options object to an url query string. // ex: {key:'value',key2:'value2'} becomes '?key="value"&key2="value2"' diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js index 986a90b2..70879479 100644 --- a/share/www/script/couch_tests.js +++ b/share/www/script/couch_tests.js @@ -839,8 +839,33 @@ var tests = { headers: {"if-match": etag} }); T(xhr.status == 202) - } + }, + compact: function(debug) { + var db = new CouchDB("test_suite_db"); + db.deleteDb(); + db.createDb(); + if (debug) debugger; + var docs = makeDocs(0, 10); + var saveResult = db.bulkSave(docs); + T(saveResult.ok); + var originalsize = db.info().disk_size; + + for(var i in docs) { + db.deleteDoc(docs[i]); + } + var deletesize = db.info().disk_size; + T(deletesize > originalsize); + + var xhr = CouchDB.request("POST", "/test_suite_db/_compact"); + T(xhr.status == 202); + //compaction isn't instantaneous, loop until done + while(db.info().compact_running) {}; + + var compactedsize = db.info().disk_size; + + T(deletesize > originalsize); + } }; function makeDocs(start, end, templateDoc) { |