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

consider removal of broken objects #730

Merged
merged 3 commits into from
Jun 1, 2017
Merged

consider removal of broken objects #730

merged 3 commits into from
Jun 1, 2017

Conversation

toolslive
Copy link
Member

No description provided.

Copy link
Contributor

@domsj domsj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice test addition, looks like we needed it...
a few comments, see below


Lwt_log.debug_f
"Found buckets %s for namespace_id:%Li"
([%show : (Policy.policy * int64) list] bucket_count)
namespace_id >>= fun () ->

mgr_access # get_namespace_by_id ~namespace_id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will query the albamgr each time, we may want to avoid that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's silly and easy to avoid as we have the name a level above. will do.

let prefix_len = String.length prefix in
len >= prefix_len
&&
String.sub namespace_name 0 prefix_len = prefix
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably have a String.starts_with helper function in prelude, which avoids the string copy done here. I have the feeling we do this elsewhere in the code too, but I can't find it / recall where...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had that feeling too, looked for it, couldn't find it. Will add to prelude.

end
end

let neg_compare_buckets b1 b2 =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe remove this function, and let it immediately sort in the desired way in compare_buckets above?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok.

let compare_bucket_safety
(k1, _, fragment_count1, _)
(k2, _, fragment_count2, _) =
(fragment_count2 - k2) - (fragment_count1 - k1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you flipped this around which is a bit counter intuitive?

let expected =[
( 1, 2, 3, 1), Rewrite; (* safety: 2 *)
(16, 8, 20, 3), Regenerate; (* safety: 4 *)
(16, 8, 24, 6), Rebalance;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add 1 extra Rewrite & Regenerate case so that part of the sorting is fully tested too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok.

@@ -101,6 +101,16 @@ end
module String = struct
include String

let starts_with s prefix =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation is inefficient due to bounds checks, and it can throw Invalid_argument 'index out of bounds' when the prefix is longer than the string s.
Probably the easiest solution is to use Core.String.is_prefix ~prefix s

don't throw if string shorter than prefix
use unsafe_get
@toolslive toolslive merged commit fec90d9 into master Jun 1, 2017
@toolslive toolslive deleted the maybe_delete_broken branch June 1, 2017 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants