cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Filipe Gonçalves <the.wa.syndr...@gmail.com>
Subject Re: Setting Key Validation Class
Date Mon, 05 Dec 2011 16:46:39 GMT
Cassandra's data model is NOT table based. The key is not a column, it
is a separate value.  "index_type: KEYS" means you are creating an
index on that column, and that index can only be acessed in an
equality query ( column = x ).

You should probably read http://www.datastax.com/docs/1.0/ddl/index first.

2011/12/5 Dinusha Dilrukshi <sdddilrukshi@gmail.com>:
> Hi,
>
> I am using apache-cassandra-1.0.0 and I tried to insert/retrieve data in a
> column family using cassandra-jdbc program.
> Here is how I created 'USER' column family using cassandra-cli.
>
> create column family USER with comparator=UTF8Type
> and column_metadata=[{column_name: user_id, validation_class: UTF8Type,
> index_type: KEYS},
> {column_name: username, validation_class: UTF8Type, index_type: KEYS},
> {column_name: password, validation_class: UTF8Type}];
>
> But, when i try to insert data to USER column family it gives the error
> "java.sql.SQLException: Mismatched types: java.lang.String cannot be cast to
> java.nio.ByteBuffer".
>
> Since I have set user_id as a KEY and it's validation_class as UTF8Type, I
> was expected Key Validation Class as UTF8Type.
> But when I look at the meta-data of USER column family it shows as "Key
> Validation Class: org.apache.cassandra.db.marshal.BytesType" which has cause
> for the above error.
>
> When I created USER column family as follows, it solves the above issue.
>
> create column family USER with comparator=UTF8Type and
> key_validation_class=UTF8Type
> and column_metadata=[{column_name: user_id, validation_class: UTF8Type,
> index_type: KEYS},
> {column_name: username, validation_class: UTF8Type, index_type: KEYS},
> {column_name: password, validation_class: UTF8Type}];
>
> Do we always need to define key_validation_class as in the above query ?
> Isn't it not enough to add validation classes for each column ?
>
> Regards,
> ~Dinusha~
>



-- 
Filipe Gonçalves

Mime
View raw message