Permalink
Browse files

Removal of CouchDB revision tree support for efficiency

XDCR is broken. Otherwise ready for testing.

Change-Id: I25a929e1fc66904a455c5d49c2c1cf70f6bd00d0
Reviewed-on: http://review.couchbase.org/11220
Reviewed-by: Damien Katz <damien@couchbase.com>
Tested-by: Damien Katz <damien@couchbase.com>
  • Loading branch information...
Damien Katz
Damien Katz committed Nov 28, 2011
1 parent 5809b81 commit 5dd1d5440aa6b965bd06e9ae68231e87c5cefaee
Showing with 768 additions and 7,016 deletions.
  1. +1 −0 Makefile.am
  2. +10 −2 share/www/script/couch.js
  3. +1 −1 src/couch_set_view/src/couch_set_view_compactor.erl
  4. +1 −1 src/couch_set_view/src/couch_set_view_group.erl
  5. +6 −12 src/couch_set_view/src/couch_set_view_http.erl
  6. +1 −1 src/couch_set_view/src/couch_set_view_updater.erl
  7. +7 −8 src/couch_set_view/test/02-old-index-cleanup.t
  8. +1 −1 src/couch_set_view/test/03-db-compaction-file-leaks.t
  9. +1 −1 src/couch_set_view/test/04-group-shutdown.t
  10. +4 −5 src/couch_set_view/test/couch_set_view_test_util.erl
  11. +0 −10 src/couchdb/Makefile.am
  12. +38 −447 src/couchdb/couch_api_wrap.erl
  13. +2 −2 src/couchdb/couch_auth_cache.erl
  14. +62 −87 src/couchdb/couch_changes.erl
  15. +2 −2 src/couchdb/couch_compaction_daemon.erl
  16. +127 −873 src/couchdb/couch_db.erl
  17. +20 −57 src/couchdb/couch_db.hrl
  18. +9 −35 src/couchdb/couch_db_frontend.erl
  19. +120 −565 src/couchdb/couch_db_updater.erl
  20. +66 −450 src/couchdb/couch_doc.erl
  21. +22 −46 src/couchdb/couch_file.erl
  22. +14 −5 src/couchdb/couch_httpd.erl
  23. +60 −597 src/couchdb/couch_httpd_db.erl
  24. +2 −2 src/couchdb/couch_httpd_show.erl
  25. +0 −2 src/couchdb/couch_httpd_vhost.erl
  26. +6 −12 src/couchdb/couch_httpd_view.erl
  27. +2 −3 src/couchdb/couch_index_merger.erl
  28. +0 −175 src/couchdb/couch_internal_load_gen.erl
  29. +5 −5 src/couchdb/couch_query_servers.erl
  30. +3 −3 src/couchdb/couch_replication_manager.erl
  31. +20 −18 src/couchdb/couch_replicator.erl
  32. +1 −1 src/couchdb/couch_replicator_utils.erl
  33. +18 −114 src/couchdb/couch_replicator_worker.erl
  34. +32 −0 src/couchdb/couch_util.erl
  35. +1 −1 src/couchdb/couch_view_compactor.erl
  36. +1 −1 src/couchdb/couch_view_group.erl
  37. +9 −18 src/couchdb/couch_view_merger.erl
  38. +1 −1 src/couchdb/couch_view_updater.erl
  39. +0 −197 test/etap/001-couchbase-clobber_head.t
  40. +1 −4 test/etap/001-load.t
  41. +6 −72 test/etap/030-doc-from-json.t
  42. +7 −124 test/etap/031-doc-to-json.t
  43. +0 −88 test/etap/050-stream.t
  44. +0 −176 test/etap/060-kt-merging.t
  45. +0 −65 test/etap/061-kt-missing-leaves.t
  46. +0 −69 test/etap/062-kt-remove-leaves.t
  47. +0 −98 test/etap/063-kt-get-leaves.t
  48. +0 −46 test/etap/064-kt-counting.t
  49. +0 −42 test/etap/065-kt-stemming.t
  50. +43 −44 test/etap/073-changes.t
  51. +0 −158 test/etap/074-doc-update-conflicts.t
  52. +0 −248 test/etap/130-attachments-md5.t
  53. +0 −725 test/etap/140-attachment-comp.t
  54. +3 −3 test/etap/150-invalid-view-seq.t
  55. +0 −282 test/etap/160-vhosts.t
  56. +9 −12 test/etap/200-view-group-no-db-leaks.t
  57. +2 −2 test/etap/201-view-group-shutdown.t
  58. +2 −2 test/etap/220-compaction-daemon.t
  59. +0 −486 test/etap/240-replication-compact.t
  60. +0 −267 test/etap/241-replication-large-atts.t
  61. +0 −216 test/etap/242-replication-many-leaves.t
  62. +1 −16 test/etap/Makefile.am
  63. +13 −2 test/python/set_view/common/common.py
  64. +2 −2 test/python/set_view/erlang_views.py
  65. +0 −2 test/python/set_view/include_docs.py
  66. +0 −1 test/python/set_view/passive_partitions_update.py
  67. +1 −1 test/python/set_view/run.py
  68. +2 −2 test/python/set_view/updates.py
View
@@ -82,6 +82,7 @@ THANKS.gz: $(top_srcdir)/THANKS
-gzip -9 < $< > $@
check: dev
+ rm -fr $(top_builddir)/tmp/lib/*
$(top_builddir)/test/etap/run test/etap
cover: dev
View
@@ -72,8 +72,12 @@ function CouchDB(name, httpHeaders) {
// Deletes a document from the database
this.deleteDoc = function(doc) {
+ var rev = '';
+ if (doc._rev!==undefined) {
+ rev = "?rev=" + doc._rev;
+ }
this.last_req = this.request("DELETE", this.uri + encodeURIComponent(doc._id)
- + "?rev=" + doc._rev);
+ + rev);
CouchDB.maybeThrowError(this.last_req);
var result = JSON.parse(this.last_req.responseText);
doc._rev = result.rev; //record rev in input document
@@ -83,8 +87,12 @@ function CouchDB(name, httpHeaders) {
// Deletes an attachment from a document
this.deleteDocAttachment = function(doc, attachment_name) {
+ var rev = '';
+ if (doc._rev!==undefined) {
+ rev = "?rev=" + doc._rev;
+ }
this.last_req = this.request("DELETE", this.uri + encodeURIComponent(doc._id)
- + "/" + attachment_name + "?rev=" + doc._rev);
+ + "/" + attachment_name + rev);
CouchDB.maybeThrowError(this.last_req);
var result = JSON.parse(this.last_req.responseText);
doc._rev = result.rev; //record rev in input document
@@ -55,7 +55,7 @@ compact_group(Group, EmptyGroup, SetName) ->
IdsCount = lists:foldl(
fun({PartId, _}, Acc) ->
{ok, Db} = couch_db:open_int(?dbname(SetName, PartId), []),
- {ok, DbReduce} = couch_btree:full_reduce(Db#db.fulldocinfo_by_id_btree),
+ {ok, DbReduce} = couch_btree:full_reduce(Db#db.docinfo_by_id_btree),
ok = couch_db:close(Db),
Acc + element(1, DbReduce)
end,
@@ -812,7 +812,7 @@ sum_btree_sizes(Size1, Size2) ->
Size1 + Size2.
% maybe move to another module
-design_doc_to_set_view_group(SetName, #doc{id=Id,body={Fields}}) ->
+design_doc_to_set_view_group(SetName, #doc{id=Id,json={Fields}}) ->
Language = couch_util:get_value(<<"language">>, Fields, <<"javascript">>),
{DesignOptions} = couch_util:get_value(<<"options">>, Fields, {[]}),
{RawViews} = couch_util:get_value(<<"views">>, Fields, {[]}),
@@ -18,7 +18,7 @@
-export([make_view_fold_fun/6, finish_view_fold/4, finish_view_fold/5, view_row_obj/2]).
-export([view_etag/2, view_etag/3, make_reduce_fold_funs/5]).
-export([design_doc_view/6, parse_bool_param/1]).
--export([make_key_options/1]).
+-export([make_key_options/1,get_row_doc/6]).
-import(couch_httpd,
[send_json/2,send_json/3,send_json/4,send_method_not_allowed/2,send_chunk/2,
@@ -504,24 +504,18 @@ get_row_doc(_Kv, _SetName, _PartId, false, _UserCtx, _DocOpenOptions) ->
nil;
get_row_doc({{_Key, DocId}, {Props}}, SetName, PartId, true, UserCtx, DocOpenOptions) ->
- Rev = case couch_util:get_value(<<"_rev">>, Props) of
- undefined ->
- nil;
- Rev0 ->
- couch_doc:parse_rev(Rev0)
- end,
Id = couch_util:get_value(<<"_id">>, Props, DocId),
- open_row_doc(SetName, PartId, Id, Rev, UserCtx, DocOpenOptions);
+ open_row_doc(SetName, PartId, Id, UserCtx, DocOpenOptions);
get_row_doc({{_Key, DocId}, _Value}, SetName, PartId, true, UserCtx, DocOpenOptions) ->
- open_row_doc(SetName, PartId, DocId, nil, UserCtx, DocOpenOptions).
+ open_row_doc(SetName, PartId, DocId, UserCtx, DocOpenOptions).
-open_row_doc(SetName, PartId, Id, Rev, UserCtx, DocOptions) ->
+open_row_doc(SetName, PartId, Id, UserCtx, DocOptions) ->
{ok, Db} = couch_db:open(
?dbname(SetName, PartId), [{user_ctx, UserCtx}]),
- JsonDoc = case (catch couch_db_frontend:couch_doc_open(Db, Id, Rev, DocOptions)) of
- #doc{} = Doc ->
+ JsonDoc = case (catch couch_db_frontend:open_doc(Db, Id, DocOptions)) of
+ {ok, #doc{} = Doc} ->
couch_doc:to_json_obj(Doc, []);
_ ->
null
@@ -212,7 +212,7 @@ purge_index(#set_view_group{fd=Fd, views=Views, id_btree=IdBtree}=Group, Db, Par
load_doc(Db, PartitionId, DocInfo, MapQueue, DocOpts, IncludeDesign) ->
- #doc_info{id=DocId, high_seq=Seq, revs=[#rev_info{deleted=Deleted}|_]} = DocInfo,
+ #doc_info{id=DocId, local_seq=Seq, deleted=Deleted} = DocInfo,
case {IncludeDesign, DocId} of
{false, <<?DESIGN_DOC_PREFIX, _/binary>>} -> % we skip design docs
ok;
@@ -40,7 +40,7 @@ test() ->
couch_set_view_test_util:delete_set_dbs(test_set_name(), num_set_partitions()),
couch_set_view_test_util:create_set_dbs(test_set_name(), num_set_partitions()),
- {ok, DDocRev} = populate_set(),
+ ok = populate_set(),
GroupPid = couch_set_view:get_group_pid(test_set_name(), ddoc_id()),
query_view(num_docs(), []),
@@ -50,7 +50,7 @@ test() ->
etap:is(all_index_files(), [IndexFile], "Index file found"),
- {ok, _} = update_ddoc(DDocRev),
+ ok = update_ddoc(),
ok = timer:sleep(1000),
NewGroupPid = couch_set_view:get_group_pid(test_set_name(), ddoc_id()),
etap:isnt(NewGroupPid, GroupPid, "Got new group after ddoc update"),
@@ -132,7 +132,7 @@ populate_set() ->
]}}
]}}
]},
- {ok, DDocRev} = couch_set_view_test_util:update_ddoc(test_set_name(), DDoc),
+ ok = couch_set_view_test_util:update_ddoc(test_set_name(), DDoc),
DocList = lists:map(
fun(I) ->
{[
@@ -151,28 +151,27 @@ populate_set() ->
num_set_partitions(),
lists:seq(0, num_set_partitions() - 1),
[]),
- {ok, DDocRev}.
+ ok.
-update_ddoc(DDocRev) ->
+update_ddoc() ->
NewDDoc = {[
{<<"_id">>, ddoc_id()},
- {<<"_rev">>, DDocRev},
{<<"language">>, <<"javascript">>},
{<<"views">>, {[
{<<"test">>, {[
{<<"map">>, <<"function(doc) { emit(doc.value, null); }">>}
]}}
]}}
]},
- {ok, NewRev} = couch_set_view_test_util:update_ddoc(test_set_name(), NewDDoc),
+ ok = couch_set_view_test_util:update_ddoc(test_set_name(), NewDDoc),
ok = couch_set_view_test_util:define_set_view(
test_set_name(),
ddoc_id(),
num_set_partitions(),
lists:seq(0, num_set_partitions() - 1),
[]),
- {ok, NewRev}.
+ ok.
get_group_sig() ->
@@ -109,7 +109,7 @@ populate_set() ->
]}}
]}}
]},
- {ok, _} = couch_set_view_test_util:update_ddoc(test_set_name(), DDoc),
+ ok = couch_set_view_test_util:update_ddoc(test_set_name(), DDoc),
DocList = lists:map(
fun(I) ->
{[
@@ -130,7 +130,7 @@ populate_set() ->
]}}
]}}
]},
- {ok, _DDocRev} = couch_set_view_test_util:update_ddoc(test_set_name(), DDoc),
+ ok = couch_set_view_test_util:update_ddoc(test_set_name(), DDoc),
DocList = lists:map(
fun(I) ->
{[
@@ -122,7 +122,7 @@ populate_set_alternated(SetName, Partitions, DocList) ->
fun(DocJson, I) ->
Db = lists:nth(I + 1, Dbs),
Doc = couch_doc:from_json_obj(DocJson),
- {ok, _} = couch_db:update_doc(Db, Doc, []),
+ ok = couch_db:update_doc(Db, Doc, []),
(I + 1) rem length(Dbs)
end,
0,
@@ -133,16 +133,15 @@ populate_set_alternated(SetName, Partitions, DocList) ->
update_ddoc(SetName, DDoc) ->
DbName = iolist_to_binary([SetName, "/master"]),
{ok, Db} = couch_db:open_int(DbName, [admin_user_ctx()]),
- {ok, NewRev} = couch_db:update_doc(Db, couch_doc:from_json_obj(DDoc), []),
- ok = couch_db:close(Db),
- {ok, couch_doc:rev_to_str(NewRev)}.
+ ok = couch_db:update_doc(Db, couch_doc:from_json_obj(DDoc), []),
+ ok = couch_db:close(Db).
delete_ddoc(SetName, DDocId) ->
DbName = iolist_to_binary([SetName, "/master"]),
{ok, Db} = couch_db:open_int(DbName, [admin_user_ctx()]),
{ok, DDoc} = couch_db:open_doc(Db, DDocId, []),
- {ok, _} = couch_db:update_doc(Db, DDoc#doc{deleted = true}, []),
+ ok = couch_db:update_doc(Db, DDoc#doc{deleted = true}, []),
ok = couch_db:close(Db).
View
@@ -58,15 +58,12 @@ source_files = \
couch_httpd_auth.erl \
couch_httpd_oauth.erl \
couch_httpd_external.erl \
- couch_httpd_show.erl \
couch_httpd_view.erl \
couch_httpd_misc_handlers.erl \
couch_httpd_proxy.erl \
couch_httpd_replicator.erl \
- couch_httpd_rewrite.erl \
couch_httpd_stats_handlers.erl \
couch_httpd_vhost.erl \
- couch_key_tree.erl \
couch_log.erl \
couch_access_log.erl \
couch_native_process.erl \
@@ -86,7 +83,6 @@ source_files = \
couch_server_sup.erl \
couch_stats_aggregator.erl \
couch_stats_collector.erl \
- couch_stream.erl \
couch_task_status.erl \
couch_util.erl \
couch_uuids.erl \
@@ -97,7 +93,6 @@ source_files = \
couch_db_updater.erl \
couch_work_queue.erl \
json_stream_parse.erl \
- couch_internal_load_gen.erl \
couch_httpd_view_merger.erl \
couch_index_merger.erl \
couch_view_merger.erl \
@@ -142,14 +137,11 @@ compiled_files = \
couch_httpd_oauth.beam \
couch_httpd_proxy.beam \
couch_httpd_external.beam \
- couch_httpd_show.beam \
couch_httpd_view.beam \
couch_httpd_misc_handlers.beam \
couch_httpd_replicator.beam \
- couch_httpd_rewrite.beam \
couch_httpd_stats_handlers.beam \
couch_httpd_vhost.beam \
- couch_key_tree.beam \
couch_log.beam \
couch_access_log.beam \
couch_native_process.beam \
@@ -169,7 +161,6 @@ compiled_files = \
couch_server_sup.beam \
couch_stats_aggregator.beam \
couch_stats_collector.beam \
- couch_stream.beam \
couch_task_status.beam \
couch_util.beam \
couch_uuids.beam \
@@ -180,7 +171,6 @@ compiled_files = \
couch_db_updater.beam \
couch_work_queue.beam \
json_stream_parse.beam \
- couch_internal_load_gen.beam \
couch_httpd_view_merger.beam \
couch_index_merger.beam \
couch_view_merger.beam \
Oops, something went wrong.

0 comments on commit 5dd1d54

Please sign in to comment.