CRASH REPORT Process <<"TypeError: reduce of empty array with no initial value">>},{<<"source">>,<<"unknown">>}]}

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

CRASH REPORT Process <<"TypeError: reduce of empty array with no initial value">>},{<<"source">>,<<"unknown">>}]}

David Montgomery
2012-12-20 13:31:27.906 [error] <0.30794.1> CRASH REPORT Process <0.30794.1> with 0 neighbours exited with reason: {fitting_exited_abnormally,[{<<"lineno">>,3},{<<"message">>,<<"TypeError: reduce of empty array with no initial value">>},{<<"source">>,<<"unknown">>}]} in gen_fsm:terminate/7 line 611
2012-12-20 13:31:27.912 [error] <0.213.0> Supervisor riak_pipe_builder_sup had child undefined started with {riak_pipe_builder,start_link,undefined} at <0.30794.1> exit with reason {fitting_exited_abnormally,[{<<"lineno">>,3},{<<"message">>,<<"TypeError: reduce of empty array with no initial value">>},{<<"source">>,<<"unknown">>}]} in context child_terminated


Hi,

The above is the crash report I get when I run the below script using the api.  The api does not return an error.  I have to look at the logs on the node running the query else will run till timeout is reached.

query.map('''
    function(value, keyData, arg) {
        var data = Riak.mapValuesJson(value)[0];
        if(data['adx']=='gdn'){
            try{
                var matches = data['url'].match(/^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i);
                var alt_key = matches && matches[1];
            }
            catch(err){
                var alt_key = 'error';
            }
            obj[alt_key] = 1;
            return [ obj ];
        }else{
           return [];
        }
    }''')

query.reduce('''
    function(values, arg){
        return [ values.reduce( function(acc, item) {
            for (var state in item) {
                if (acc[state])
                    acc[state] += item[state];
                else
                    acc[state] = item[state];
            }
            return acc;
        })];
    }
    ''')

Thanks

_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CRASH REPORT Process <<"TypeError: reduce of empty array with no initial value">>},{<<"source">>,<<"unknown">>}]}

bryan-basho
Administrator
On Thu, Dec 20, 2012 at 8:52 AM, David Montgomery
<[hidden email]> wrote:
> {fitting_exited_abnormally,[{<<"lineno">>,3},{<<"message">>,<<"TypeError:
> reduce of empty array with no initial value">>}

Hi, David. The error is occurring on line three of your reduce
function, where it calls `values.reduce`:

> query.reduce('''
>     function(values, arg){
>         return [ values.reduce( function(acc, item) {
...

It's complaining about the fact that `values` is an empty array, so
`values.reduce` doesn't know what to do. You will need to either
include an initial value as a second parameter, like:

    values.reduce(function(acc, item) { ... },
                  {}) //initial empty object

Or check to see if `values` is empty before reducing, like the Riak JS
reduce builtins do:

https://github.com/basho/riak_kv/blob/master/priv/mapred_builtins.js#L68

Cheers,
Bryan

_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CRASH REPORT Process <<"TypeError: reduce of empty array with no initial value">>},{<<"source">>,<<"unknown">>}]}

David Montgomery
Hi,

Thanks...... in my mapper I added obj={} which I left out.

But still cant get MR to work but left out that i am using filters.  I get the same error and am wondering if I am using key filters correct.
    {'uuid':1,'campaign_id':2,'adgroup_id':3,'date':4,'country':5}

    filters = key_filter.tokenize(":",5).eq(country) \
    &  key_filter.tokenize(":", 2).eq(campaign_id) \
    &  key_filter.tokenize(":", 4).string_to_int().less_than_eq(date_end) \
    &  key_filter.tokenize(":", 4).string_to_int().greater_than_eq(date_start)
    query.add_key_filters(filters)

'[['and', [['tokenize', ':', 5], ['eq', 'SG']], [['tokenize', ':', 2], ['eq', 'cid5989410021']], [['tokenize', ':', 4], ['string_to_int'], ['less_than_eq', '2012122509']], [['tokenize', ':', 4], ['string_to_int'], ['greater_than_eq', '2012121810']]]]

If I leave out &  key_filter.tokenize(":", filter_map['date']).string_to_int().greater_than_eq(date_start) the query works and I get the data I want.  If I include then I get the error.  So...what I cant figure out is why I cant use the last filter.  My key looks like this.  07712f3d-6661-44a7-89ff-4e4ed3b5f5a6:cid5989410021:agid7744464312:2012122205:SG

uuid:campaign_id:aid:date:country where date is in YYYYMMDDHH format

I just want a query that will filter by campaign_id, country, and between a date range.

thanks
















On Thu, Dec 20, 2012 at 11:07 PM, Bryan Fink <[hidden email]> wrote:
On Thu, Dec 20, 2012 at 8:52 AM, David Montgomery
<[hidden email]> wrote:
> {fitting_exited_abnormally,[{<<"lineno">>,3},{<<"message">>,<<"TypeError:
> reduce of empty array with no initial value">>}

Hi, David. The error is occurring on line three of your reduce
function, where it calls `values.reduce`:

> query.reduce('''
>     function(values, arg){
>         return [ values.reduce( function(acc, item) {
...

It's complaining about the fact that `values` is an empty array, so
`values.reduce` doesn't know what to do. You will need to either
include an initial value as a second parameter, like:

    values.reduce(function(acc, item) { ... },
                  {}) //initial empty object

Or check to see if `values` is empty before reducing, like the Riak JS
reduce builtins do:

https://github.com/basho/riak_kv/blob/master/priv/mapred_builtins.js#L68

Cheers,
Bryan


_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CRASH REPORT Process <<"TypeError: reduce of empty array with no initial value">>},{<<"source">>,<<"unknown">>}]}

David Montgomery
Hi

As an update.......I did get it to work and still wondering if correct even though I did get data. 

filters = key_filter.tokenize(":",5).eq(country) \
    &  key_filter.tokenize(":", 2).eq(campaign_id) \
    &  key_filter.tokenize(":", 4).string_to_int().less_than_eq(date_end) \
    &  key_filter.tokenize(":", 4).string_to_int().greater_than_eq(date_start)
    query.add_key_filters(filters)

I changed the & to a | for the date range.  This was a tough bug to track down yet so simple and image that is why I get the error in the log file.

Thanks



On Sat, Dec 22, 2012 at 3:39 PM, David Montgomery <[hidden email]> wrote:
Hi,

Thanks...... in my mapper I added obj={} which I left out.

But still cant get MR to work but left out that i am using filters.  I get the same error and am wondering if I am using key filters correct.
    {'uuid':1,'campaign_id':2,'adgroup_id':3,'date':4,'country':5}

    filters = key_filter.tokenize(":",5).eq(country) \
    &  key_filter.tokenize(":", 2).eq(campaign_id) \
    &  key_filter.tokenize(":", 4).string_to_int().less_than_eq(date_end) \
    &  key_filter.tokenize(":", 4).string_to_int().greater_than_eq(date_start)
    query.add_key_filters(filters)

'[['and', [['tokenize', ':', 5], ['eq', 'SG']], [['tokenize', ':', 2], ['eq', 'cid5989410021']], [['tokenize', ':', 4], ['string_to_int'], ['less_than_eq', '<a href="tel:2012122509" value="+12012122509" target="_blank">2012122509']], [['tokenize', ':', 4], ['string_to_int'], ['greater_than_eq', '<a href="tel:2012121810" value="+12012121810" target="_blank">2012121810']]]]

If I leave out &  key_filter.tokenize(":", filter_map['date']).string_to_int().greater_than_eq(date_start) the query works and I get the data I want.  If I include then I get the error.  So...what I cant figure out is why I cant use the last filter.  My key looks like this.  07712f3d-6661-44a7-89ff-4e4ed3b5f5a6:cid5989410021:agid7744464312:2012122205:SG

uuid:campaign_id:aid:date:country where date is in YYYYMMDDHH format

I just want a query that will filter by campaign_id, country, and between a date range.

thanks
















On Thu, Dec 20, 2012 at 11:07 PM, Bryan Fink <[hidden email]> wrote:
On Thu, Dec 20, 2012 at 8:52 AM, David Montgomery
<[hidden email]> wrote:
> {fitting_exited_abnormally,[{<<"lineno">>,3},{<<"message">>,<<"TypeError:
> reduce of empty array with no initial value">>}

Hi, David. The error is occurring on line three of your reduce
function, where it calls `values.reduce`:

> query.reduce('''
>     function(values, arg){
>         return [ values.reduce( function(acc, item) {
...

It's complaining about the fact that `values` is an empty array, so
`values.reduce` doesn't know what to do. You will need to either
include an initial value as a second parameter, like:

    values.reduce(function(acc, item) { ... },
                  {}) //initial empty object

Or check to see if `values` is empty before reducing, like the Riak JS
reduce builtins do:

https://github.com/basho/riak_kv/blob/master/priv/mapred_builtins.js#L68

Cheers,
Bryan



_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Loading...