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
| """ | |
| Simple Linear Probabilistic Counters | |
| Credit for idea goes to: | |
| http://highscalability.com/blog/2012/4/5/big-data-counting-how-to-count-a-billion-distinct-objects-us.html | |
| http://highlyscalable.wordpress.com/2012/05/01/probabilistic-structures-web-analytics-data-mining/ | |
| Installation: | |
| pip install smhasher | |
| pip install bitarray |
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
| import json | |
| from pycassa.pool import ConnectionPool | |
| from pycassa.columnfamily import ColumnFamily | |
| from pycassa.cassandra.ttypes import ConsistencyLevel, NotFoundException | |
| HOSTS = ['localhost'] | |
| pool = ConnectionPool('my_keyspace', HOSTS) | |
| my_cf = ColumnFamily(pool, 'my_cf') |
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
| for ks in SYSTEM_MANAGER.list_keyspaces(): | |
| describe_keyspace(ks) | |
| for cf in SYSTEM_MANAGER.get_keyspace_column_families(ks): | |
| describe_column_family(ks, cf) |
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
| for args in tables_for_load: | |
| thread = FileLoaderWorker(*args) | |
| thread.start() | |
| completed = 0 | |
| while completed < len(tables_for_load): | |
| try: | |
| response, exception = response_queue.get(block=False, timeout=0.1) | |
| if exception: |
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
| class Result(threading.Event): | |
| exception = None | |
| def execute(): | |
| cql = 'select * from events limit 10' | |
| response = Result() | |
| def _on_error(error): | |
| response.exception = error |
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
| ui: mocha-qunit | |
| browsers: | |
| - name:chrome | |
| - version: latest | |
| scripts: | |
| - "http://d8rk54i4mohrb.cloudfront.net/js/reach.js" | |
| server: ./server.js |
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
| class TunableRetryPolicy(RetryPolicy): | |
| """ A retry policy that allows you to decide if you want to downgrade consistency before | |
| attempting to retry, additionally, you can specify the number of retries to try | |
| """ | |
| def __init__(self, read_retries=3, write_retries=3, downgrade_consistency=True): | |
| self._read_retries = read_retries | |
| self._write_retries = write_retries | |
| self._downgrade_consistency = downgrade_consistency |
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
| #!/usr/bin/env python | |
| """ | |
| Counts the number of tombstones in a keyspace.table and reports the top N highest counts | |
| tombstone_count.py | |
| [-h] This help screen | |
| [--data-dir DATA_DIR] The C* data directory (/var/lib/cassandra/data) | |
| [--top-k TOP_K] The top number of keys with highest tombstone counts to display. | |
| keyspace The keyspace that contains the table |
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
| import fileinput, re, operator | |
| from collections import Counter | |
| def sizeof_fmt(num, suffix='B'): | |
| for unit in ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi']: | |
| if abs(num) < 1024.0: | |
| return "%3.1f%s%s" % (num, unit, suffix) | |
| num /= 1024.0 | |
| return "%.1f%s%s" % (num, 'Yi', suffix) |
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
| #!/usr/bin/env python | |
| from __future__ import print_function | |
| import json | |
| import logging | |
| import re | |
| from base64 import b64decode, b64encode | |
| from urllib2 import Request, urlopen, URLError, HTTPError |