You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by Benoit Chesneau <bc...@gmail.com> on 2010/11/29 23:05:17 UTC

use view functions to emit changes

Hi all,

Tonight i've written t quick patch that allows the user to use map
view function to filter changes. Here is the patch :

https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad

thoughts ?

- benoît

Re: use view functions to emit changes

Posted by Benoit Chesneau <bc...@gmail.com>.
On Tue, Nov 30, 2010 at 2:30 PM, Filipe David Manana
<fd...@apache.org> wrote:
> On Tue, Nov 30, 2010 at 1:16 PM, Benoit Chesneau <bc...@gmail.com> wrote:
>> That's what we discussed the other day on irc. It doesn't do more than
>
> Not everyone is always on IRC, and when there not always paying
> attention to every conversation there :)
>
>
Thought that this sentence  "use map view function to filter changes"
and patch was enough though. I was wrong.

- benoît

Re: use view functions to emit changes

Posted by Filipe David Manana <fd...@apache.org>.
On Tue, Nov 30, 2010 at 1:16 PM, Benoit Chesneau <bc...@gmail.com> wrote:
> That's what we discussed the other day on irc. It doesn't do more than

Not everyone is always on IRC, and when there not always paying
attention to every conversation there :)


> "use map view function to filter changes  instead of duplicating the
> effort in writing a filter function that does the same, which is
> apparently done a lot. So each time a value could be emitted, a change
> is returned. The url is :
>
> http://127.0.0.1:5984/testdb/_changes?filter=_view&view=dname/viewname
>
> On other advantage is that I can also use this in an external indexer.
>
> - benoît.
>



-- 
Filipe David Manana,
fdmanana@gmail.com, fdmanana@apache.org

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."

Re: use view functions to emit changes

Posted by Jan Lehnardt <ja...@apache.org>.
On 30 Nov 2010, at 15:14, Benoit Chesneau wrote:

> On Tue, Nov 30, 2010 at 2:58 PM, Jan Lehnardt <ja...@apache.org> wrote:
>> 
>> On 30 Nov 2010, at 14:16, Benoit Chesneau wrote:
>> 
>>> On Tue, Nov 30, 2010 at 1:56 PM, Jan Lehnardt <ja...@apache.org> wrote:
>>>> Hi Benoit,
>>>> 
>>>> On 29 Nov 2010, at 23:05, Benoit Chesneau wrote:
>>>> 
>>>>> Hi all,
>>>>> 
>>>>> Tonight i've written t quick patch that allows the user to use map
>>>>> view function to filter changes. Here is the patch :
>>>>> 
>>>>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad
>>>>> 
>>>>> thoughts ?
>>>> 
>>>> Thanks for the patch, but could you explain what problem this solves,
>>>> where this is useful, how it works and what problems there might be?
>>>> 
>>>> I'd like to see some more description of what a patch does before
>>>> looking at it to see if it does what it is supposed to.
>>>> 
>>>> Cheers
>>>> Jan
>>>> --
>>>> 
>>>> 
>>> 
>>> Hi,
>>> 
>>> That's what we discussed the other day on irc.
>> 
>> All dev discussion must happen on this mailing list to count. It's
>> nice we can do some high-bandwidth exchange on IRC, but that's not
>> where we can afford to hold any important discussion because it is
>> not transparent to everybody on this list.
>> 
> 
> 
> Hmfff. Where did you see I used I used irc as an argument to describe
> what the patch do? I was just using this irc discussion as a mind
> bookmark to remember *you* the context, sorry for that.

While I remember parts of the discussion, I could do with a refresher.
And I was playing devil's advocate so others could learn about it too.

Cheers
Jan
--


Re: use view functions to emit changes

Posted by Benoit Chesneau <bc...@gmail.com>.
On Tue, Nov 30, 2010 at 2:58 PM, Jan Lehnardt <ja...@apache.org> wrote:
>
> On 30 Nov 2010, at 14:16, Benoit Chesneau wrote:
>
>> On Tue, Nov 30, 2010 at 1:56 PM, Jan Lehnardt <ja...@apache.org> wrote:
>>> Hi Benoit,
>>>
>>> On 29 Nov 2010, at 23:05, Benoit Chesneau wrote:
>>>
>>>> Hi all,
>>>>
>>>> Tonight i've written t quick patch that allows the user to use map
>>>> view function to filter changes. Here is the patch :
>>>>
>>>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad
>>>>
>>>> thoughts ?
>>>
>>> Thanks for the patch, but could you explain what problem this solves,
>>> where this is useful, how it works and what problems there might be?
>>>
>>> I'd like to see some more description of what a patch does before
>>> looking at it to see if it does what it is supposed to.
>>>
>>> Cheers
>>> Jan
>>> --
>>>
>>>
>>
>> Hi,
>>
>> That's what we discussed the other day on irc.
>
> All dev discussion must happen on this mailing list to count. It's
> nice we can do some high-bandwidth exchange on IRC, but that's not
> where we can afford to hold any important discussion because it is
> not transparent to everybody on this list.
>


Hmfff. Where did you see I used I used irc as an argument to describe
what the patch do? I was just using this irc discussion as a mind
bookmark to remember *you* the context, sorry for that.

- benoît.

"

Re: use view functions to emit changes

Posted by Jan Lehnardt <ja...@apache.org>.
On 30 Nov 2010, at 14:16, Benoit Chesneau wrote:

> On Tue, Nov 30, 2010 at 1:56 PM, Jan Lehnardt <ja...@apache.org> wrote:
>> Hi Benoit,
>> 
>> On 29 Nov 2010, at 23:05, Benoit Chesneau wrote:
>> 
>>> Hi all,
>>> 
>>> Tonight i've written t quick patch that allows the user to use map
>>> view function to filter changes. Here is the patch :
>>> 
>>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad
>>> 
>>> thoughts ?
>> 
>> Thanks for the patch, but could you explain what problem this solves,
>> where this is useful, how it works and what problems there might be?
>> 
>> I'd like to see some more description of what a patch does before
>> looking at it to see if it does what it is supposed to.
>> 
>> Cheers
>> Jan
>> --
>> 
>> 
> 
> Hi,
> 
> That's what we discussed the other day on irc.

All dev discussion must happen on this mailing list to count. It's
nice we can do some high-bandwidth exchange on IRC, but that's not
where we can afford to hold any important discussion because it is
not transparent to everybody on this list.

Cheers
Jan
-- 



> It doesn't do more than
> "use map view function to filter changes  instead of duplicating the
> effort in writing a filter function that does the same, which is
> apparently done a lot. So each time a value could be emitted, a change
> is returned. The url is :
> 
> http://127.0.0.1:5984/testdb/_changes?filter=_view&view=dname/viewname
> 
> On other advantage is that I can also use this in an external indexer.
> 
> - benoît.


Re: use view functions to emit changes

Posted by Benoit Chesneau <bc...@gmail.com>.
On Tue, Nov 30, 2010 at 1:56 PM, Jan Lehnardt <ja...@apache.org> wrote:
> Hi Benoit,
>
> On 29 Nov 2010, at 23:05, Benoit Chesneau wrote:
>
>> Hi all,
>>
>> Tonight i've written t quick patch that allows the user to use map
>> view function to filter changes. Here is the patch :
>>
>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad
>>
>> thoughts ?
>
> Thanks for the patch, but could you explain what problem this solves,
> where this is useful, how it works and what problems there might be?
>
> I'd like to see some more description of what a patch does before
> looking at it to see if it does what it is supposed to.
>
> Cheers
> Jan
> --
>
>

Hi,

That's what we discussed the other day on irc. It doesn't do more than
"use map view function to filter changes  instead of duplicating the
effort in writing a filter function that does the same, which is
apparently done a lot. So each time a value could be emitted, a change
is returned. The url is :

http://127.0.0.1:5984/testdb/_changes?filter=_view&view=dname/viewname

On other advantage is that I can also use this in an external indexer.

- benoît.

Re: use view functions to emit changes

Posted by Jan Lehnardt <ja...@apache.org>.
Hi Benoit,

On 29 Nov 2010, at 23:05, Benoit Chesneau wrote:

> Hi all,
> 
> Tonight i've written t quick patch that allows the user to use map
> view function to filter changes. Here is the patch :
> 
> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad
> 
> thoughts ?

Thanks for the patch, but could you explain what problem this solves,
where this is useful, how it works and what problems there might be?

I'd like to see some more description of what a patch does before
looking at it to see if it does what it is supposed to.

Cheers
Jan
-- 


Re: use view functions to emit changes

Posted by Benoit Chesneau <bc...@gmail.com>.
And thanks for the review anyway!

- benoît

On Tue, Nov 30, 2010 at 1:05 PM, Benoit Chesneau <bc...@gmail.com> wrote:
> On Tue, Nov 30, 2010 at 12:22 PM, Filipe David Manana
> <fd...@apache.org> wrote:
>> Hi Benoît,
>>
>> It's a good idea I think. Good work.
>> I have some comments regarding the patch:
>>
>> 1) Doing a regexp substitution of the view function's code string
>> seems like a recipe for disaster to me.
>>
>> I think the safe and clean way to go here is to create another
>> sandbox, with a different 'emit' function, and in
>> Couch.compileFunction (utils.js) pass a third and optional argument
>> which is the context in which the function is going to be executed. If
>> omitted, it uses 'sandbox' as the context, otherwise use that other
>> context. Then here:
>>
>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L0R34
>>
>> You would so something like:
>>
>> fun = Couch.compileFunction(source, filter_sandbox);
>>
>
> Indeed that's better, will make the change.
>>
>> 2) Don't forget the indentation level for .js files is 2 spaces (I'm
>> seeing a mix of 4 and 2 spaces in share/server/filter.js)
>>
>> 3) Avoid the unnecessary white-space only changes:
>>
>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L2R396
>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L2R477
>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L3R255
>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R60
>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R85
>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R247
>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R503
>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L3R191
>
>
> about 2 & 3 can we add indent rules on top of our sources from now ?
> I think there is something common between vim and emacs for example.
> That should solve such errors. I don't want to change my config each
> time I'm using a project. Using such rules solves that automatically.
>
> Ex:
>
> %% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*-
> %% ex: ts=4 sw=4 et
>
>
> works on erlang and vim and surely other editors. About the 2 spaces
> in js, imo we should go to a 4 spaces indentations, which is a way
> more readable and more common. (Mozilla uses that rule.)
>
>>
>> 4) This?LOG_INFO line is there for your debugging purposes I think
>> (should be removed):
>>
>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L3R168
>>
>>
> yup.
>

Re: use view functions to emit changes

Posted by Benoit Chesneau <bc...@gmail.com>.
On Tue, Nov 30, 2010 at 2:34 PM, Robert Newson <ro...@gmail.com> wrote:
> Am I the only one that thinks our code is already indented to 4 spaces? :)
>
not the js one ;)

- benoît

Re: use view functions to emit changes

Posted by Robert Newson <ro...@gmail.com>.
Am I the only one that thinks our code is already indented to 4 spaces? :)

B.

On Tue, Nov 30, 2010 at 1:32 PM, Benoit Chesneau <bc...@gmail.com> wrote:
> On Tue, Nov 30, 2010 at 1:50 PM, Jan Lehnardt <ja...@apache.org> wrote:
>>
>> On 30 Nov 2010, at 13:05, Benoit Chesneau wrote:
>>
>>> On Tue, Nov 30, 2010 at 12:22 PM, Filipe David Manana
>>> <fd...@apache.org> wrote:
>>>>
>>>> 3) Avoid the unnecessary white-space only changes:
>>>>
>>>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L2R396
>>>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L2R477
>>>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L3R255
>>>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R60
>>>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R85
>>>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R247
>>>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R503
>>>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L3R191
>>>
>>>
>>> about 2 & 3 can we add indent rules on top of our sources from now ?
>>> I think there is something common between vim and emacs for example.
>>> That should solve such errors. I don't want to change my config each
>>> time I'm using a project. Using such rules solves that automatically.
>>>
>>> Ex:
>>>
>>> %% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*-
>>> %% ex: ts=4 sw=4 et
>>>
>>> works on erlang and vim and surely other editors.
>>
>> a) I don't mind adding these markers they it help anyone.
>> b) My editor and git tell me about trailing whitespace.
>> c) Because of b), these markers never helped me.
>>
>>> About the 2 spaces
>>> in js, imo we should go to a 4 spaces indentations, which is a way
>>> more readable and more common. (Mozilla uses that rule.)
>>
>> We agreed on two spaces early on:
>>
>>  http://wiki.apache.org/couchdb/Coding_Standards
>>
>> Coding standards are not to find the best one, but to pick one and
>> stick to it.
>>
> Coding standard are here to make the code more easy to share *between*
> developers, this isn't just a convention. Sorry to disagree with the 2
> spaces indentation.
>
> While we are in coding standard , there is one I really think we
> should follow "http://www.erlang.se/doc/programming_rules.shtml#REF14536"
> . I think I can add for some, but need help for btree codes and view
> server, anyone can help me on that ?
>
> - benoît.
>

Re: use view functions to emit changes

Posted by Filipe David Manana <fd...@apache.org>.
Crockford, JavaScript's ChuckNorris:

http://javascript.crockford.com/code.html



On Mon, Dec 6, 2010 at 5:10 PM, Volker Mische <vo...@gmail.com> wrote:
> On 06.12.2010 18:05, Gabriel Farrell wrote:
>>
>> On Tue, Nov 30, 2010 at 8:32 AM, Benoit Chesneau<bc...@gmail.com>
>>  wrote:
>>>
>>> On Tue, Nov 30, 2010 at 1:50 PM, Jan Lehnardt<ja...@apache.org>  wrote:
>>>>
>>>> On 30 Nov 2010, at 13:05, Benoit Chesneau wrote:
>>>>>
>>>>> About the 2 spaces
>>>>> in js, imo we should go to a 4 spaces indentations, which is a way
>>>>> more readable and more common. (Mozilla uses that rule.)
>>
>> The Mozilla Coding Style document recommends 2 spaces.
>> https://developer.mozilla.org/En/Developer_Guide/Coding_Style#Indentation
>>
>> Google also recommends 2-space indents.
>>
>> http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Spaces_vs._Tabs#Spaces_vs._Tabs
>>
>> Also, both jQuery and Node use 2-space indentation.
>
> jQuery uses 1-tab indentation.
>
> Cheers,
>  Volker
>



-- 
Filipe David Manana,
fdmanana@gmail.com, fdmanana@apache.org

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."

Re: use view functions to emit changes

Posted by Volker Mische <vo...@gmail.com>.
On 06.12.2010 18:05, Gabriel Farrell wrote:
> On Tue, Nov 30, 2010 at 8:32 AM, Benoit Chesneau<bc...@gmail.com>  wrote:
>> On Tue, Nov 30, 2010 at 1:50 PM, Jan Lehnardt<ja...@apache.org>  wrote:
>>> On 30 Nov 2010, at 13:05, Benoit Chesneau wrote:
>>>> About the 2 spaces
>>>> in js, imo we should go to a 4 spaces indentations, which is a way
>>>> more readable and more common. (Mozilla uses that rule.)
>
> The Mozilla Coding Style document recommends 2 spaces.
> https://developer.mozilla.org/En/Developer_Guide/Coding_Style#Indentation
>
> Google also recommends 2-space indents.
> http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Spaces_vs._Tabs#Spaces_vs._Tabs
>
> Also, both jQuery and Node use 2-space indentation.

jQuery uses 1-tab indentation.

Cheers,
   Volker

Re: use view functions to emit changes

Posted by Mikeal Rogers <mi...@gmail.com>.
The indentation thread is a little too indented :)

Re: use view functions to emit changes

Posted by Benoit Chesneau <bc...@gmail.com>.
On Mon, Dec 6, 2010 at 7:10 PM, Filipe David Manana <fd...@apache.org> wrote:
> What about moving this long indentation discussion to a separate thread?
>

I'm not sure it worth a thread, I'm pretty sure i'm the only one that
find it hard to read a 2 chars indented line ;)

- benoit

Re: use view functions to emit changes

Posted by Filipe David Manana <fd...@apache.org>.
What about moving this long indentation discussion to a separate thread?

On Mon, Dec 6, 2010 at 6:06 PM, Mikeal Rogers <mi...@gmail.com> wrote:
> 4 space is standard in a lot of language but most programmers vary style
> between languages. Python people are pretty opinionated about syntax and
> style and tend to be more resistant especially when writing JavaScript
> because the languages are so similar.
>



-- 
Filipe David Manana,
fdmanana@gmail.com, fdmanana@apache.org

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."

Re: use view functions to emit changes

Posted by Mikeal Rogers <mi...@gmail.com>.
4 space is standard in a lot of language but most programmers vary style between languages. Python people are pretty opinionated about syntax and style and tend to be more resistant especially when writing JavaScript because the languages are so similar.

Re: use view functions to emit changes

Posted by till <ti...@php.net>.
On Mon, Dec 6, 2010 at 7:04 PM, Benoit Chesneau <bc...@gmail.com> wrote:
> On Mon, Dec 6, 2010 at 6:57 PM, Mikeal Rogers <mi...@gmail.com> wrote:
>
>> But for the record, nobody except people who wish they were writing Python
>> use 4 space indentation everywhere. It's the part of crockford's style guide
>> that is most often ignored.
>>
> except maybe BSD developers, Erlang developers,etc . sure 4 spaces is
> python thing....
>
> - benoît

Or PHP, Ruby...

Re: use view functions to emit changes

Posted by Benoit Chesneau <bc...@gmail.com>.
On Mon, Dec 6, 2010 at 6:57 PM, Mikeal Rogers <mi...@gmail.com> wrote:

> But for the record, nobody except people who wish they were writing Python
> use 4 space indentation everywhere. It's the part of crockford's style guide
> that is most often ignored.
>
except maybe BSD developers, Erlang developers,etc . sure 4 spaces is
python thing....

- benoît

Re: use view functions to emit changes

Posted by Mikeal Rogers <mi...@gmail.com>.
Every style guide, and every linter, has a different notion about spacing. All of them use spaces of course but the actual indentation varies.

2 spaces is fairly standard and damn near the entire world uses it. There are other variations, like 4 spaces for multi-line var which closure-lint likes.

To be honest, js style guides are mostly pointless when this many people are working on it. It's impossible to get everyone to use the same style and the tools that validate it aren't consistent between each other.

But for the record, nobody except people who wish they were writing Python use 4 space indentation everywhere. It's the part of crockford's style guide that is most often ignored.

Re: use view functions to emit changes

Posted by Benoit Chesneau <bc...@gmail.com>.
On Mon, Dec 6, 2010 at 6:05 PM, Gabriel Farrell <gs...@gmail.com> wrote:
> On Tue, Nov 30, 2010 at 8:32 AM, Benoit Chesneau <bc...@gmail.com> wrote:
>> On Tue, Nov 30, 2010 at 1:50 PM, Jan Lehnardt <ja...@apache.org> wrote:
>>> On 30 Nov 2010, at 13:05, Benoit Chesneau wrote:
>>>> About the 2 spaces
>>>> in js, imo we should go to a 4 spaces indentations, which is a way
>>>> more readable and more common. (Mozilla uses that rule.)
>
> The Mozilla Coding Style document recommends 2 spaces.
> https://developer.mozilla.org/En/Developer_Guide/Coding_Style#Indentation
>
> Google also recommends 2-space indents.
> http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Spaces_vs._Tabs#Spaces_vs._Tabs
>

> I agree with Jan -- we should stick with those coding standards.
>
>
Mozilla don't follow it scoding standard in some projects for a reason
though. 2 spaces is a pretty bad standard when you have to read/review
code.

- benoît

Re: use view functions to emit changes

Posted by Gabriel Farrell <gs...@gmail.com>.
On Tue, Nov 30, 2010 at 8:32 AM, Benoit Chesneau <bc...@gmail.com> wrote:
> On Tue, Nov 30, 2010 at 1:50 PM, Jan Lehnardt <ja...@apache.org> wrote:
>> On 30 Nov 2010, at 13:05, Benoit Chesneau wrote:
>>> About the 2 spaces
>>> in js, imo we should go to a 4 spaces indentations, which is a way
>>> more readable and more common. (Mozilla uses that rule.)

The Mozilla Coding Style document recommends 2 spaces.
https://developer.mozilla.org/En/Developer_Guide/Coding_Style#Indentation

Google also recommends 2-space indents.
http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Spaces_vs._Tabs#Spaces_vs._Tabs

Also, both jQuery and Node use 2-space indentation.

>> We agreed on two spaces early on:
>>
>>  http://wiki.apache.org/couchdb/Coding_Standards
>>
>> Coding standards are not to find the best one, but to pick one and
>> stick to it.
>>
> Coding standard are here to make the code more easy to share *between*
> developers, this isn't just a convention. Sorry to disagree with the 2
> spaces indentation.

I agree with Jan -- we should stick with those coding standards.


Gabriel

Re: use view functions to emit changes

Posted by Benoit Chesneau <bc...@gmail.com>.
On Tue, Nov 30, 2010 at 1:50 PM, Jan Lehnardt <ja...@apache.org> wrote:
>
> On 30 Nov 2010, at 13:05, Benoit Chesneau wrote:
>
>> On Tue, Nov 30, 2010 at 12:22 PM, Filipe David Manana
>> <fd...@apache.org> wrote:
>>>
>>> 3) Avoid the unnecessary white-space only changes:
>>>
>>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L2R396
>>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L2R477
>>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L3R255
>>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R60
>>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R85
>>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R247
>>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R503
>>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L3R191
>>
>>
>> about 2 & 3 can we add indent rules on top of our sources from now ?
>> I think there is something common between vim and emacs for example.
>> That should solve such errors. I don't want to change my config each
>> time I'm using a project. Using such rules solves that automatically.
>>
>> Ex:
>>
>> %% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*-
>> %% ex: ts=4 sw=4 et
>>
>> works on erlang and vim and surely other editors.
>
> a) I don't mind adding these markers they it help anyone.
> b) My editor and git tell me about trailing whitespace.
> c) Because of b), these markers never helped me.
>
>> About the 2 spaces
>> in js, imo we should go to a 4 spaces indentations, which is a way
>> more readable and more common. (Mozilla uses that rule.)
>
> We agreed on two spaces early on:
>
>  http://wiki.apache.org/couchdb/Coding_Standards
>
> Coding standards are not to find the best one, but to pick one and
> stick to it.
>
Coding standard are here to make the code more easy to share *between*
developers, this isn't just a convention. Sorry to disagree with the 2
spaces indentation.

While we are in coding standard , there is one I really think we
should follow "http://www.erlang.se/doc/programming_rules.shtml#REF14536"
. I think I can add for some, but need help for btree codes and view
server, anyone can help me on that ?

- benoît.

Re: use view functions to emit changes

Posted by Jan Lehnardt <ja...@apache.org>.
On 30 Nov 2010, at 13:05, Benoit Chesneau wrote:

> On Tue, Nov 30, 2010 at 12:22 PM, Filipe David Manana
> <fd...@apache.org> wrote:
>> 
>> 3) Avoid the unnecessary white-space only changes:
>> 
>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L2R396
>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L2R477
>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L3R255
>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R60
>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R85
>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R247
>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R503
>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L3R191
> 
> 
> about 2 & 3 can we add indent rules on top of our sources from now ?
> I think there is something common between vim and emacs for example.
> That should solve such errors. I don't want to change my config each
> time I'm using a project. Using such rules solves that automatically.
> 
> Ex:
> 
> %% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*-
> %% ex: ts=4 sw=4 et
> 
> works on erlang and vim and surely other editors.

a) I don't mind adding these markers they it help anyone.
b) My editor and git tell me about trailing whitespace.
c) Because of b), these markers never helped me.

> About the 2 spaces
> in js, imo we should go to a 4 spaces indentations, which is a way
> more readable and more common. (Mozilla uses that rule.)

We agreed on two spaces early on:

  http://wiki.apache.org/couchdb/Coding_Standards

Coding standards are not to find the best one, but to pick one and
stick to it.

Cheers
Jan
--


Re: use view functions to emit changes

Posted by Filipe David Manana <fd...@apache.org>.
On Tue, Nov 30, 2010 at 12:22 PM, Benoit Chesneau <bc...@gmail.com> wrote:
> I don't know why "whitespaces" are introduced. One sure things is
> that's the only external code I edit where I have it, and I edit a lot
> of code.
>
> Having indentations rules force any editor to follow them (except
> weird editors like textmate, which doesen't do it without a plugin),
> which would be good. One other thing is to improve our code guidelines
> and how we follow them.

Those are strange. Specially the ones that add a single white space
before a '.' like this:
https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R60

Nevertheless, there are git flags (and for the 'path' command as well)
to give warnings (or fail) on white space only changes.

>
> - benoit.
>



-- 
Filipe David Manana,
fdmanana@gmail.com, fdmanana@apache.org

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."

Re: use view functions to emit changes

Posted by Benoit Chesneau <bc...@gmail.com>.
On Tue, Nov 30, 2010 at 1:13 PM, Filipe David Manana
<fd...@apache.org> wrote:
> On Tue, Nov 30, 2010 at 12:05 PM, Benoit Chesneau <bc...@gmail.com> wrote:
>>
>> about 2 & 3 can we add indent rules on top of our sources from now ?
>> I think there is something common between vim and emacs for example.
>> That should solve such errors. I don't want to change my config each
>> time I'm using a project. Using such rules solves that automatically.
>>
>> Ex:
>>
>> %% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*-
>> %% ex: ts=4 sw=4 et
>
> I don't mind. But that wouldn't fix 3)
>
>
>

I don't know why "whitespaces" are introduced. One sure things is
that's the only external code I edit where I have it, and I edit a lot
of code.

Having indentations rules force any editor to follow them (except
weird editors like textmate, which doesen't do it without a plugin),
which would be good. One other thing is to improve our code guidelines
and how we follow them.

- benoit.

Re: use view functions to emit changes

Posted by Filipe David Manana <fd...@apache.org>.
On Tue, Nov 30, 2010 at 12:05 PM, Benoit Chesneau <bc...@gmail.com> wrote:
>
> about 2 & 3 can we add indent rules on top of our sources from now ?
> I think there is something common between vim and emacs for example.
> That should solve such errors. I don't want to change my config each
> time I'm using a project. Using such rules solves that automatically.
>
> Ex:
>
> %% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*-
> %% ex: ts=4 sw=4 et

I don't mind. But that wouldn't fix 3)



-- 
Filipe David Manana,
fdmanana@gmail.com, fdmanana@apache.org

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."

Re: use view functions to emit changes

Posted by Benoit Chesneau <bc...@gmail.com>.
On Tue, Nov 30, 2010 at 12:22 PM, Filipe David Manana
<fd...@apache.org> wrote:
> Hi Benoît,
>
> It's a good idea I think. Good work.
> I have some comments regarding the patch:
>
> 1) Doing a regexp substitution of the view function's code string
> seems like a recipe for disaster to me.
>
> I think the safe and clean way to go here is to create another
> sandbox, with a different 'emit' function, and in
> Couch.compileFunction (utils.js) pass a third and optional argument
> which is the context in which the function is going to be executed. If
> omitted, it uses 'sandbox' as the context, otherwise use that other
> context. Then here:
>
> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L0R34
>
> You would so something like:
>
> fun = Couch.compileFunction(source, filter_sandbox);
>

Indeed that's better, will make the change.
>
> 2) Don't forget the indentation level for .js files is 2 spaces (I'm
> seeing a mix of 4 and 2 spaces in share/server/filter.js)
>
> 3) Avoid the unnecessary white-space only changes:
>
> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L2R396
> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L2R477
> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L3R255
> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R60
> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R85
> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R247
> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R503
> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L3R191


about 2 & 3 can we add indent rules on top of our sources from now ?
I think there is something common between vim and emacs for example.
That should solve such errors. I don't want to change my config each
time I'm using a project. Using such rules solves that automatically.

Ex:

%% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ts=4 sw=4 et


works on erlang and vim and surely other editors. About the 2 spaces
in js, imo we should go to a 4 spaces indentations, which is a way
more readable and more common. (Mozilla uses that rule.)

>
> 4) This?LOG_INFO line is there for your debugging purposes I think
> (should be removed):
>
> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L3R168
>
>
yup.

Re: use view functions to emit changes

Posted by Benoit Chesneau <bc...@gmail.com>.
On Tue, Dec 14, 2010 at 2:03 PM, Filipe David Manana
<fd...@apache.org> wrote:
> On Tue, Dec 14, 2010 at 12:42 PM, Benoit Chesneau <bc...@gmail.com> wrote:
>> Back on this, have been distracted by flu.
>
>>> 4) Perhaps here:
>>> https://github.com/benoitc/couchdb/compare/master...view_changes#L4R235
>>> the name of the command sent to the view server should be something
>>> like 'view_filter' instead of 'views', which to me is a bit misleading
>>
>> Well it would require more changes in loop.js. It actually looks for
>> mountpoints in the design doc to validate it. Her views is the mmember
>> of the ddoc where to find the map function. I think we should keep  it
>
> I don't understand. Why is it complex?
> You just need to change two lines:
>
> https://github.com/cmullaparthi/ibrowse/commit/3dabcaa174203ac41e9b5624a50e01fa02a17286#L0R63
>
> and
>
> https://github.com/benoitc/couchdb/compare/master...view_changes#L4R235
>
> "views" -> "filter_view"
> <<"views">> -> <<"filter_view">>
>
> I'm talking about just the name of the command sent to the view server.
>

For all (it was discussed on irc), this isn't as easy. Reason is :

https://github.com/benoitc/couchdb/blob/view_changes/share/server/loop.js#L91

Actually the point givent by the query server should be a member of
ddoc. So it will require either an alias :

if (funPath === "view_filter") { funPath = "views"; }

(suggested by fdmanana)

or more changes in loop.js .

I don't like to add this extra bit just for a naming purpose. This
isn't really required here even for debug since we know we are in ddoc
part of loop.js .
Ticket about this feature:https://issues.apache.org/jira/browse/COUCHDB-987


14:10 < fdmanana> nobody else complained, so i leave the decision to you

If others are OK I will commit it. Let me know.

- benoît

Re: use view functions to emit changes

Posted by Filipe David Manana <fd...@apache.org>.
On Tue, Dec 14, 2010 at 12:42 PM, Benoit Chesneau <bc...@gmail.com> wrote:
> Back on this, have been distracted by flu.

>> 4) Perhaps here:
>> https://github.com/benoitc/couchdb/compare/master...view_changes#L4R235
>> the name of the command sent to the view server should be something
>> like 'view_filter' instead of 'views', which to me is a bit misleading
>
> Well it would require more changes in loop.js. It actually looks for
> mountpoints in the design doc to validate it. Her views is the mmember
> of the ddoc where to find the map function. I think we should keep  it

I don't understand. Why is it complex?
You just need to change two lines:

https://github.com/cmullaparthi/ibrowse/commit/3dabcaa174203ac41e9b5624a50e01fa02a17286#L0R63

and

https://github.com/benoitc/couchdb/compare/master...view_changes#L4R235

"views" -> "filter_view"
<<"views">> -> <<"filter_view">>

I'm talking about just the name of the command sent to the view server.

> /
>
>>
>> As for 1), 2) and 3) I committed into my own branch:
>>
>> https://github.com/fdmanana/couchdb/commit/1e5498abcdc005c24961685e37359809bf3fedad
>
>
> Applied and tested on mine:
>
> https://github.com/benoitc/couchdb/tree/view_changes
>
>
> tests pass.

Great, thanks Benoit.

Btw, can you create a Jira ticket for it, attach there the patch or
point to a github link and then close it after committing. This helps
keeping track of new features/bug fixes.

>>
>> good work
>> regards,
>>
>>
> Thanks for the review again :) .
>
>
> OK for this patch ?
>
> - benoit
>



-- 
Filipe David Manana,
fdmanana@gmail.com, fdmanana@apache.org

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."

Re: use view functions to emit changes

Posted by Benoit Chesneau <bc...@gmail.com>.
Back on this, have been distracted by flu.

On Mon, Dec 6, 2010 at 1:10 PM, Filipe David Manana <fd...@apache.org> wrote:
> Sorry for the delay Benoît.
>
> Comments:
>
> 1) At https://github.com/benoitc/couchdb/compare/master...view_changes#L1R40
> you're also changing the emit of the regular sandbpox (don't forget,
> in the previous statement you're copying a reference, not a value):
> E.g.:
>
> $ ./couchjs -
> c1 = evalcx('');
> c1.foo = "bar";
> c2 = c1;
> c2.foo = "hello world";
> print("c1.foo: " + c1.foo);
> print("c2.foo: " + c2.foo);
> <EOF>
> c1.foo: hello world
> c2.foo: hello world
>
> 2) couch_changes:filter_view/4 has an unused parameter in both clauses
> (Req) - it's better to remove it?
>

Yes
> 3) The error message at
> https://github.com/benoitc/couchdb/compare/master...view_changes#L1R40
> uses single quotes. Everywhere else we use back ticks.
>
> 4) Perhaps here:
> https://github.com/benoitc/couchdb/compare/master...view_changes#L4R235
> the name of the command sent to the view server should be something
> like 'view_filter' instead of 'views', which to me is a bit misleading

Well it would require more changes in loop.js. It actually looks for
mountpoints in the design doc to validate it. Her views is the mmember
of the ddoc where to find the map function. I think we should keep  it
/

>
> As for 1), 2) and 3) I committed into my own branch:
>
> https://github.com/fdmanana/couchdb/commit/1e5498abcdc005c24961685e37359809bf3fedad


Applied and tested on mine:

https://github.com/benoitc/couchdb/tree/view_changes


tests pass.
>
> good work
> regards,
>
>
Thanks for the review again :) .


OK for this patch ?

- benoit

Re: use view functions to emit changes

Posted by Benoit Chesneau <bc...@gmail.com>.
On Mon, Dec 6, 2010 at 1:10 PM, Filipe David Manana <fd...@apache.org> wrote:
> Sorry for the delay Benoît.
>
> Comments:
>
> 1) At https://github.com/benoitc/couchdb/compare/master...view_changes#L1R40
> you're also changing the emit of the regular sandbpox (don't forget,
> in the previous statement you're copying a reference, not a value):
> E.g.:
>
> $ ./couchjs -
> c1 = evalcx('');
> c1.foo = "bar";
> c2 = c1;
> c2.foo = "hello world";
> print("c1.foo: " + c1.foo);
> print("c2.foo: " + c2.foo);
> <EOF>
> c1.foo: hello world
> c2.foo: hello world
>
> 2) couch_changes:filter_view/4 has an unused parameter in both clauses
> (Req) - it's better to remove it?
>
> 3) The error message at
> https://github.com/benoitc/couchdb/compare/master...view_changes#L1R40
> uses single quotes. Everywhere else we use back ticks.
>
> 4) Perhaps here:
> https://github.com/benoitc/couchdb/compare/master...view_changes#L4R235
> the name of the command sent to the view server should be something
> like 'view_filter' instead of 'views', which to me is a bit misleading

+1

>
> As for 1), 2) and 3) I committed into my own branch:
>
> https://github.com/fdmanana/couchdb/commit/1e5498abcdc005c24961685e37359809bf3fedad
>

k
> good work
> regards,
>
Thanks for the correction . I will post a fixed version in the morning.

best,

- benoît

Re: use view functions to emit changes

Posted by Filipe David Manana <fd...@apache.org>.
Sorry for the delay Benoît.

Comments:

1) At https://github.com/benoitc/couchdb/compare/master...view_changes#L1R40
you're also changing the emit of the regular sandbpox (don't forget,
in the previous statement you're copying a reference, not a value):
E.g.:

$ ./couchjs -
c1 = evalcx('');
c1.foo = "bar";
c2 = c1;
c2.foo = "hello world";
print("c1.foo: " + c1.foo);
print("c2.foo: " + c2.foo);
<EOF>
c1.foo: hello world
c2.foo: hello world

2) couch_changes:filter_view/4 has an unused parameter in both clauses
(Req) - it's better to remove it?

3) The error message at
https://github.com/benoitc/couchdb/compare/master...view_changes#L1R40
uses single quotes. Everywhere else we use back ticks.

4) Perhaps here:
https://github.com/benoitc/couchdb/compare/master...view_changes#L4R235
the name of the command sent to the view server should be something
like 'view_filter' instead of 'views', which to me is a bit misleading

As for 1), 2) and 3) I committed into my own branch:

https://github.com/fdmanana/couchdb/commit/1e5498abcdc005c24961685e37359809bf3fedad

good work
regards,


On Mon, Dec 6, 2010 at 8:36 AM, Benoit Chesneau <bc...@gmail.com> wrote:
> bump.
>
> On Tuesday, November 30, 2010, Benoit Chesneau <bc...@gmail.com> wrote:
>> On Tue, Nov 30, 2010 at 4:44 PM, Filipe David Manana
>> <fd...@apache.org> wrote:
>>>>
>>>> Here is an updated patch. It now use a filter sandbox instead of
>>>> patching the function and it fixes whitespaces.
>>>
>>> Why a separate function to init the filter_sandbox? It can be done at
>>> the end of the existing init_sandbox() function (perhaps renaming it
>>> to init_sandboxes).
>>>
>>> I would rename Filter.filter_view to Filter.view_filter or to
>>> Filter.map_filter (doing the same in
>>> src/couchdb/couch_query_servers.erl for naming consistency).
>>>
>>> 4) is still there (the debugging ?LOG_INFO line).
>>>
>>> Also, this patch should only contain the changes necessary to
>>> implement the new feature. While all the whitespace and indentation
>>> fixes (to comply with the wiki rules) are a welcome plus, they should
>>> come in a separate patch imo.
>>>
>> Well I used filter_view for consistency, since we use filter_docs
>> already, I don't think it need to be changed at this point. I've
>> removed the log stuff.
>>
>> Are we OK for such feature ? If yes, I will commit it.
>>
>> - benoit
>>
>



-- 
Filipe David Manana,
fdmanana@gmail.com, fdmanana@apache.org

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."

Re: use view functions to emit changes

Posted by Benoit Chesneau <bc...@gmail.com>.
bump.

On Tuesday, November 30, 2010, Benoit Chesneau <bc...@gmail.com> wrote:
> On Tue, Nov 30, 2010 at 4:44 PM, Filipe David Manana
> <fd...@apache.org> wrote:
>>>
>>> Here is an updated patch. It now use a filter sandbox instead of
>>> patching the function and it fixes whitespaces.
>>
>> Why a separate function to init the filter_sandbox? It can be done at
>> the end of the existing init_sandbox() function (perhaps renaming it
>> to init_sandboxes).
>>
>> I would rename Filter.filter_view to Filter.view_filter or to
>> Filter.map_filter (doing the same in
>> src/couchdb/couch_query_servers.erl for naming consistency).
>>
>> 4) is still there (the debugging ?LOG_INFO line).
>>
>> Also, this patch should only contain the changes necessary to
>> implement the new feature. While all the whitespace and indentation
>> fixes (to comply with the wiki rules) are a welcome plus, they should
>> come in a separate patch imo.
>>
> Well I used filter_view for consistency, since we use filter_docs
> already, I don't think it need to be changed at this point. I've
> removed the log stuff.
>
> Are we OK for such feature ? If yes, I will commit it.
>
> - benoit
>

Re: use view functions to emit changes

Posted by Benoit Chesneau <bc...@gmail.com>.
On Tue, Nov 30, 2010 at 4:44 PM, Filipe David Manana
<fd...@apache.org> wrote:
>>
>> Here is an updated patch. It now use a filter sandbox instead of
>> patching the function and it fixes whitespaces.
>
> Why a separate function to init the filter_sandbox? It can be done at
> the end of the existing init_sandbox() function (perhaps renaming it
> to init_sandboxes).
>
> I would rename Filter.filter_view to Filter.view_filter or to
> Filter.map_filter (doing the same in
> src/couchdb/couch_query_servers.erl for naming consistency).
>
> 4) is still there (the debugging ?LOG_INFO line).
>
> Also, this patch should only contain the changes necessary to
> implement the new feature. While all the whitespace and indentation
> fixes (to comply with the wiki rules) are a welcome plus, they should
> come in a separate patch imo.
>
Well I used filter_view for consistency, since we use filter_docs
already, I don't think it need to be changed at this point. I've
removed the log stuff.

Are we OK for such feature ? If yes, I will commit it.

- benoit

Re: use view functions to emit changes

Posted by Filipe David Manana <fd...@apache.org>.
>
> Here is an updated patch. It now use a filter sandbox instead of
> patching the function and it fixes whitespaces.

Why a separate function to init the filter_sandbox? It can be done at
the end of the existing init_sandbox() function (perhaps renaming it
to init_sandboxes).

I would rename Filter.filter_view to Filter.view_filter or to
Filter.map_filter (doing the same in
src/couchdb/couch_query_servers.erl for naming consistency).

4) is still there (the debugging ?LOG_INFO line).

Also, this patch should only contain the changes necessary to
implement the new feature. While all the whitespace and indentation
fixes (to comply with the wiki rules) are a welcome plus, they should
come in a separate patch imo.

good work

regards,





-- 
Filipe David Manana,
fdmanana@gmail.com, fdmanana@apache.org

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."

Re: use view functions to emit changes

Posted by Benoit Chesneau <bc...@gmail.com>.
On Tue, Nov 30, 2010 at 12:22 PM, Filipe David Manana
<fd...@apache.org> wrote:
> Hi Benoît,
>
> It's a good idea I think. Good work.
> I have some comments regarding the patch:
>
> 1) Doing a regexp substitution of the view function's code string
> seems like a recipe for disaster to me.
>
> I think the safe and clean way to go here is to create another
> sandbox, with a different 'emit' function, and in
> Couch.compileFunction (utils.js) pass a third and optional argument
> which is the context in which the function is going to be executed. If
> omitted, it uses 'sandbox' as the context, otherwise use that other
> context. Then here:
>
> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L0R34
>
> You would so something like:
>
> fun = Couch.compileFunction(source, filter_sandbox);
>
>
> 2) Don't forget the indentation level for .js files is 2 spaces (I'm
> seeing a mix of 4 and 2 spaces in share/server/filter.js)
>
> 3) Avoid the unnecessary white-space only changes:
>
> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L2R396
> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L2R477
> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L3R255
> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R60
> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R85
> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R247
> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R503
> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L3R191
>
> 4) This?LOG_INFO line is there for your debugging purposes I think
> (should be removed):
>
> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L3R168
>
>
> cheers
>
> On Mon, Nov 29, 2010 at 10:05 PM, Benoit Chesneau <bc...@gmail.com> wrote:
>> Hi all,
>>
>> Tonight i've written t quick patch that allows the user to use map
>> view function to filter changes. Here is the patch :
>>
>> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad
>>
>> thoughts ?
>>
>> - benoît
>>
>
>
>
> --
> Filipe David Manana,
> fdmanana@gmail.com, fdmanana@apache.org
>
> "Reasonable men adapt themselves to the world.
>  Unreasonable men adapt the world to themselves.
>  That's why all progress depends on unreasonable men."
>

Here is an updated patch. It now use a filter sandbox instead of
patching the function and it fixes whitespaces.

https://github.com/benoitc/couchdb/compare/master...view_changes

Description of this patch:

Allows to use view map functions to filter database changes. Each time
a map function function could have emitted a pair of key value for a
doc, a change is emitted. This is another builtin change filter. Query
parameters are :

filter=_view
view = designame/viewname

Url:
http://host/db/_changes?filter=_view&view=designame/viewname

ok for you?

- benoît

Re: use view functions to emit changes

Posted by Filipe David Manana <fd...@apache.org>.
Hi Benoît,

It's a good idea I think. Good work.
I have some comments regarding the patch:

1) Doing a regexp substitution of the view function's code string
seems like a recipe for disaster to me.

I think the safe and clean way to go here is to create another
sandbox, with a different 'emit' function, and in
Couch.compileFunction (utils.js) pass a third and optional argument
which is the context in which the function is going to be executed. If
omitted, it uses 'sandbox' as the context, otherwise use that other
context. Then here:

https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L0R34

You would so something like:

fun = Couch.compileFunction(source, filter_sandbox);


2) Don't forget the indentation level for .js files is 2 spaces (I'm
seeing a mix of 4 and 2 spaces in share/server/filter.js)

3) Avoid the unnecessary white-space only changes:

https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L2R396
https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L2R477
https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L3R255
https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R60
https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R85
https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R247
https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R503
https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L3R191

4) This?LOG_INFO line is there for your debugging purposes I think
(should be removed):

https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L3R168


cheers

On Mon, Nov 29, 2010 at 10:05 PM, Benoit Chesneau <bc...@gmail.com> wrote:
> Hi all,
>
> Tonight i've written t quick patch that allows the user to use map
> view function to filter changes. Here is the patch :
>
> https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad
>
> thoughts ?
>
> - benoît
>



-- 
Filipe David Manana,
fdmanana@gmail.com, fdmanana@apache.org

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."