Skip to content

Instantly share code, notes, and snippets.

@jimjamdev
Last active September 24, 2015 12:22
Show Gist options
  • Save jimjamdev/6a31013304688b0053a2 to your computer and use it in GitHub Desktop.
Save jimjamdev/6a31013304688b0053a2 to your computer and use it in GitHub Desktop.
Cassandra table set-up example
// Drop table
DROP TABLE cdr;
// Set up table
CREATE TABLE cdr (
id uuid,
imsi bigint,
calling_gt bigint,
timestamp timestamp,
text varchar,
modules map<text, text>,
PRIMARY KEY (id, imsi, calling_gt, timestamp)
);
// Create Indexes
CREATE INDEX ON cdr (ENTRIES(value));
// For 2.1 you can't get an index on collection key->value, just the KEY
//CREATE INDEX modules ON cdr (KEYS(modules));
// Insert some sample data
INSERT INTO cdr (id, imsi, calling_gt, timestamp, modules) VALUES (now(), 39779095086, 33167180472, 372832526, {'HardBlockGT_action':'1', 'HardBlockGT_matched_rule_id':'0','HardBlockGT_matched_rule_name':'1','BulkGuard_action':'0'});
INSERT INTO cdr (id, imsi, calling_gt, timestamp, modules) VALUES (now(), 39779095087, 33167180473, 372832527, {'HardBlockGT_action':'0', 'HardBlockGT_matched_rule_id':'1','HardBlockGT_matched_rule_name':'0','BulkGuard_action':'0'});
INSERT INTO cdr (id, imsi, calling_gt, timestamp, modules) VALUES (now(), 39779095088, 33167180474, 372832528, {'HardBlockGT_action':'1', 'HardBlockGT_matched_rule_id':'0','HardBlockGT_matched_rule_name':'1','BulkGuard_action':'1'});
INSERT INTO cdr (id, imsi, calling_gt, timestamp, modules) VALUES (now(), 39779095089, 33167180475, 372832529, {'HardBlockGT_action':'0', 'HardBlockGT_matched_rule_id':'1','HardBlockGT_matched_rule_name':'1','BulkGuard_action':'1'});
INSERT INTO cdr (id, imsi, calling_gt, timestamp, modules) VALUES (now(), 39779095010, 33167180476, 372832530, {'HardBlockGT_action':'1', 'HardBlockGT_matched_rule_id':'0','HardBlockGT_matched_rule_name':'0','BulkGuard_action':'0'});
INSERT INTO cdr (id, imsi, calling_gt, timestamp, modules) VALUES (now(), 39779095011, 33167180477, 372832536, {'HardBlockGT_action':'0', 'HardBlockGT_matched_rule_id':'1','HardBlockGT_matched_rule_name':'0','BulkGuard_action':'1'});
INSERT INTO cdr (id, imsi, calling_gt, timestamp, modules) VALUES (now(), 39779095012, 33167180478, 372832536, {'HardBlockGT_action':'1', 'HardBlockGT_matched_rule_id':'0','HardBlockGT_matched_rule_name':'1','BulkGuard_action':'1'});
INSERT INTO cdr (id, imsi, calling_gt, timestamp, modules) VALUES (now(), 39779095013, 33167180479, 372832546, {'HardBlockGT_action':'0', 'HardBlockGT_matched_rule_id':'1','HardBlockGT_matched_rule_name':'0','BulkGuard_action':'0'});
INSERT INTO cdr (id, imsi, calling_gt, timestamp, modules) VALUES (now(), 39779095014, 33167180480, 372832556, {'HardBlockGT_action':'1', 'HardBlockGT_matched_rule_id':'1','HardBlockGT_matched_rule_name':'0','BulkGuard_action':'1'});
INSERT INTO cdr (id, imsi, calling_gt, timestamp, modules) VALUES (now(), 39779095015, 33167180481, 372832566, {'HardBlockGT_action':'0', 'HardBlockGT_matched_rule_id':'0','HardBlockGT_matched_rule_name':'1','BulkGuard_action':'1'});
INSERT INTO cdr (id, imsi, calling_gt, timestamp, modules) VALUES (now(), 39779095016, 33167180482, 372832576, {'HardBlockGT_action':'1', 'HardBlockGT_matched_rule_id':'1','HardBlockGT_matched_rule_name':'0','BulkGuard_action':'1'});
INSERT INTO cdr (id, imsi, calling_gt, timestamp, modules) VALUES (now(), 39779095017, 33167180483, 372832586, {'HardBlockGT_action':'0', 'HardBlockGT_matched_rule_id':'1','HardBlockGT_matched_rule_name':'0','BulkGuard_action':'0'});
INSERT INTO cdr (id, imsi, calling_gt, timestamp, modules) VALUES (now(), 39779095018, 33167180484, 372832596, {'HardBlockGT_action':'1', 'HardBlockGT_matched_rule_id':'1','HardBlockGT_matched_rule_name':'1','BulkGuard_action':'1'});
INSERT INTO cdr (id, imsi, calling_gt, timestamp, modules) VALUES (now(), 39779095019, 33167180485, 372832516, {'HardBlockGT_action':'0', 'HardBlockGT_matched_rule_id':'1','HardBlockGT_matched_rule_name':'0','BulkGuard_action':'1'});
INSERT INTO cdr (id, imsi, calling_gt, timestamp, modules) VALUES (now(), 39779095020, 33167180486, 372832553, {'HardBlockGT_action':'0', 'HardBlockGT_matched_rule_id':'0','HardBlockGT_matched_rule_name':'0','BulkGuard_action':'0'});
INSERT INTO cdr (id, imsi, calling_gt, timestamp, modules) VALUES (now(), 39779095021, 33167180487, 372832545, {'HardBlockGT_action':'1', 'HardBlockGT_matched_rule_id':'1','HardBlockGT_matched_rule_name':'0','BulkGuard_action':'1'});
INSERT INTO cdr (id, imsi, calling_gt, timestamp, modules) VALUES (now(), 39779095022, 33167180488, 372832545, {'HardBlockGT_action':'0', 'HardBlockGT_matched_rule_id':'1','HardBlockGT_matched_rule_name':'1','BulkGuard_action':'1'});
INSERT INTO cdr (id, imsi, calling_gt, timestamp, modules) VALUES (now(), 39779095023, 33167180489, 372832545, {'HardBlockGT_action':'1', 'HardBlockGT_matched_rule_id':'1','HardBlockGT_matched_rule_name':'0','BulkGuard_action':'0'});
INSERT INTO cdr (id, imsi, calling_gt, timestamp, modules) VALUES (now(), 39779095024, 33167180490, 372832545, {'HardBlockGT_action':'0', 'HardBlockGT_matched_rule_id':'0','HardBlockGT_matched_rule_name':'0','BulkGuard_action':'1'});
INSERT INTO cdr (id, imsi, calling_gt, timestamp, modules) VALUES (now(), 39779095025, 33167180491, 372832564, {'HardBlockGT_action':'1', 'HardBlockGT_matched_rule_id':'1','HardBlockGT_matched_rule_name':'1','BulkGuard_action':'0'});
INSERT INTO cdr (id, imsi, calling_gt, timestamp, modules) VALUES (now(), 39779095026, 33167180492, 372832564, {'HardBlockGT_action':'1', 'HardBlockGT_matched_rule_id':'1','HardBlockGT_matched_rule_name':'0','BulkGuard_action':'1'});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment