You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Holger Hoffstaette <ho...@googlemail.com> on 2012/06/12 17:40:31 UTC

Odd problem with cli and display of value types

While trying to play around with 1.1.1 and secondary indexes I just
noticed something odd in cassandra-cli. Example straight from the README:

--> show Mr. Smith

holger>cassandra-cli
[..]
[default@Users] list users;
Using default limit of 100
Using default column limit of 100
-------------------
RowKey: jsmith
=> (column=first, value=John, timestamp=1339507271651000)
=> (column=last, value=Smith, timestamp=1339507280745000)

1 Row Returned.
Elapsed time: 0 msec(s).

--> Hello Mr. Smith with no age.
--> You should be 64 years old:

[default@Users] set Users[jsmith][age] = long(64);
Value inserted.
Elapsed time: 16 msec(s).

[default@Users] list users;
Using default limit of 100
Using default column limit of 100
-------------------
RowKey: jsmith
=> (column=age, value=64, timestamp=1339513585914000)
=> (column=first, value=John, timestamp=1339507271651000)
=> (column=last, value=Smith, timestamp=1339507280745000)

1 Row Returned.
Elapsed time: 0 msec(s).
[default@Users]

--> That worked, as expected. Exit & restart the cli

holger>cassandra-cli
[..]
[default@Users] list users;
Using default limit of 100
Using default column limit of 100
-------------------
RowKey: jsmith
=> (column=age, value=       @, timestamp=1339513585914000)
=> (column=first, value=John, timestamp=1339507271651000)
=> (column=last, value=Smith, timestamp=1339507280745000)

1 Row Returned.
Elapsed time: 78 msec(s).
[default@Users]

// age=@ you say?

I understand of course that since the default validation class is set to
UTF8 I should have inserted '64' as age and not the long(64) as given in
the README - probably an oversight/bug/typo. The README uses 42 as value,
which results in a * as output. To verify the behaviour I used 64, which
is the ASCII value of @.

What I find more curious is that the cli displays the value in
human-readable form immediately after insertion, yet a new session
displays it in "native" form (as it should). Should it not always display
the value according to the validation class, i.e. show the @ immediately
after insertion?

thanks,
Holger



Re: Odd problem with cli and display of value types

Posted by aaron morton <aa...@thelastpickle.com>.
The set with the type casts updates the client side column meta data with the type (just like assume does). So after the first set the client will act as if you said

assume users validator as long;

In this case it's not particularly helpful. Can you add a trivial ticket to https://issues.apache.org/jira/browse/CASSANDRA to update the example ?

Thanks


-----------------
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com

On 13/06/2012, at 3:40 AM, Holger Hoffstaette wrote:

> 
> While trying to play around with 1.1.1 and secondary indexes I just
> noticed something odd in cassandra-cli. Example straight from the README:
> 
> --> show Mr. Smith
> 
> holger>cassandra-cli
> [..]
> [default@Users] list users;
> Using default limit of 100
> Using default column limit of 100
> -------------------
> RowKey: jsmith
> => (column=first, value=John, timestamp=1339507271651000)
> => (column=last, value=Smith, timestamp=1339507280745000)
> 
> 1 Row Returned.
> Elapsed time: 0 msec(s).
> 
> --> Hello Mr. Smith with no age.
> --> You should be 64 years old:
> 
> [default@Users] set Users[jsmith][age] = long(64);
> Value inserted.
> Elapsed time: 16 msec(s).
> 
> [default@Users] list users;
> Using default limit of 100
> Using default column limit of 100
> -------------------
> RowKey: jsmith
> => (column=age, value=64, timestamp=1339513585914000)
> => (column=first, value=John, timestamp=1339507271651000)
> => (column=last, value=Smith, timestamp=1339507280745000)
> 
> 1 Row Returned.
> Elapsed time: 0 msec(s).
> [default@Users]
> 
> --> That worked, as expected. Exit & restart the cli
> 
> holger>cassandra-cli
> [..]
> [default@Users] list users;
> Using default limit of 100
> Using default column limit of 100
> -------------------
> RowKey: jsmith
> => (column=age, value=       @, timestamp=1339513585914000)
> => (column=first, value=John, timestamp=1339507271651000)
> => (column=last, value=Smith, timestamp=1339507280745000)
> 
> 1 Row Returned.
> Elapsed time: 78 msec(s).
> [default@Users]
> 
> // age=@ you say?
> 
> I understand of course that since the default validation class is set to
> UTF8 I should have inserted '64' as age and not the long(64) as given in
> the README - probably an oversight/bug/typo. The README uses 42 as value,
> which results in a * as output. To verify the behaviour I used 64, which
> is the ASCII value of @.
> 
> What I find more curious is that the cli displays the value in
> human-readable form immediately after insertion, yet a new session
> displays it in "native" form (as it should). Should it not always display
> the value according to the validation class, i.e. show the @ immediately
> after insertion?
> 
> thanks,
> Holger
> 
>