You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ra...@apache.org on 2011/11/09 11:07:20 UTC
[2/5] git commit: use couch_db calls instead of couch_btree
use couch_db calls instead of couch_btree
couch_changes can use the interface from couch_db to access documents,
keeping the logic of the btree storage better encapsulated.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/e41d226d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/e41d226d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/e41d226d
Branch: refs/heads/master
Commit: e41d226dca11dc8b24d6c011cc3014e6c553db42
Parents: 13f704b
Author: Randall Leeds <ra...@apache.org>
Authored: Wed Nov 9 01:31:18 2011 -0800
Committer: Randall Leeds <ra...@apache.org>
Committed: Wed Nov 9 01:42:40 2011 -0800
----------------------------------------------------------------------
src/couchdb/couch_changes.erl | 9 ++-------
1 files changed, 2 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/e41d226d/src/couchdb/couch_changes.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_changes.erl b/src/couchdb/couch_changes.erl
index 267f3d7..30f1d88 100644
--- a/src/couchdb/couch_changes.erl
+++ b/src/couchdb/couch_changes.erl
@@ -298,7 +298,7 @@ send_changes(Args, Callback, UserAcc, Db, StartSeq, Prepend, FirstRound) ->
send_changes_doc_ids(DocIds, Db, StartSeq, Dir, Fun, Acc0) ->
- Lookups = couch_btree:lookup(Db#db.fulldocinfo_by_id_btree, DocIds),
+ Lookups = couch_db:get_full_doc_infos(Db, DocIds),
FullDocInfos = lists:foldl(
fun({ok, FDI}, Acc) ->
[FDI | Acc];
@@ -310,12 +310,7 @@ send_changes_doc_ids(DocIds, Db, StartSeq, Dir, Fun, Acc0) ->
send_changes_design_docs(Db, StartSeq, Dir, Fun, Acc0) ->
- FoldFun = fun(FullDocInfo, _, Acc) ->
- {ok, [FullDocInfo | Acc]}
- end,
- KeyOpts = [{start_key, <<"_design/">>}, {end_key_gt, <<"_design0">>}],
- {ok, _, FullDocInfos} = couch_btree:fold(
- Db#db.fulldocinfo_by_id_btree, FoldFun, [], KeyOpts),
+ FullDocInfos = couch_db:get_design_docs(Db),
send_lookup_changes(FullDocInfos, StartSeq, Dir, Db, Fun, Acc0).
Re: [2/5] git commit: use couch_db calls instead of couch_btree
Posted by Randall Leeds <ra...@gmail.com>.
On Wed, Nov 9, 2011 at 11:00, Randall Leeds <ra...@gmail.com> wrote:
> On Wed, Nov 9, 2011 at 02:48, Robert Newson <rn...@apache.org> wrote:
>> Randall,
>>
>> Did we miss the chance to review this work before it landed?
>
> Yes. Sorry. I thought it was more trivial than it was. I owe it to
> Filipe for catching the mistake.
> While I changed get_design_docs not to get the body by default (I like
> this change), he's correct that it skips deleted docs and that would
> break _changes.
>
> My apologies, Bob. I've just reverted it.
>
>>
>> B.
>>
>> On 9 November 2011 10:36, Benoit Chesneau <bc...@gmail.com> wrote:
>>> On Wed, Nov 9, 2011 at 11:27 AM, Filipe David Manana
>>> <fd...@apache.org> wrote:
>>>> Randall, I have to disagree on this one.
>>>>
>>>> The reason to not call couch_db:get_design_docs/1 is to avoid reading
>>>> the body of the documents, which is not needed.
>>>>
>>>> Plus, couch_db:get_design_docs/1 skips deleted documents, which will
>>>> causes _changes rows to be skipped.
>>>>
>>>
>>> maybe couch_db:get_design_docs could take some options to handle the
>>> case. I think it's a good idea to use couch_db as abstraction to the
>>> deep level.
>>>
Open for suggestions. I left my change to not read the body
automatically in there, since I think it could do good things for
couch_mrview as is.
Some of these module dependencies will become more clear as we start
breaking up the core into more OTPieces.
Thanks for being vigilant. Sorry for getting trigger-happy.
>>> - benoit
>>>
>>
>
Re: [2/5] git commit: use couch_db calls instead of couch_btree
Posted by Filipe David Manana <fd...@apache.org>.
On Wed, Nov 9, 2011 at 7:00 PM, Randall Leeds <ra...@gmail.com> wrote:
> On Wed, Nov 9, 2011 at 02:48, Robert Newson <rn...@apache.org> wrote:
>> Randall,
>>
>> Did we miss the chance to review this work before it landed?
>
> Yes. Sorry. I thought it was more trivial than it was. I owe it to
> Filipe for catching the mistake.
> While I changed get_design_docs not to get the body by default (I like
> this change), he's correct that it skips deleted docs and that would
> break _changes.
No sweat. I noticed after getting back home that there's a subsequent
commit that change couch_db:get_design_docs/1 which makes it return
only the full_doc_info records.
Avoiding doing this directly in couch_changes is fine for me. The
intention is good. Agree with Benoit that the couch_db function could
take parameters to tell if deleted docs are to be returned or not and
opt for docs or just full_doc_infos.
thanks
>
> My apologies, Bob. I've just reverted it.
>
>>
>> B.
>>
>> On 9 November 2011 10:36, Benoit Chesneau <bc...@gmail.com> wrote:
>>> On Wed, Nov 9, 2011 at 11:27 AM, Filipe David Manana
>>> <fd...@apache.org> wrote:
>>>> Randall, I have to disagree on this one.
>>>>
>>>> The reason to not call couch_db:get_design_docs/1 is to avoid reading
>>>> the body of the documents, which is not needed.
>>>>
>>>> Plus, couch_db:get_design_docs/1 skips deleted documents, which will
>>>> causes _changes rows to be skipped.
>>>>
>>>
>>> maybe couch_db:get_design_docs could take some options to handle the
>>> case. I think it's a good idea to use couch_db as abstraction to the
>>> deep level.
>>>
>>> - benoit
>>>
>>
>
--
Filipe David Manana,
"Reasonable men adapt themselves to the world.
Unreasonable men adapt the world to themselves.
That's why all progress depends on unreasonable men."
Re: [2/5] git commit: use couch_db calls instead of couch_btree
Posted by Randall Leeds <ra...@gmail.com>.
On Wed, Nov 9, 2011 at 02:48, Robert Newson <rn...@apache.org> wrote:
> Randall,
>
> Did we miss the chance to review this work before it landed?
Yes. Sorry. I thought it was more trivial than it was. I owe it to
Filipe for catching the mistake.
While I changed get_design_docs not to get the body by default (I like
this change), he's correct that it skips deleted docs and that would
break _changes.
My apologies, Bob. I've just reverted it.
>
> B.
>
> On 9 November 2011 10:36, Benoit Chesneau <bc...@gmail.com> wrote:
>> On Wed, Nov 9, 2011 at 11:27 AM, Filipe David Manana
>> <fd...@apache.org> wrote:
>>> Randall, I have to disagree on this one.
>>>
>>> The reason to not call couch_db:get_design_docs/1 is to avoid reading
>>> the body of the documents, which is not needed.
>>>
>>> Plus, couch_db:get_design_docs/1 skips deleted documents, which will
>>> causes _changes rows to be skipped.
>>>
>>
>> maybe couch_db:get_design_docs could take some options to handle the
>> case. I think it's a good idea to use couch_db as abstraction to the
>> deep level.
>>
>> - benoit
>>
>
Re: [2/5] git commit: use couch_db calls instead of couch_btree
Posted by Robert Newson <rn...@apache.org>.
Randall,
Did we miss the chance to review this work before it landed?
B.
On 9 November 2011 10:36, Benoit Chesneau <bc...@gmail.com> wrote:
> On Wed, Nov 9, 2011 at 11:27 AM, Filipe David Manana
> <fd...@apache.org> wrote:
>> Randall, I have to disagree on this one.
>>
>> The reason to not call couch_db:get_design_docs/1 is to avoid reading
>> the body of the documents, which is not needed.
>>
>> Plus, couch_db:get_design_docs/1 skips deleted documents, which will
>> causes _changes rows to be skipped.
>>
>
> maybe couch_db:get_design_docs could take some options to handle the
> case. I think it's a good idea to use couch_db as abstraction to the
> deep level.
>
> - benoit
>
Re: [2/5] git commit: use couch_db calls instead of couch_btree
Posted by Benoit Chesneau <bc...@gmail.com>.
On Wed, Nov 9, 2011 at 11:27 AM, Filipe David Manana
<fd...@apache.org> wrote:
> Randall, I have to disagree on this one.
>
> The reason to not call couch_db:get_design_docs/1 is to avoid reading
> the body of the documents, which is not needed.
>
> Plus, couch_db:get_design_docs/1 skips deleted documents, which will
> causes _changes rows to be skipped.
>
maybe couch_db:get_design_docs could take some options to handle the
case. I think it's a good idea to use couch_db as abstraction to the
deep level.
- benoit
Re: [2/5] git commit: use couch_db calls instead of couch_btree
Posted by Filipe David Manana <fd...@apache.org>.
Randall, I have to disagree on this one.
The reason to not call couch_db:get_design_docs/1 is to avoid reading
the body of the documents, which is not needed.
Plus, couch_db:get_design_docs/1 skips deleted documents, which will
causes _changes rows to be skipped.
On Wed, Nov 9, 2011 at 10:07 AM, <ra...@apache.org> wrote:
> use couch_db calls instead of couch_btree
>
> couch_changes can use the interface from couch_db to access documents,
> keeping the logic of the btree storage better encapsulated.
>
>
> Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
> Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/e41d226d
> Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/e41d226d
> Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/e41d226d
>
> Branch: refs/heads/master
> Commit: e41d226dca11dc8b24d6c011cc3014e6c553db42
> Parents: 13f704b
> Author: Randall Leeds <ra...@apache.org>
> Authored: Wed Nov 9 01:31:18 2011 -0800
> Committer: Randall Leeds <ra...@apache.org>
> Committed: Wed Nov 9 01:42:40 2011 -0800
>
> ----------------------------------------------------------------------
> src/couchdb/couch_changes.erl | 9 ++-------
> 1 files changed, 2 insertions(+), 7 deletions(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/couchdb/blob/e41d226d/src/couchdb/couch_changes.erl
> ----------------------------------------------------------------------
> diff --git a/src/couchdb/couch_changes.erl b/src/couchdb/couch_changes.erl
> index 267f3d7..30f1d88 100644
> --- a/src/couchdb/couch_changes.erl
> +++ b/src/couchdb/couch_changes.erl
> @@ -298,7 +298,7 @@ send_changes(Args, Callback, UserAcc, Db, StartSeq, Prepend, FirstRound) ->
>
>
> send_changes_doc_ids(DocIds, Db, StartSeq, Dir, Fun, Acc0) ->
> - Lookups = couch_btree:lookup(Db#db.fulldocinfo_by_id_btree, DocIds),
> + Lookups = couch_db:get_full_doc_infos(Db, DocIds),
> FullDocInfos = lists:foldl(
> fun({ok, FDI}, Acc) ->
> [FDI | Acc];
> @@ -310,12 +310,7 @@ send_changes_doc_ids(DocIds, Db, StartSeq, Dir, Fun, Acc0) ->
>
>
> send_changes_design_docs(Db, StartSeq, Dir, Fun, Acc0) ->
> - FoldFun = fun(FullDocInfo, _, Acc) ->
> - {ok, [FullDocInfo | Acc]}
> - end,
> - KeyOpts = [{start_key, <<"_design/">>}, {end_key_gt, <<"_design0">>}],
> - {ok, _, FullDocInfos} = couch_btree:fold(
> - Db#db.fulldocinfo_by_id_btree, FoldFun, [], KeyOpts),
> + FullDocInfos = couch_db:get_design_docs(Db),
> send_lookup_changes(FullDocInfos, StartSeq, Dir, Db, Fun, Acc0).
>
>
>
>
--
Filipe David Manana,
"Reasonable men adapt themselves to the world.
Unreasonable men adapt the world to themselves.
That's why all progress depends on unreasonable men."