Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling a named javascript function as mapper [JIRA: CLIENTS-615] #412

Open
dvillaj opened this issue Sep 29, 2015 · 5 comments
Open

Calling a named javascript function as mapper [JIRA: CLIENTS-615] #412

dvillaj opened this issue Sep 29, 2015 · 5 comments

Comments

@dvillaj
Copy link

dvillaj commented Sep 29, 2015

I have a named javascript function stored in a bucket/key in Riak:

import riak

client = riak.RiakClient()
bucket = client.bucket('my_functions')

obj = riak.RiakObject(client, bucket, 'map_capacity')
obj.content_type = 'application/json'
obj.encoded_data = """function(v) {
    var parsed_data = JSON.parse(v.values[0].data);
    var data = {};
    data[parsed_data.style] = parsed_data.capacity;
    return [data];
}"""
obj.store()

The problem is when I try to call it:

mapReduce = riak.mapreduce.RiakMapReduce(client)
mapReduce.add("rooms") 
mapReduce.map( "my_functions.map_capacity")

mapReduce.run()

Riak returns ReferenceError: my_functions is not defined

What 's wrong?

Thanks

@Basho-JIRA Basho-JIRA changed the title Calling a named javascript function as mapper Calling a named javascript function as mapper [JIRA: CLIENTS-615] Sep 29, 2015
@lukebakken
Copy link
Contributor

Can you invoke your function using the HTTP API?

http://docs.basho.com/riak/latest/dev/advanced/mapreduce/#Invoking-MapReduce

Can you attach Riak's error.log file?

@dvillaj
Copy link
Author

dvillaj commented Jan 20, 2016

Yes I can

On Wed, Jan 20, 2016 at 5:17 PM, Luke Bakken [email protected]
wrote:

Can you invoke your function using the HTTP API?

http://docs.basho.com/riak/latest/dev/advanced/mapreduce/#Invoking-MapReduce


Reply to this email directly or view it on GitHub
#412 (comment)
.

@lukebakken
Copy link
Contributor

Can you share your HTTP invocation as well as Riak's error.log file when you receive the error in the Python client?

@dvillaj
Copy link
Author

dvillaj commented Jan 20, 2016

Sure.

I've attached a PDF showing what I did using a iPython notebook.

Thanks

On Wed, Jan 20, 2016 at 5:28 PM, Luke Bakken [email protected]
wrote:

Can you share your HTTP invocation as well as Riak's error.log file when
you receive the error in the Python client?


Reply to this email directly or view it on GitHub
#412 (comment)
.

@lukebakken
Copy link
Contributor

This is strange, I don't see any files attached to this issue.

@lukebakken lukebakken modified the milestone: riak-python-client-2.7.1 Dec 16, 2016
@lukebakken lukebakken modified the milestones: riak-python-client-2.7.1, riak-python-client-3.0.0 Feb 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants