-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Spanner: partial key range and bug fix with single key #4618
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
Spanner: partial key range and bug fix with single key #4618
Conversation
| elif self.start_closed is not None: | ||
| kwargs['start_closed'] = _make_list_value_pb(self.start_closed) | ||
| else: | ||
| kwargs['start_closed'] = _make_list_value_pb([]) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
spanner/tests/unit/test_keyset.py
Outdated
|
|
||
| import unittest | ||
|
|
||
| import six |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
spanner/tests/unit/test_keyset.py
Outdated
| self._make_one(end_open=KEY_1, end_closed=KEY_2) | ||
|
|
||
| def test_ctor_w_only_start_open(self): | ||
| def test_ctor_start_open_and_start_closed_empty_lists_and_end_closed(self): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
spanner/tests/unit/test_keyset.py
Outdated
| with self.assertRaises(ValueError): | ||
| self._make_one(start_open=KEY_1, end_open=[], end_closed=[]) | ||
|
|
||
| def _check_unused_keys(self, krange, used_keys): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
spanner/tests/unit/test_keyset.py
Outdated
| 'end_open') | ||
| for key_type in key_types: | ||
| if key_type not in used_keys: | ||
| self.assertFalse(krange.to_pb().HasField(key_type)) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| self.assertEqual(krange.end_closed, None) | ||
| KEY_2 = [u'key_2'] | ||
| with self.assertRaises(ValueError): | ||
| self._make_one(start_open=[], start_closed=[], end_closed=KEY_1) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
spanner/tests/unit/test_keyset.py
Outdated
| self._make_one(start_open=[], start_closed=[], end_closed=KEY_1) | ||
|
|
||
| def test_ctor_w_only_start_closed(self): | ||
| def test_ctor_start_open_and_end_open_and_end_closed_empty_lists(self): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| self.assertIsNone(krange.start_closed) | ||
| self.assertIsNone(krange.end_open) | ||
|
|
||
| def test_ctor_single_key_end_open(self): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
spanner/tests/unit/test_keyset.py
Outdated
| self.assertEqual(pb_key_type.values[0].string_value, KEY_1[0]) | ||
| self._check_unused_keys(krange, used_keys) | ||
|
|
||
| def test_to_pb_single_key_end_open(self): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| """ | ||
| def __init__(self, start_open=None, start_closed=None, | ||
| end_open=None, end_closed=None): | ||
| if not any([start_open, start_closed, end_open, end_closed]): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| if start_open is not None and start_closed is not None: | ||
| raise ValueError("Specify one of 'start_open' / 'start_closed'.") | ||
| elif start_open is None and start_closed is None: | ||
| start_closed = [] |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| raise ValueError("Must specify at least a start or end row.") | ||
|
|
||
| if start_open and start_closed: | ||
| if start_open is not None and start_closed is not None: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
9954202 to
63b8948
Compare
|
maybe breaking this up and changing the code all at once isn't such a great idea..... |
|
working on it... |
762322c to
ba5619c
Compare
ba5619c to
9283a46
Compare
| end_open=None, end_closed=None): | ||
| if not any([start_open, start_closed, end_open, end_closed]): | ||
| keys = (start_open, start_closed, end_open, end_closed) | ||
| if all(key is None for key in keys): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| if start_open is not None and start_closed is not None: | ||
| raise ValueError("Specify one of 'start_open' / 'start_closed'.") | ||
| elif start_open is None and start_closed is None: | ||
| start_closed = [] |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| kwargs['start_open'] = _make_list_value_pb(self.start_open) | ||
|
|
||
| if self.start_closed: | ||
| else: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| self._make_one() | ||
|
|
||
| def test_ctor_w_start_open_and_start_closed(self): | ||
| def test_ctor_start_open_and_start_closed(self): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
spanner/tests/unit/test_keyset.py
Outdated
| with self.assertRaises(ValueError): | ||
| self._make_one(start_open=KEY_1, end_open=[], end_closed=[]) | ||
|
|
||
| def _check_unused_keys(self, key_range, used_keys): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| self.assertIsNone(krange.start_open) | ||
| self.assertIsNone(krange.end_open) | ||
|
|
||
| def test_ctor_single_key_end_open(self): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
020091d to
8d84c34
Compare
|
@dhermes PTAL, thanks. |
| raise ValueError("Must specify at least a start or end row.") | ||
| if ((start_open is None and start_closed is None) | ||
| or (start_open is not None and start_closed is not None)): | ||
| raise ValueError("Specify exactly one start key type") |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
8d84c34 to
4192357
Compare
|
no opposition, changed. |
| if not any([start_open, start_closed, end_open, end_closed]): | ||
| raise ValueError("Must specify at least a start or end row.") | ||
| if ((start_open is None and start_closed is None) | ||
| or (start_open is not None and start_closed is not None)): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
spanner/tests/unit/test_keyset.py
Outdated
|
|
||
| KEY_1 = [u'key_1'] | ||
| with self.assertRaises(ValueError): | ||
| krange = self._make_one(start_closed=KEY_1) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
e973bd7 to
a106cda
Compare
- Converting to "Google" docstring style - Adding note about the "exactly one of" requirement with a suggestion about what to pass if the start/end is not important to the user - Adding a `Raises` section to the class docstring
Also reworked the `to_pb()` tests to just create a protobuf and just use one assertion.
a106cda to
88ca5bb
Compare
|
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
dhermes
left a comment
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.
LGTM
This is a follow-on to #4618.
breaking up #4515