Hi everbody,
I'm using riak to store large numbers of FX rates, to allow for deep
backtests of trading strategies. My code seems to be working, except
that I don't get any keys back from 2i range requests.
Here's the code which puts the rate into riak (the rate is itself a
protocol buffers object):
std::string s = p->rate().time();
std::string rate;
p->rate().SerializeToString(&rate);
mrx::riak::RpbPutReqPtr req(new mrx::riak::RpbPutReq());
req->set_bucket(symbol);
req->set_key(s);
mrx::riak::RpbContent* content = req->mutable_content();
content->set_value(rate);
mrx::riak::RpbPair* index = content->add_indexes();
index->set_key(vm["riak.index"].as<std::string>());
index->set_value(s);
Here's the code which does the index search:
mrx::riak::RpbIndexReqPtr req(new mrx::riak::RpbIndexReq());
req->set_bucket(symbol);
req->set_index(vm["riak.index"].as<std::string>());
req->set_qtype(mrx::riak::RpbIndexReq::range);
req->set_range_min(vm["rates.start"].as<std::string>());
req->set_range_max(vm["rates.end"].as<std::string>());
I originally used the string "time" as the index key, and there was no
error when doing the put command. However, when trying to search with
this index, I got the following error:
[{unknown_field_type,<<"time">>}]
This error went away when I used "time_bin" as the index. However,
regardless of what I use as the index key when doing the put, I never
get any keys returned during the search.
Can someone point me to a working example of using protocol buffers to
do a put and subsequent index search? The examples online only show the
latter.
thanks,
Joey
_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com