javascript - calling another list function in couchdb -
helo folks,
i working on view in couchdb. and, in 'extract' list function, i'm trying filter out information using view (myview). client connects couchdb, want 1 major thing - show results 'extract' list function. but, there multiple other things want perform on results returned 'extract' function. 1 simple operation out of other operations 'sum'. but, there many other features calculating median/standard deviation etc on results of 'extract' list function.
{ "_id": "_design/mydesigndoc", "lists": { "extract": "function(head, req){ ...*extract info view*: **myview** ...}", "sum" : "function(head,req) {...**sum values returned 'extract' function above**...}" }, "views": { "myview" : { "map" : "..." }, } } so, i'm stuck @ 1 point:-
as whole design doc json , function bodies javascript, there way call 'extract' list function in other list functions 'sum', 'median', 'standard deviation' etc ?
reason want this:-
all other list functions: 'sum', 'standard deviation' etc expect return value of 'extract' function input. so, making redundant copies of code of extract function in other list functions last thing want do.
is there alternate way solve this:-
yes, there way. had thought i'll use view functions 'myview' these functionalities , write same 'map' function in 'myview' but, these views have separate 'reduce' functions calculating 'sum', 'standard dev' etc. but, calculation of views caused lot of resource usage because many views getting created each time.
could guys provide better solution this?
thanks
my first thought implement views again reduce functions calculations resource intensive.. wonder how views used , if there heap of changes between accesses?
if used produce statistics reports or , accessed when there heap of changes needs make view indexes maybe @ running script regularly retrieves views keeps views date when accessed still respond relatively quickly.
this have done our of our views in our production environment , works quite well, guess depends on infrastructure , how data pumping through.
something else consider not sure if there difference/benefit doing maybe built in reduce functions may offer better performance self created ones
Comments
Post a Comment