mirror of https://github.com/apache/cassandra
fix cli value conversion, update readme
patch by Pavel Yaskevich and jbellis for CASSANDRA-1635 git-svn-id: https://svn.apache.org/repos/asf/cassandra/trunk@1025705 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fad1f92bdb
commit
da5a3dfeba
44
README.txt
44
README.txt
|
|
@ -43,45 +43,51 @@ remain in the foreground and log to standard out.
|
||||||
|
|
||||||
Now let's try to read and write some data using the command line client.
|
Now let's try to read and write some data using the command line client.
|
||||||
|
|
||||||
* bin/cassandra-cli --host localhost --port 9160
|
* bin/cassandra-cli --host localhost
|
||||||
|
|
||||||
The command line client is interactive so if everything worked you should
|
The command line client is interactive so if everything worked you should
|
||||||
be sitting in front of a prompt...
|
be sitting in front of a prompt...
|
||||||
|
|
||||||
Connected to localhost/9160
|
Connected to: "Test Cluster" on localhost/9160
|
||||||
Welcome to cassandra CLI.
|
Welcome to cassandra CLI.
|
||||||
|
|
||||||
Type 'help' or '?' for help. Type 'quit' or 'exit' to quit.
|
Type 'help' or '?' for help. Type 'quit' or 'exit' to quit.
|
||||||
cassandra>
|
[default@unknown]
|
||||||
|
|
||||||
As the banner says, you can use 'help' or '?' to see what the CLI has to
|
As the banner says, you can use 'help' or '?' to see what the CLI has to
|
||||||
offer, and 'quit' or 'exit' when you've had enough fun. But lets try
|
offer, and 'quit' or 'exit' when you've had enough fun. But lets try
|
||||||
something slightly more interesting...
|
something slightly more interesting...
|
||||||
|
|
||||||
cassandra> set Keyspace1.Standard2['jsmith']['first'] = 'John'
|
[default@unknown] create keyspace Keyspace1
|
||||||
|
ece86bde-dc55-11df-8240-e700f669bcfc
|
||||||
|
[default@unknown] use Keyspace1
|
||||||
|
Authenticated to keyspace: Keyspace1
|
||||||
|
[default@Keyspace1] create column family Users with comparator=UTF8Type
|
||||||
|
737c7a71-dc56-11df-8240-e700f669bcfc
|
||||||
|
|
||||||
|
[default@KS1] set Users[jsmith][first] = 'John'
|
||||||
Value inserted.
|
Value inserted.
|
||||||
cassandra> set Keyspace1.Standard2['jsmith']['last'] = 'Smith'
|
[default@KS1] set Users[jsmith][last] = 'Smith'
|
||||||
Value inserted.
|
Value inserted.
|
||||||
cassandra> set Keyspace1.Standard2['jsmith']['age'] = '42'
|
[default@KS1] set Users[jsmith][age] = long(42)
|
||||||
Value inserted.
|
Value inserted.
|
||||||
cassandra> get Keyspace1.Standard2['jsmith']
|
[default@KS1] get Users[jsmith]
|
||||||
(column=age, value=42; timestamp=1249930062801)
|
=> (column=last, value=Smith, timestamp=1287604215498000)
|
||||||
(column=first, value=John; timestamp=1249930053103)
|
=> (column=first, value=John, timestamp=1287604214111000)
|
||||||
(column=last, value=Smith; timestamp=1249930058345)
|
=> (column=age, value=42, timestamp=1287604216661000)
|
||||||
Returned 3 rows.
|
Returned 3 results.
|
||||||
cassandra>
|
|
||||||
|
|
||||||
If your session looks similar to what's above, congrats, your single node
|
If your session looks similar to what's above, congrats, your single node
|
||||||
cluster is operational! But what exactly was all of that? Let's break it
|
cluster is operational! But what exactly was all of that? Let's break it
|
||||||
down into pieces and see.
|
down into pieces and see.
|
||||||
|
|
||||||
set Keyspace1.Standard2['jsmith']['first'] = 'John'
|
set Users[jsmith][first] = 'John'
|
||||||
\ \ \ \ \
|
\ \ \ \
|
||||||
\ \ \_ key \ \_ value
|
\ \_ key \ \_ value
|
||||||
\ \ \_ column
|
\ \_ column
|
||||||
\_ keyspace \_ column family
|
\_ column family
|
||||||
|
|
||||||
Data stored in Cassandra is associated with a column family (Standard2),
|
Data stored in Cassandra is associated with a column family (Users),
|
||||||
which in turn is associated with a keyspace (Keyspace1). In the example
|
which in turn is associated with a keyspace (Keyspace1). In the example
|
||||||
above, we set the value 'John' in the 'first' column for key 'jsmith'.
|
above, we set the value 'John' in the 'first' column for key 'jsmith'.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -597,6 +597,9 @@ public class CliClient
|
||||||
new ColumnParent(columnFamily).setSuper_column(superColumnName),
|
new ColumnParent(columnFamily).setSuper_column(superColumnName),
|
||||||
new SlicePredicate().setColumn_names(null).setSlice_range(range), ConsistencyLevel.ONE);
|
new SlicePredicate().setColumn_names(null).setSlice_range(range), ConsistencyLevel.ONE);
|
||||||
int size = columns.size();
|
int size = columns.size();
|
||||||
|
|
||||||
|
AbstractType validator;
|
||||||
|
CfDef cfDef = getCfDef(columnFamily);
|
||||||
|
|
||||||
// Print out super columns or columns.
|
// Print out super columns or columns.
|
||||||
for (ColumnOrSuperColumn cosc : columns)
|
for (ColumnOrSuperColumn cosc : columns)
|
||||||
|
|
@ -607,16 +610,20 @@ public class CliClient
|
||||||
|
|
||||||
css_.out.printf("=> (super_column=%s,", formatSuperColumnName(keyspace, columnFamily, superColumn));
|
css_.out.printf("=> (super_column=%s,", formatSuperColumnName(keyspace, columnFamily, superColumn));
|
||||||
for (Column col : superColumn.getColumns())
|
for (Column col : superColumn.getColumns())
|
||||||
|
{
|
||||||
|
validator = getValidatorForValue(cfDef, col.getName());
|
||||||
css_.out.printf("\n (column=%s, value=%s, timestamp=%d)", formatSubcolumnName(keyspace, columnFamily, col),
|
css_.out.printf("\n (column=%s, value=%s, timestamp=%d)", formatSubcolumnName(keyspace, columnFamily, col),
|
||||||
new String(col.value, "UTF-8"), col.timestamp);
|
validator.getString(col.value), col.timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
css_.out.println(")");
|
css_.out.println(")");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Column column = cosc.column;
|
Column column = cosc.column;
|
||||||
|
validator = getValidatorForValue(cfDef, column.getName());
|
||||||
css_.out.printf("=> (column=%s, value=%s, timestamp=%d)\n", formatColumnName(keyspace, columnFamily, column),
|
css_.out.printf("=> (column=%s, value=%s, timestamp=%d)\n", formatColumnName(keyspace, columnFamily, column),
|
||||||
new String(column.value, "UTF-8"), column.timestamp);
|
validator.getString(column.value), column.timestamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue