Custom Search

Wednesday, March 18, 2015

Getting Started Using the Cassandra CLI

1)
Open cassandra cli

#cassandra-cli

[..] help;
[..] show keyspaces;
[..] show schema
[..] use config_db_uuid: <== select a keyspace/database
[..]List obj_uuid_table <== Reading Rows and Columns of a table



* Cassandra stores all data internally as hex byte arrays by default. If you do not specify a default row key validation class, column comparator and column validation class when you define the column family, Cassandra CLI will expect input data for row keys, column names, and column values to be in hex format (and data will be returned in hex format).
http://www.datastax.com/docs/1.1/dml/using_cli

2)
Query from table with id


[..] get obj_uuid_table[utf8('d123ad89-f047-40ee-8878-4b9b05dfa513')];
<=== passing id of ipam in utf8()
=> (name=66715f6e616d65, value=["default-domain", "admin", "ipam34"], timestamp=1426111375529317)
=> (name=706172656e743a70726f6a6563743a35663037653331622d643961382d346539392d613963642d663039643161663164623231, value=null, timestamp=1426111375529098)
=> (name=706172656e745f74797065, value="project", timestamp=1426111375529317)
=> (name=70726f703a646973706c61795f6e616d65, value="ipam34", timestamp=1426111375529289)
=> (name=70726f703a69645f7065726d73, value={"enable": true, "uuid": {"uuid_mslong": 15070079586065137902, "uuid_lslong": 9833692915554034963}, "creator": null, "created": "2015-03-11T22:02:55.529187", "user_visible": true, "last_modified": "2015-03-11T22:02:55.529187", "permissions": {"owner": "cloud-admin", "owner_access": 7, "other_access": 7, "group": "admin", "group_access": 7}, "description": null}, timestamp=1426111375529239)
=> (name=70726f703a6e6574776f726b5f6970616d5f6d676d74, value={"ipam_dns_method": "default-dns-server", "ipam_dns_server": {"tenant_dns_server_address": {}, "virtual_dns_server_name": null}}, timestamp=1426111375529153)
=> (name=74797065, value="network_ipam", timestamp=1426111375529317)
Returned 7 results.
Elapsed time: 20 msec(s).
[..]

OR

[..]ASSUME obj_uuid_table KEYS AS utf8
[..]get obj_uuid_table['d123ad89-f047-40ee-8878-4b9b05dfa513'];



3)

Convert hex values into a human-readable format

ASSUME obj_uuid_table KEYS AS utf8;
ASSUME obj_uuid_table COMPARATOR AS utf8;
ASSUME obj_uuid_table VALIDATOR AS utf8;


OR

ASSUME obj_uuid_table KEYS AS ascii;
ASSUME obj_uuid_table COMPARATOR AS ascii;
ASSUME obj_uuid_table VALIDATOR AS ascii;


[..]List obj_uuid_table <== Reading Rows and Columns of a table


No comments:

Post a Comment