-
Notifications
You must be signed in to change notification settings - Fork 162
counter_incs by incrementRows #89
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
Open
ummae
wants to merge
7
commits into
python-happybase:master
Choose a base branch
from
ummae:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d455db0
counter_incs by incrementRows
ummae c7dd562
- Correct typo/PEP8 style
ummae 6c9a2e6
- Correct typo/PEP8 style
ummae 209ce27
Merge branch 'master' of github.com:ummae/happybase
ummae c5761f6
Add more tests
ummae 3ab00d2
Change parameter type as dict from iteratble data types
ummae ff5c525
Correct typo
ummae 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -183,6 +183,34 @@ def test_atomic_counters(): | |
assert_equal(10, table.counter_dec(row, column, -7)) | ||
|
||
|
||
def test_multiple_counters(): | ||
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. Thanks, tests look good. |
||
row = 'row-with-counters' | ||
columns = ['cf1:counter1', 'cf1:counter2', 'cf1:counter3'] | ||
|
||
table.counters_inc(row, zip(columns, [0, 0, 0])) | ||
assert_equal([0, 0, 0], [table.counter_get(row, c) for c in columns]) | ||
|
||
table.counters_inc(row, zip(columns, [1, 3, 5])) | ||
assert_equal([1, 3, 5], [table.counter_get(row, c) for c in columns]) | ||
|
||
table.counters_inc(row, zip(columns, [-1, -3, -5])) | ||
assert_equal([0, 0, 0], [table.counter_get(row, c) for c in columns]) | ||
|
||
for col, delta in zip(columns, [1, 3, 5]): | ||
table.counters_inc(row, [(col, delta)]) | ||
assert_equal(delta, table.counter_get(row, col)) | ||
table.counter_dec(row, [(col, -delta)]) | ||
assert_equal(0, table.counter_get(row, col)) | ||
|
||
table.counters_inc(row, zip(columns, [1, 3, 5])) | ||
table.counters_inc(row, zip(columns, [1, 3, 5])) | ||
assert_equal([2, 6, 10], [table.counter_get(row, c) for c in columns]) | ||
|
||
table.counters_inc(row, zip(columns, [-1, -3, -5])) | ||
table.counters_inc(row, zip(columns, [-1, -3, -5])) | ||
assert_equal([0, 0, 0], [table.counter_get(row, c) for c in columns]) | ||
|
||
|
||
def test_batch(): | ||
with assert_raises(TypeError): | ||
table.batch(timestamp='invalid') | ||
|
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.
Why not simply require a
dict
here?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.
About type of
data
? I think that iterable collections are more general and efficiency thandict
, especially for bunch of data processing, and alsodict
can be used withiteritems
method. But it seems a little bit verbose...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.
Do you have any numbers to back up this claim? In the end everything will be pulled into memory anyway when constructing the
TIncrement
instances, and using adict
won't really add much overhead. Other parts of the Happybase API extensively usedict
as well, so I'm inclined to require adict
here as well for consistency.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.
I see.. yes you're right. At the end the data will be wrapped as '''TIncrement''' anyway. ;)
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.
Though you're right that passing a dict will result in stuff in memory twice, but I think it's not a problem.