I have a problem were i need to aggregate some vectors in order to find some statistics. For example i have vectors of doubles and i need to sum them. My vectors look like this:
1,0,3,4,5
2,3,4,5,6
3,4,5,5,6
My key-value pairs so far are (String,String). But every time i need to add these vectors, i first have to convert them to double arrays, add them up and finally convert the aggregate vector into string. I think it would be a lot faster if i just could have key-value pairs in the form (String,double array). There would be no need to convert them back and forth. My problem is that i cant find a way to have double arrays as value. Is there any easy way rather than create a new custom type?
You mean something like this?
then you could call your map method:
Also you can serialize your double array, and then deserialize it back:
OUTPUT:
Mapping is faster, but serialization will be more usefull if you use nodes and clusters for that (if you need to pass your arrays into another JVM):
OUTPUT: