cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Cassandra Wiki] Update of "CassandraCli" by MatthewChurcher
Date Sun, 18 Dec 2011 01:05:48 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Cassandra Wiki" for change notification.

The "CassandraCli" page has been changed by MatthewChurcher:
http://wiki.apache.org/cassandra/CassandraCli?action=diff&rev1=39&rev2=40

Comment:
It did a major clean up as the previous format didn't work for me with Cassandra 1.0 and it
was hard to track down the issue because format was hard to follow.

- Cassandra ships with a very basic interactive command line interface. Using the CLI you
can connect to remote nodes in the cluster to create or update your schema and set and retrieve
records. 
+ Cassandra ships with a very basic interactive command line interface. Using the CLI you
can connect to remote nodes in the cluster to create or update your schema and set and retrieve
records.
  
  The examples below have been tested with Cassandra 1.0.6. For instructions for previous
versions of Cassandra see one of: [[CassandraCli07]], [[CassandraCli06]].
  a
@@ -18, +18 @@

  
  == Creating a Keyspace ==
  We first create a keyspace to run our examples in.
- 
+ {{{
- {{{ create keyspace Twissandra; }}}
+ create keyspace Twissandra;
+ }}}
  
  == Selecting the keyspace to user ==
  We must then select our example keyspace as our new context before we can run any queries.
- 
+ {{{
- {{{ use Twissandra; }}}
+ use Twissandra;
+ }}}
  
  == To Create A Column ==
  We can then create a column to play with.
- 
+ {{{
- {{{create column family User with comparator = UTF8Type;}}}
+ create column family User with comparator = UTF8Type;
+ }}}
  
  For the later examples to work you must also update the schema using the following command.
This will set the return type for the first and last name to make them human readable. It
will also add and index for the age field so that you filter your gets using the Users name
field.
  {{{
- update column family User with                                                         
                              
+ update column family User with
- 	column_metadata = 
+ 	column_metadata =
  	[
  	{column_name: first, validation_class: UTF8Type},
  	{column_name: last, validation_class: UTF8Type},
@@ -46, +49 @@

  To add data we want to into our new column we must first specify our default key type otherwise
we would have to specify it for each key using the format {{{[utf8('keyname')]}}} this is
probably advisable if you have mixed key types but makes simple cases harder to read.
  
  So we run the command below, which will last the length of you cli session. On quitting
and restarting we must run it again.
- 
+ {{{
- {{{assume User keys as utf8;}}} 
+ assume User keys as utf8;
+ }}}
  
  and then we add our data.
- 
  {{{
  set User['jsmith']['first'] = 'John';
  set User['jsmith']['last'] = 'Smith';
@@ -62, +65 @@

  ''' The set command uses [[API#insert]]'''
  == To Update Data ==
  If we need to update a value we simply set it again.
- 
+ {{{
- {{{set User['jsmith']['first'] = 'Jack';}}}
+ set User['jsmith']['first'] = 'Jack';
+ }}}
  
  == To Get Data ==
  Now let's read back the `jsmith` row to see what it contains:
- 
+ {{{
- {{{get User['jsmith'];}}}
+ get User['jsmith'];
+ }}}
  
  ''' The get command uses [[API#get_slice]]'''
  
  == To Query Data ==
+ {{{
- {{{ get User where age = '12'; }}}
+ get User where age = '12';
+ }}}
  
  == For  help ==
- {{{ help; }}}
+ {{{
+ help;
+ }}}
  
  == To Quit ==
- {{{ quit; }}}
+ {{{
+ quit;
+ }}}
  
  == To Execute Script ==
+ {{{
- {{{bin/cassandra-cli -host localhost -port 9160 -f script.txt}}}
+ bin/cassandra-cli -host localhost -port 9160 -f script.txt
+ }}}
  

Mime
View raw message