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

Counter Batches and Reverse table scans #96

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

philip-sterne
Copy link

  • Ability to batch counter increments and decrements. This functions in exactly the same form as table.batch(), except one now calls:
cb = table.counter_batch()
cb.counter_inc('row-key', 'cf1:counter1')
cb.counter_inc('row-key', 'cf1:counter2')
cb.send()

Or alternatively, one can use a context manager:

with table.counter_batch(batch_size=1000) as cb:
    cb.counter_inc('row-key', 'cf1:counter1')
    cb.counter_inc('row-key', 'cf1:counter2')
  • Added reverse table scans:
for key, data in table.scan(reverse=True):
    print key, data

which will return the data in reversed order

@landscape-bot
Copy link

Code Health
Repository health increased by 0.31% when pulling c9048bf on TAKEALOT:master into 9cbd718 on wbolster:master.

@landscape-bot
Copy link

Code Health
Repository health increased by 0.35% when pulling 6663a88 on TAKEALOT:master into 9cbd718 on wbolster:master.

@landscape-bot
Copy link

Code Health
Repository health increased by 0.33% when pulling 2d4ed1f on TAKEALOT:master into 9cbd718 on wbolster:master.


def counter_inc(self, row, column, value=1):
self.batch[(row, column)] += value
self.batch_count += 1
Copy link
Member

Choose a reason for hiding this comment

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

i think this is incorrect. if the (row, column) tuple was already present this count will be wrong. i guess len(self.batch) is a better count ;)

@gabrii
Copy link

gabrii commented Jun 12, 2018

I've solved the merge conflicts and the patch_counter problem, out of the need to use this in pyhton3. Third PR about this feature. Time to merge! :)
#192

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.

5 participants