On 30 Jan 2012, at 18:12, Dietrich Featherston wrote:
> I'm using a leveldb-backed riak 1.0.2 and looking for some suggestions to
> fetch a block of data by key range. I have control over the keys and all
> reads out of this setup will involve at minimum a key range. It seems that if
> leveldb is an ideal candidate for this kind of access pattern so long as I'm
> able to take advantage of that in the APIs exposed by riak.
>
> First thought is to use the built-in $key index to do a query for the keys
> falling in a range, then fetch the underlying objects (either directly or via
> a map job). Doesn't look like this is yielding any results for a range known
> to contain data, however.
>
> Doing something like the following in the Java API yields no data
>
> val keys =
> bucket.fetchIndex(BinIndex.named("$key")).from(startKey).to(endKey).execute();
>
> Whereas the same question phrased as a keyfilter map job does yield data
>
> riak.mapReduce(query)
> .addKeyFilter(new BetweenFilter(startKey, endKey))
> .addMapPhase(new NamedErlangFunction("riak_kv_mapreduce",
> "map_object_value"), true)
> .execute()
>
> Perhaps there is something I need to do to make sure the $key index is built
> other than using the leveldb backend, but I couldn't find any evidence of
> that in the docs.
>
> Does this seem like a reasonable approach? If so, any thoughts on how I might
> be reading the key index incorrectly?
It is a bug/oversight in the RJC, when you do BinIndex.named("$key"), you'll
get an index called "$key_bin", which isn't the name of the index you want.
I'll raise a bug for it and get a patch out. I think the best bet is to have a
tagged type (KeyIndex ?) rather than change the way that BinIndex/IntIndex
work. Sound ok?
Cheers
Russell
>
> Thanks,
> D
>
> _______________________________________________
> riak-users mailing list
> [email protected]
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com