You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Ruben Rubio Rey <tk...@gmail.com> on 2012/01/22 09:01:03 UTC

Playing around with Cassandra ... how did the value changed?

Hi Everyone,

I am getting started with Cassandra and I decided to play around with the
Example at 'getting started'.

The thing is that something happened that it does not make sense to me, it
looks like the value one value just changed from 38 to 8 after adding an
index.


[default@Twissandra] get User['jsmith'];
=> (*column=age, value=38*, timestamp=1327217985629000)
=> (column=first, value=74776974746572, timestamp=1327217843318000)
=> (column=last, value=536d697468, timestamp=1327217752256000)
=> (column=twitter, value=twitter, timestamp=1327217988179000)
Returned 4 results.
Elapsed time: 39 msec(s).

You can see that the column age the value is 38. I tried to test a search:

[default@Twissandra] get User where age = '38';
No indexed columns present in index clause with operator EQ

Ok, I had a missing index. I tried to add it

[default@Twissandra] update column family User with column_metadata =
[{column_name: age, validation_class: UTF8Type, index_type: KEYS}];
b59a9710-44cc-11e1-0000-242d50cf1fbf
Waiting for schema agreement...
... schemas agree across the cluster

I try again to search by the age ...
[default@Twissandra] get User where age = '38';
0 Row Returned.
Elapsed time: 23 msec(s).

I check the record to double check the age
[default@Twissandra] get User['jsmith'];
=> (*column=age, value=8*, timestamp=1327217985629000)
=> (column=first, value=74776974746572, timestamp=1327217843318000)
=> (column=last, value=536d697468, timestamp=1327217752256000)
=> (column=twitter, value=74776974746572, timestamp=1327217988179000)
Returned 4 results.
Elapsed time: 11 msec(s).

It changed !

[default@Twissandra] get User where age = '8';
-------------------
RowKey: jsmith
=> (*column=age, value=8*, timestamp=1327217985629000)
=> (column=first, value=74776974746572, timestamp=1327217843318000)
=> (column=last, value=536d697468, timestamp=1327217752256000)
=> (column=twitter, value=74776974746572, timestamp=1327217988179000)
1 Row Returned.
Elapsed time: 38 msec(s).

As I said I am quite new in Cassandra, so I am aware that I might be doing
something wrong. Any clue why the age changed from 38 to 8 ?


Some more information:

cassandra 1.0.7

$ java -showversion
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)

Regards,
Ruben

Re: Playing around with Cassandra ... how did the value changed?

Posted by Ruben Rubio Rey <tk...@gmail.com>.
Thanks for the response!

On Mon, Jan 23, 2012 at 12:18 AM, Tristan Seligmann <mithrandi@mithrandi.net
> wrote:

> On Sun, Jan 22, 2012 at 10:11 AM, Eric Czech <er...@nextbigsound.com>
> wrote:
> > That's likely because there wasn't previously a validation class for the
> > "age" column before you added that index.  In other words, the CLI
> doesn't
> > display values in a UTF8 format until you tell it to so I think the value
> > "8" is correct and you could check that by running the CLI command
> "assume
> > User validator as utf8" and querying the CF User (without the index)
> again
> > to see if you get "8" as the value for the age column.
>
> Note that 0x38 is the character "8" (in ASCII and UTF-8, at least),
> and I believe the CLI shows hex bytes when no validator class is
> specified (either by the column family, or an "assume" command being
> issued), so this explanation seems consistent.
> --
> mithrandi, i Ainil en-Balandor, a faer Ambar
>

Re: Playing around with Cassandra ... how did the value changed?

Posted by Tristan Seligmann <mi...@mithrandi.net>.
On Sun, Jan 22, 2012 at 10:11 AM, Eric Czech <er...@nextbigsound.com> wrote:
> That's likely because there wasn't previously a validation class for the
> "age" column before you added that index.  In other words, the CLI doesn't
> display values in a UTF8 format until you tell it to so I think the value
> "8" is correct and you could check that by running the CLI command "assume
> User validator as utf8" and querying the CF User (without the index) again
> to see if you get "8" as the value for the age column.

Note that 0x38 is the character "8" (in ASCII and UTF-8, at least),
and I believe the CLI shows hex bytes when no validator class is
specified (either by the column family, or an "assume" command being
issued), so this explanation seems consistent.
-- 
mithrandi, i Ainil en-Balandor, a faer Ambar

Re: Playing around with Cassandra ... how did the value changed?

Posted by Eric Czech <er...@nextbigsound.com>.
That's likely because there wasn't previously a validation class for the
"age" column before you added that index.  In other words, the CLI doesn't
display values in a UTF8 format until you tell it to so I think the value
"8" is correct and you could check that by running the CLI command "assume
User validator as utf8" and querying the CF User (without the index) again
to see if you get "8" as the value for the age column.

On Sun, Jan 22, 2012 at 1:01 AM, Ruben Rubio Rey <tk...@gmail.com> wrote:

> Hi Everyone,
>
> I am getting started with Cassandra and I decided to play around with the
> Example at 'getting started'.
>
> The thing is that something happened that it does not make sense to me, it
> looks like the value one value just changed from 38 to 8 after adding an
> index.
>
>
> [default@Twissandra] get User['jsmith'];
> => (*column=age, value=38*, timestamp=1327217985629000)
> => (column=first, value=74776974746572, timestamp=1327217843318000)
> => (column=last, value=536d697468, timestamp=1327217752256000)
> => (column=twitter, value=twitter, timestamp=1327217988179000)
> Returned 4 results.
> Elapsed time: 39 msec(s).
>
> You can see that the column age the value is 38. I tried to test a search:
>
> [default@Twissandra] get User where age = '38';
> No indexed columns present in index clause with operator EQ
>
> Ok, I had a missing index. I tried to add it
>
> [default@Twissandra] update column family User with column_metadata =
> [{column_name: age, validation_class: UTF8Type, index_type: KEYS}];
> b59a9710-44cc-11e1-0000-242d50cf1fbf
> Waiting for schema agreement...
> ... schemas agree across the cluster
>
> I try again to search by the age ...
> [default@Twissandra] get User where age = '38';
> 0 Row Returned.
> Elapsed time: 23 msec(s).
>
> I check the record to double check the age
> [default@Twissandra] get User['jsmith'];
> => (*column=age, value=8*, timestamp=1327217985629000)
> => (column=first, value=74776974746572, timestamp=1327217843318000)
> => (column=last, value=536d697468, timestamp=1327217752256000)
> => (column=twitter, value=74776974746572, timestamp=1327217988179000)
> Returned 4 results.
> Elapsed time: 11 msec(s).
>
> It changed !
>
> [default@Twissandra] get User where age = '8';
> -------------------
> RowKey: jsmith
> => (*column=age, value=8*, timestamp=1327217985629000)
> => (column=first, value=74776974746572, timestamp=1327217843318000)
> => (column=last, value=536d697468, timestamp=1327217752256000)
> => (column=twitter, value=74776974746572, timestamp=1327217988179000)
> 1 Row Returned.
> Elapsed time: 38 msec(s).
>
> As I said I am quite new in Cassandra, so I am aware that I might be doing
> something wrong. Any clue why the age changed from 38 to 8 ?
>
>
> Some more information:
>
> cassandra 1.0.7
>
> $ java -showversion
> java version "1.6.0_26"
> Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
> Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)
>
> Regards,
> Ruben
>