Secondary index update function #40

Closed
wants to merge 3 commits into
from

Projects

None yet

4 participants

@alinpopa

Update api in order to support secondary indexes

  • Add new function to the riakc_obj module
    update_index(#riakc_obj{}, indexes()) -> #riakc_obj{}
    which wraps the update_metadata function call for ?MD_INDEX.
  • A small update to the README.md in order to specify that Make is also a requirement in order to build the riak erlang client.
alinpopa added some commits Dec 29, 2011
@alinpopa alinpopa Add 'make' as one of the dependencies. bbab735
@alinpopa alinpopa Update api in order to support secondary indexes
Add new function to the riakc_obj module
update_index(#riakc_obj{}, indexes()) -> #riakc_obj{}
which wraps the update_metadata function call for ?MD_INDEX.
8206264
@jonmeredith jonmeredith and 1 other commented on an outdated diff Dec 29, 2011
src/riakc_obj.erl
@@ -72,6 +76,7 @@
vclock :: vclock(),
contents :: contents(),
updatemetadata :: dict(),
+ updateindex :: indexes(),
@jonmeredith
jonmeredith Dec 29, 2011

Is updateindex used anywhere?

@alinpopa
alinpopa Dec 29, 2011

Will remove it, as it's there because it was part of some experimentations.

@jonmeredith jonmeredith commented on the diff Dec 29, 2011
src/riakc_obj.erl
@@ -185,6 +190,11 @@ get_values(#riakc_obj{contents=Contents}) ->
update_metadata(Object=#riakc_obj{}, M) ->
Object#riakc_obj{updatemetadata=M}.
+%% @doc Set the update index on an object to I.
+-spec update_index(#riakc_obj{}, indexes()) -> #riakc_obj{}.
+update_index(Object, Indexes) ->
+ update_metadata(Object, dict:store(?MD_INDEX, Indexes, dict:new())).
@jonmeredith
jonmeredith Dec 29, 2011

you should use get_update_metadata(Object) instead of dict:new(), otherwise you'll wipe out the old metadata. You'll have to call select_sibling first if there are multiple entries or it will throw.

@jonmeredith

Thanks for the pull request - I've added a couple of comments. It'd be great to add an accessor for the indices to make that easy too.

@alinpopa alinpopa Remove record field
'updateindex' as not being used.
01bfb1a
@massung
massung commented Mar 19, 2012

This PR cannot be accepted until #43 is resolved satisfactorily.

@beerriot

I believe this PR has been superseded by the riakc_obj:set_secondary_index functions in PR #81.

@beerriot beerriot closed this Jan 23, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment