This file contains 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 | |
import logging | |
log = logging.getLogger() | |
log.setLevel('DEBUG') | |
handler = logging.StreamHandler() | |
handler.setFormatter(logging.Formatter("%(asctime)s [%(levelname)s] %(name)s: %(message)s")) | |
log.addHandler(handler) |
This file contains 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 | |
import logging | |
log = logging.getLogger() | |
log.setLevel('INFO') | |
handler = logging.StreamHandler() | |
handler.setFormatter(logging.Formatter("%(asctime)s [%(levelname)s] %(name)s: %(message)s")) | |
log.addHandler(handler) |
This file contains 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 resource | |
import gc | |
from guppy import hpy | |
def print_heap(hp): | |
h = hp.heap() | |
strs = [] | |
strs.extend(str(h).split('\n')[1:-1]) | |
for i in range(10): |
This file contains 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
#! /bin/bash | |
while true; do | |
echo "stopping node1" | |
./ccm node1 stop | |
sleep 1 | |
echo "starting node1" | |
./ccm node1 start |
This file contains 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
index 7abca4f..c451f90 100644 | |
--- a/pycassa/connection.py | |
+++ b/pycassa/connection.py | |
@@ -47,6 +47,7 @@ class ClientTransport(object): | |
"""Encapsulation of a client session.""" | |
def __init__(self, keyspace, server, framed_transport, timeout, credentials, recycle): | |
+ self.server = server | |
host, port = server.split(":") | |
socket = TSocket.TSocket(host, int(port)) |
This file contains 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 DatetimeStingType(pycassa.types.CassandraType): | |
def __init__(self): | |
self.pack = lambda dtime: dtime.strftime('%Y-%m-%d') | |
self.unpack = lambda dtime_str: datetime.strptime('%Y-%m-%d') |
This file contains 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
[default@unknown] connect localhost/9160; | |
Connected to: "Test Cluster" on localhost/9160 | |
[default@unknown] create keyspace Foo; | |
b2461b50-838a-11e1-0000-242d50cf1ffe | |
Waiting for schema agreement... | |
... schemas agree across the cluster | |
[default@unknown] use Foo; | |
Authenticated to keyspace: Foo | |
[default@Foo] CREATE COLUMN FAMILY mycf | |
... WITH column_type = 'Standard' |
This file contains 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) |
This file contains 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
CREATE TABLE scores ( | |
some_partition_key text, | |
score int, | |
test_id uuid, | |
field_a text, | |
field_b text, | |
PRIMARY KEY (some_partition_key, score, test_id) | |
); |
This file contains 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
<?php | |
$cf->return_format = ColumnFamily::ARRAY_FORMAT; | |
function get_page($cf, $key, $page, $page_size) { | |
$start_col = ""; | |
$current_page = 0; | |
$page_data = null; | |
while ($current_page < $page) { | |
// fetch one extra column at the end |
OlderNewer