Created
April 19, 2012 04:38
-
-
Save thobbs/2418598 to your computer and use it in GitHub Desktop.
Pycassa super column test
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 time, logging | |
import pycassa | |
from pycassa.system_manager import SystemManager, SIMPLE_STRATEGY | |
pycassa.PycassaLogger().get_logger().addHandler(logging.StreamHandler()) | |
sys = SystemManager() | |
if "Keyspace1" not in sys.list_keyspaces(): | |
sys.create_keyspace("Keyspace1", SIMPLE_STRATEGY, {"replication_factor": "1"}) | |
sys.create_column_family("Keyspace1", "CF1", super=True) | |
sys.close() | |
pool = pycassa.ConnectionPool("Keyspace1", timeout=5.0) | |
cf = pycassa.ColumnFamily(pool, "CF1") | |
subcols = dict((str(i), str(i)) for i in range(25)) | |
for i in range(0, 150000, 100): | |
print i | |
supercols = dict((str(j), subcols) for j in range(i, i+100)) | |
cf.insert('key', supercols) | |
time.sleep(5) | |
print "fetching super columns" | |
start = time.time() | |
res = cf.get('key', column_count=5000) | |
print "total time:", time.time() - start | |
pool.dispose() | |
cf.truncate() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment