-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix/fd/riak 1937 #529
Merged
Merged
Bugfix/fd/riak 1937 #529
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1f68ac3
Exposed accessor for whether yokozuna is enabled, for write_once put …
fadushin 9117cce
Overloaded yz_kv:index to handle binaries, so that we don't have to d…
fadushin 2fab6e6
Added a write_once search test to the yz_pb test suite.
fadushin eeb90d0
After review, modified yz integration so that we preserve the old yz_…
fadushin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,35 +190,53 @@ has_indexes(RemoteNode) -> | |
_ -> false | ||
end. | ||
|
||
|
||
%% @doc Index the data supplied in the Riak Object. | ||
%% The Riak Object should be a serialized object (a binary, | ||
%% which has been serialized using riak_object:to_binary/1) | ||
-spec index_binary(bucket(), key(), binary(), write_reason(), p()) -> ok. | ||
index_binary(Bucket, Key, Obj, Reason, P) -> | ||
index_internal( | ||
Bucket, Key, Obj, Reason, P | ||
). | ||
|
||
%% @doc Index the data supplied in the Riak Object. | ||
-spec index(riak_object:riak_object(), write_reason(), p()) -> ok. | ||
index(Obj, Reason, P) -> | ||
index_internal( | ||
riak_object:bucket(Obj), riak_object:key(Obj), Obj, Reason, P | ||
). | ||
|
||
%% @private | ||
index_internal(Bucket, Key, Obj, Reason, P) -> | ||
case yokozuna:is_enabled(index) andalso ?YZ_ENABLED of | ||
true -> | ||
Ring = yz_misc:get_ring(transformed), | ||
case is_owner_or_future_owner(P, node(), Ring) of | ||
true -> | ||
T1 = os:timestamp(), | ||
BKey = {riak_object:bucket(Obj), riak_object:key(Obj)}, | ||
BKey = {Bucket, Key}, | ||
try | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fadushin thinking we can create a helper to avoid the duplication in index/3 and index/5, no? |
||
Index = get_index(BKey), | ||
ShortPL = riak_kv_util:get_index_n(BKey), | ||
case should_index(Index) of | ||
true -> | ||
index(Obj, Reason, Ring, P, BKey, ShortPL, Index); | ||
index(robj(Bucket, Key, Obj), Reason, Ring, P, BKey, ShortPL, Index); | ||
false -> | ||
dont_index(Obj, Reason, P, BKey, ShortPL) | ||
dont_index(robj(Bucket, Key, Obj), Reason, P, BKey, ShortPL) | ||
end, | ||
yz_stat:index_end(?YZ_TIME_ELAPSED(T1)) | ||
catch _:Err -> | ||
yz_stat:index_fail(), | ||
Trace = erlang:get_stacktrace(), | ||
case Reason of | ||
delete -> | ||
?ERROR("failed to delete docid ~p with error ~p because ~p", | ||
[BKey, Err, Trace]); | ||
_ -> | ||
?ERROR("failed to index object ~p with error ~p because ~p", | ||
[BKey, Err, Trace]) | ||
end | ||
yz_stat:index_fail(), | ||
Trace = erlang:get_stacktrace(), | ||
case Reason of | ||
delete -> | ||
?ERROR("failed to delete docid ~p with error ~p because ~p", | ||
[BKey, Err, Trace]); | ||
_ -> | ||
?ERROR("failed to index object ~p with error ~p because ~p", | ||
[BKey, Err, Trace]) | ||
end | ||
end; | ||
false -> | ||
ok | ||
|
@@ -227,6 +245,12 @@ index(Obj, Reason, P) -> | |
ok | ||
end. | ||
|
||
%% @private | ||
robj(Bucket, Key, Obj) when is_binary(Obj) -> | ||
riak_object:from_binary(Bucket, Key, Obj); | ||
robj(_Bucket, _Key, Obj) -> | ||
Obj. | ||
|
||
%% @private | ||
%% | ||
%% @doc Update the hashtree so that AAE works but don't create any | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After looking through the code in a walkthrough (esp. the pars the PR doesn't show, haha), @fadushin and I realized that the
should_index
check should be called before converting the object from binary. This led to a deeper look into some code duplication (around BKey creating, etc...) and whatnot that is happening; so, he's going to be refactoring his changes a bit and just adding a separate index/5 function for binary objects.