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
# -*- ksh -*- | |
# | |
# If you use the GNU debugger gdb to debug the Python C runtime, you | |
# might find some of the following commands useful. Copy this to your | |
# ~/.gdbinit file and it'll get loaded into gdb automatically when you | |
# start it up. Then, at the gdb prompt you can do things like: | |
# | |
# (gdb) pyo apyobjectptr | |
# <module 'foobar' (built-in)> | |
# refcounts: 1 |
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
cqlsh:keyspace1> UPDATE mentions SET mentions = 3 WHERE day = '01/05/11' AND item = 'acunu' AND time = 1; | |
cqlsh:keyspace1> select * from mentions; | |
day | item | time | mentions | |
----------+-------+------+---------- | |
01/05/11 | acunu | 1 | 3 | |
cqlsh:keyspace1> UPDATE mentions SET mentions = 5 WHERE day = '01/05/11' AND item = 'acunu' AND time = 2; | |
cqlsh:keyspace1> select * from mentions; |
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
cqlsh> CREATE KEYSPACE keyspace1 WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1' }; | |
cqlsh> use keyspace1; | |
cqlsh:keyspace1> CREATE TABLE cf3 ( key blob PRIMARY KEY, id varint, postcode text, price varint ) WITH COMPACT STORAGE; | |
cqlsh:keyspace1> CREATE INDEX cf3_id_idx ON cf3 (id) ; | |
cqlsh:keyspace1> CREATE INDEX cf3_price_idx ON cf3 (price) ; | |
cqlsh:keyspace1> DESCRIBE COLUMNFAMILY keyspace1.cf3; | |
CREATE TABLE cf3 ( | |
key blob PRIMARY KEY, | |
id varint, |
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
<?php | |
require_once(__DIR__.'/lib/autoload.php'); | |
use phpcassa\Connection\ConnectionPool; | |
use phpcassa\ColumnFamily; | |
use phpcassa\Index\IndexExpression; | |
use phpcassa\Index\IndexClause; | |
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
~/pycassa (master)$ ./pycassaShell -k Keyspace1 | |
---------------------------------- | |
Cassandra Interactive Python Shell | |
---------------------------------- | |
Keyspace: Keyspace1 | |
Host: localhost:9160 | |
Available ColumnFamily instances: | |
* CF1 ( CF1 ) |
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
<?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 |
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
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 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) |
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
[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 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 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') |