From 4d34e30fff64d6e192a03dd6e857334bc0f180c8 Mon Sep 17 00:00:00 2001 From: Fred Dushin Date: Fri, 10 Jul 2015 11:20:12 -0400 Subject: [PATCH] Modified write_once path to use the new yz_kv:index_binary/5 for indexing binary encoded Riak Objects. This requires that we also pass in a bucket and key, so that the riak object can be decoded. --- dialyzer.ignore-warnings | 1 + src/riak_kv_vnode.erl | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/dialyzer.ignore-warnings b/dialyzer.ignore-warnings index 0e448fbd18..ed5545a24d 100644 --- a/dialyzer.ignore-warnings +++ b/dialyzer.ignore-warnings @@ -56,6 +56,7 @@ Callback info about the riak_kv_backend behaviour is not available Unknown functions: dtrace:init/0 yz_kv:index/3 + yz_kv:index_binary/5 yz_kv:should_handoff/1 yz_stat:search_stats/0 Unknown types: diff --git a/src/riak_kv_vnode.erl b/src/riak_kv_vnode.erl index 542852f36f..fa58b212c6 100644 --- a/src/riak_kv_vnode.erl +++ b/src/riak_kv_vnode.erl @@ -95,8 +95,10 @@ -ifdef(TEST). %% Use values so that test compile doesn't give 'unused vars' warning. -define(INDEX(A,B,C), _=element(1,{A,B,C}), ok). +-define(INDEX_BIN(A,B,C,D,E), _=element(1,{A,B,C,D,E}), ok). -else. -define(INDEX(Obj, Reason, Partition), yz_kv:index(Obj, Reason, Partition)). +-define(INDEX_BIN(Bucket, Key, Obj, Reason, Partition), yz_kv:index_binary(Bucket, Key, Obj, Reason, Partition)). -endif. -ifdef(TEST). @@ -841,6 +843,7 @@ handle_command(?KV_W1C_PUT_REQ{bkey={Bucket, Key}, encoded_obj=EncodedVal, type= case Mod:put(Bucket, Key, [], EncodedVal, ModState) of {ok, UpModState} -> update_hashtree(Bucket, Key, EncodedVal, State), + ?INDEX_BIN(Bucket, Key, EncodedVal, put, Idx), update_vnode_stats(vnode_put, Idx, StartTS), {reply, ?KV_W1C_PUT_REPLY{reply=ok, type=Type}, State#state{modstate=UpModState}}; {error, Reason, UpModState} -> @@ -1164,6 +1167,7 @@ terminate(_Reason, #state{mod=Mod, modstate=ModState}) -> handle_info({{w1c_async_put, From, Type, Bucket, Key, EncodedVal, StartTS} = _Context, Reply}, State=#state{idx=Idx}) -> update_hashtree(Bucket, Key, EncodedVal, State), + ?INDEX_BIN(Bucket, Key, EncodedVal, put, Idx), riak_core_vnode:reply(From, ?KV_W1C_PUT_REPLY{reply=Reply, type=Type}), update_vnode_stats(vnode_put, Idx, StartTS), {ok, State};