Skip to content
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

Fix merge to properly operate over dict. #723

Merged
merged 1 commit into from
Nov 9, 2013
Merged

Conversation

cmeiklejohn
Copy link
Contributor

Note: not the most efficient implementation that most likely exists.
For this initial PR I was mainly focusing on ensuring I had the
semantics of the merge correctly to start a discussion.

Ensure we convert the inner dict to a list, uniquely sort the list, so
we can uniquely merge both contents, and then map over the results to
convert the inner list back to a dict.

This is necessary because mutators add data to this dictionary and we
can not guarantee an internal sort order, which causes siblings with a
default of allow_mult=true for the same value.

This is a side effect of the inner data structure not being an orddict.

@evanmcc @engelsanchez

Note: not the most efficient implementation that most likely exists.
For this initial PR I was mainly focusing on ensuring I had the
semantics of the merge correctly to start a discussion.

Ensure we convert the inner dict to a list, uniquely sort the list, so
we can uniquely merge both contents, and then map over the results to
convert the inner list back to a dict.

This is necessary because mutators add data to this dictionary and we
can not guarantee an internal sort order, which causes siblings with a
default of allow_mult=true for the same value.

This is a side effect of the inner data structure not being an orddict.
@russelldb
Copy link
Member

Looks correct to me. Did you have a test (riak_test) that provoked this round of changes I can run to verify this does what you want it to?

@cmeiklejohn
Copy link
Contributor Author

Right above, PR basho/riak_test#445 on verify_backup_restore.

@cmeiklejohn
Copy link
Contributor Author

@evanmcc Any thoughts here?

@evanmcc
Copy link
Contributor

evanmcc commented Nov 8, 2013

This looks fine to me if it fixed the problem. I'll do my best to address efficiency concerns in the near future, but we should always favor correctness over speed.

@cmeiklejohn
Copy link
Contributor Author

Cool; I'd love if someone could verify the test passes for them before I merge it. Can either you or @russelldb take that?

@russelldb
Copy link
Member

Doing it now

@russelldb
Copy link
Member

Test fails for me. Clean riak_test checkout, clean riak checkout with riak_kv set to this branch.

22:51:39.347 [info] Indexing data for search from "/Users/russell/basho/riak_test/search-corpus/spam.0"
22:51:39.347 [info] Putting files from dir "/Users/russell/basho/riak_test/search-corpus/spam.0"
into bucket         <<"search_bucket">>
22:51:39.348 [warning] verify_backup_restore failed: {{badmatch,{error,enoent}},
 [{rt,pbc_put_dir,3,[{file,"src/rt.erl"},{line,994}]},{verify_backup_restore,confirm,0,     
  [{file,"tests/verify_backup_restore.erl"},{line,60}]}]}
22:51:39.348 [error] Error in process <0.128.0> on node 'riak_test@127.0.0.1' with exit value: {{badmatch,{error,enoent}},[{rt,pbc_put_dir,3,[{file,"src/rt.erl"},{line,994}]},{verify_backup_restore,confirm,0,[{file,"tests/verify_backup_restore.erl"},{line,60}]}]}


22:51:39.348 [error] 
================ verify_backup_restore failure stack trace =====================
{{badmatch,{error,enoent}},
 [{rt,pbc_put_dir,3,[{file,"src/rt.erl"},{line,994}]},
  {verify_backup_restore,confirm,0,
                     [{file,"tests/verify_backup_restore.erl"},
                      {line,60}]}]}

================================================================================

@russelldb
Copy link
Member

Sorry, late here, will look again tomorrow.

@engelsanchez
Copy link
Contributor

It's not finding the search files. You should be able to go into that directory /Users/russell/basho/riak_test/search-corpus/ and untar the spam.0.tgz file I think.

@russelldb
Copy link
Member

Did that, same error.

@cmeiklejohn
Copy link
Contributor Author

Make sure your .riak_test.config is pointing to the directory where the search_corpus is. This is unrelated to this fix.

@russelldb
Copy link
Member

Ah! Thank you. Never had that problem before. Addressed that.

Test does indeed now pass. +1 (sorry for the futzing)

cmeiklejohn added a commit that referenced this pull request Nov 9, 2013
Fix merge to properly operate over dict.
@cmeiklejohn cmeiklejohn merged commit ff68831 into develop Nov 9, 2013
@cmeiklejohn cmeiklejohn deleted the bugfix/csm/merge branch November 9, 2013 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants