Skip to content

Commit b715906

Browse files
committed
yokozuna now module implements riak_kv_update_hook behavior and misc name changes, per PR comments.
Cf., riak_kv commit 32bcff513d92e228facd471cc2313a2623b1269d
1 parent e3d3c76 commit b715906

File tree

3 files changed

+44
-18
lines changed

3 files changed

+44
-18
lines changed

priv/yokozuna.schema

+3-2
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,9 @@
332332
hidden
333333
]}.
334334

335-
%% @doc Add yokozuna to the riak_kv index modules
336-
{mapping, "search.index_module", "riak_kv.index_module", [
335+
%% @doc Set the riak_kv update hook to be the yokozuna module, which
336+
%% implements the `riak_kv_update_hook` behavior
337+
{mapping, "search.update_hook", "riak_kv.update_hook", [
337338
{datatype, atom},
338339
{default, yokozuna},
339340
hidden

src/yokozuna.erl

+40-15
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,55 @@
2323

2424
-type fold_fun() :: fun(([term()], Acc::term()) -> Acc::term()).
2525

26+
-behaviour(riak_kv_update_hook).
27+
28+
%% riak_kv_update_hook behaviors
29+
-export([
30+
update/3,
31+
update_binary/5,
32+
requires_existing_object/1,
33+
should_handoff/1
34+
]).
35+
2636
%%%===================================================================
27-
%%% API
37+
%% riak_kv_update_hook behavior
2838
%%%===================================================================
2939

30-
%% @doc Index a Riak object, given a reason and partition under which
31-
%% the object is being indexed. The object pair contains the new
32-
%% and old objects, in the case where a read-before-write resulted
33-
%% in an old object we can use to delete siblings before updating.
34-
-spec index(object_pair(), write_reason(), p()) -> ok.
35-
index(RObjPair, Reason, Idx) ->
40+
%% @doc see riak_kv_update_hook:update/3
41+
-spec update(
42+
riak_kv_update_hook:object_pair(),
43+
riak_kv_update_hook:update_reason(),
44+
riak_kv_update_hook:partition()
45+
) -> ok.
46+
update(RObjPair, Reason, Idx) ->
3647
yz_kv:index(RObjPair, Reason, Idx).
3748

38-
%% @doc Index a Riak object encoded as a n erlang binary. This function
39-
%% is typically called from the write-once path, where there is no
40-
%% old object to
41-
-spec index_binary(bucket(), key(), binary(), write_reason(), p()) -> ok.
42-
index_binary(Bucket, Key, Bin, Reason, P) ->
49+
%% @doc see riak_kv_update_hook:update_binary/5
50+
-spec update_binary(
51+
riak_core_bucket:bucket(),
52+
riak_object:key(),
53+
binary(),
54+
riak_kv_update_hook:update_reason(),
55+
riak_kv_update_hook:partition()
56+
) -> ok.
57+
update_binary(Bucket, Key, Bin, Reason, P) ->
4358
yz_kv:index_binary(Bucket, Key, Bin, Reason, P).
4459

45-
%% @doc Determine whether a bucket is searchable, based on its properties.
46-
-spec is_searchable(riak_kv_bucket:props()) -> boolean().
47-
is_searchable(BProps) ->
60+
%% @doc see riak_kv_update_hook:requires_existing_object/1
61+
-spec requires_existing_object(riak_kv_bucket:props()) -> boolean().
62+
requires_existing_object(BProps) ->
4863
yz_kv:is_search_enabled_for_bucket(BProps).
4964

65+
%% @doc see riak_kv_update_hook:should_handoff/1
66+
-spec should_handoff(riak_kv_update_hook:handoff_dest()) -> boolean().
67+
should_handoff(HandoffSpec) ->
68+
yz_kv:should_handoff(HandoffSpec).
69+
70+
71+
%%%===================================================================
72+
%%% API
73+
%%%===================================================================
74+
5075
%% @doc Disable the given `Component'. The main reason for disabling
5176
%% a component is to help in diagnosing issues in a live,
5277
%% production environment. E.g. the `search' component may be

test/yokozuna_schema_tests.erl

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ basic_schema_test() ->
7878
cuttlefish_unit:assert_config(Config, "yokozuna.aae_throttle_enabled", true),
7979
cuttlefish_unit:assert_not_configured(Config, "yokozuna.aae_throttle_limits"),
8080
cuttlefish_unit:assert_config(Config, "yokozuna.enable_dist_query", true),
81-
cuttlefish_unit:assert_config(Config, "riak_kv.index_module", yokozuna),
81+
cuttlefish_unit:assert_config(Config, "riak_kv.update_hook", yokozuna),
8282
ok.
8383

8484
override_schema_test() ->

0 commit comments

Comments
 (0)