Skip to content

Instantly share code, notes, and snippets.

@thobbs
Created April 19, 2012 04:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thobbs/2418598 to your computer and use it in GitHub Desktop.
Save thobbs/2418598 to your computer and use it in GitHub Desktop.
Pycassa super column test
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