Hi Roach,
Thanks for taking a moment to give me a hand with this. Let me try
and be
a
bit more clear on what I am trying to figure out. My first steps
are a
Class
Account:
public class Account implements Serializable {
private String email;
}
Storing the account via
myBucket.store("key", account).withoutFetch().execute();
then retrieving it with a map reduce using JS, along the lines of:
var accounts = [];
for( i=0; i<values.length;i++) {
if ( values[i].email == '[email protected] ) {
accounts.push(values[i]);
}
}
return accounts
works as expected.
Now I updated the Class Account to have the name property:
public class Account implements Serializable {
private String name;
private String email;
}
and storing with data to the same bucket, for the same key and
attempting
to
Map Reduce for "name" I get a
{"phase":1,"error":"[{<<\"lineno\">>,1},{<<\"message\">>,<<\"TypeError:
values[i].name is
undefined\">>},{<<\"source\">>,<<\"unknown\">>}]","input":null,"type":null,"stack":null}.
If I change the bucket to a new one, the Map Reduce runs successfully
without the above error.
This is Riak 1.4.2 running on Ubuntu 13.04
thanks,
Michael
On 11/11/2013 02:32 PM, Brian Roach wrote:
Hi Michael,
I'm somewhat confused by your question; map/reduce doesn't really
have
anything to do with your Java POJO/class.
When using the Riak Java client and storing a POJO, the default
converter (JSONConverter) uses the Jackson JSON library and converts
the instance of your POJO into a JSON string and stores it in Riak.
If you change that POJO class and store more things, the resulting
JSON is obviously going to be different (in your case having an
additional field named "minty").
When doing Map/Reduce, whatever JavaScript or Erlang functions you
provide are executing in Riak and being given the data stored in Riak
(the JSON you stored); they have no connection to Java.
Can you expand on "Now the map reduce fails for that the new
property" with what exactly the problem is? It sounds like you have a
problem with your JavaScript or Erlang function(s).
Thanks!
- Roach
On Mon, Nov 11, 2013 at 12:07 PM, Michael Guymon
<[email protected]> wrote:
Hello,
I have a (hopefully dumb) question about working with the Java
client and
POJOs. I justed started tinkering with Riak and have created a simple
Account POJO and happily crammed it into a bucket "test1" and mapped
reduced
it (hooray). The problem starts when I updated the Class for Account,
adding
a new String property "minty". Now the map reduce fails for that
the new
property in the bucket "test1". Seems like the POJO is always being
serialized to the format of the older Account class. If I create
a new
bucket, "test2", and cram and reduce anew, everything works again.
I have been grepping around the docs, but have not been able to
zero in
on
my issue. Am I doing something bone headed? Is it possible to
update a
bucket to support a modified POJO class?
thanks,
Michael
_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com