Yet another fold fix, this time with the multi backend.
Yet another fold fix, this time with the multi backend.

Fix Jon's less-than-optimal bug as pointed out in pull req #37.
Also, since the multi backend is actually bucket aware, we save
work by only querying the one backend that we know is responsible
for the bucket.

Verifying, at console:

{ok, C} = riak:local_client().
C:set_bucket(<<"i">>,[{backend, inno}]).
C:set_bucket(<<"b">>,[{backend, bitcask}]).
[C:put(riak_object:new(<<"i">>, <<X:32>>, <<X:32>>)) || X <- lists:seq(1,5)].
[C:put(riak_object:new(<<"b">>, <<X:32>>, <<X:32>>)) || X <- lists:seq(6,10)].
[C:put(riak_object:new(<<"x">>, <<X:32>>, <<X:32>>)) || X <- lists:seq(11,15)].
[{Bucket, C:list_keys(Bucket)} || Bucket <- [<<"i">>, <<"b">>, <<"x">>, <<"none">>]].

Config additions:

--- rel/riak/etc/app.config	2011-02-17 16:50:36.000000000 -0600
+++ /tmp/app.config	2011-02-22 15:01:55.000000000 -0600
@@ -1,6 +1,11 @@
 %% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*-
 %% ex: ts=4 sw=4 et
 [
+{innostore, [
+    {data_home_dir, "/tmp/innodb"}, %% Where data files go
+    {log_group_home_dir, "/tmp/innodb"}, %% Where log files go
+    {buffer_pool_size, 268435456} %% 256MB in-memory buffer in bytes
+]},
  %% Riak Core config
  {riak_core, [
               %% Default location of ringstate
@@ -30,7 +35,15 @@
  {riak_kv, [
             %% Storage_backend specifies the Erlang module defining the
             %storage
             %% mechanism that will be used on this node.
-            {storage_backend, riak_kv_bitcask_backend},
+            %%{storage_backend, riak_kv_bitcask_backend},
+{storage_backend, riak_kv_multi_backend},
+{riak_kv_dets_backend_root, "data/dets"},
+{riak_kv_fs_backend_root, "data/fs"},
+{multi_backend_default, default},
+{multi_backend, [{default, riak_kv_dets_backend,
+    [{riak_kv_dets_backend_root, "data/dets"}]},
+     {bitcask, riak_kv_bitcask_backend, []},
+     {inno,    riak_kv_innostore_backend, []}]},

             %% pb_ip is the IP address that the Riak Protocol Buffers
             %interface
             %% will bind to.  If this is undefined, the interface will not
             %run.

(riak@127.0.0.1)1> {ok, C} = riak:local_client().
{ok,{riak_client,'riak@127.0.0.1',<<1,158,32,8>>}}
(riak@127.0.0.1)2> C:set_bucket(<<"i">>,[{backend, inno}]).
ok
(riak@127.0.0.1)3> C:set_bucket(<<"b">>,[{backend, bitcask}]).
ok
(riak@127.0.0.1)4> [C:put(riak_object:new(<<"i">>, <<X:32>>, <<X:32>>)) ||
X <- lists:seq(1,5)].
[ok,ok,ok,ok,ok]
(riak@127.0.0.1)5> [C:put(riak_object:new(<<"b">>, <<X:32>>, <<X:32>>)) ||
X <- lists:seq(6,10)].
[ok,ok,ok,ok,ok]
(riak@127.0.0.1)6> [C:put(riak_object:new(<<"x">>, <<X:32>>, <<X:32>>)) ||
X <- lists:seq(11,15)].
[ok,ok,ok,ok,ok]
(riak@127.0.0.1)7> [{Bucket, C:list_keys(Bucket)} || Bucket <- [<<"i">>,
<<"b">>, <<"x">>, <<"no">>]].
[{<<"i">>,
  {ok,[<<0,0,0,2>>,
       <<0,0,0,5>>,
       <<0,0,0,3>>,
       <<0,0,0,4>>,
       <<0,0,0,1>>]}},
 {<<"b">>,
  {ok,[<<0,0,0,8>>,
       <<0,0,0,7>>,
       <<0,0,0,9>>,
       <<0,0,0,10>>,
       <<0,0,0,6>>]}},
 {<<"x">>,
  {ok,[<<0,0,0,13>>,
       <<0,0,0,12>>,
       <<0,0,0,11>>,
       <<0,0,0,14>>,
       <<0,0,0,15>>]}},
 {<<"no">>,{ok,[]}}]

andytill/riak_kv