Quantcast

Inserting via thrift interface to column family created with Compound Key via cql3

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Inserting via thrift interface to column family created with Compound Key via cql3

Oleksandr Petrov
Hi,

I'm creating a table via cql3 query like:

CREATE TABLE posts (
  userid text,
  blog_name text,
  entry_title text,
  posted_at text,
  PRIMARY KEY (userid, blog_name)
)

After that i'm trying to insert into same column family via thrift interface, and i'm getting following exception: Not enough bytes to read value of component 0

             Cassandra.java:20833 org.apache.cassandra.thrift.Cassandra$batch_mutate_result.read
           TServiceClient.java:78 org.apache.thrift.TServiceClient.receiveBase
               Cassandra.java:964 org.apache.cassandra.thrift.Cassandra$Client.recv_batch_mutate
               Cassandra.java:950 org.apache.cassandra.thrift.Cassandra$Client.batch_mutate

Thrift client doesn't even display that column family when running describe_keyspace.


I may be missing something, and I realize that CQL3 is way to, but i'm still oblivious of wether it's even possible to combine cql3 and thrift things. 

--
alex p
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Inserting via thrift interface to column family created with Compound Key via cql3

Michael Kjellman
Are you using execute_cql3_query() ?

On Jan 30, 2013, at 7:31 AM, "Oleksandr Petrov" <[hidden email]> wrote:

> Hi,
>
> I'm creating a table via cql3 query like:
>
> CREATE TABLE posts (
>   userid text,
>   blog_name text,
>   entry_title text,
>   posted_at text,
>   PRIMARY KEY (userid, blog_name)
> )
>
> After that i'm trying to insert into same column family via thrift interface, and i'm getting following exception: Not enough bytes to read value of component 0
>
>              Cassandra.java:20833 org.apache.cassandra.thrift.Cassandra$batch_mutate_result.read
>            TServiceClient.java:78 org.apache.thrift.TServiceClient.receiveBase
>                Cassandra.java:964 org.apache.cassandra.thrift.Cassandra$Client.recv_batch_mutate
>                Cassandra.java:950 org.apache.cassandra.thrift.Cassandra$Client.batch_mutate
>
> Thrift client doesn't even display that column family when running describe_keyspace.
>
>
> I may be missing something, and I realize that CQL3 is way to, but i'm still oblivious of wether it's even possible to combine cql3 and thrift things.
>
> --
> alex p
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Inserting via thrift interface to column family created with Compound Key via cql3

Oleksandr Petrov
Yes, execute_cql3_query, exactly.


On Wed, Jan 30, 2013 at 4:37 PM, Michael Kjellman <[hidden email]> wrote:
Are you using execute_cql3_query() ?

On Jan 30, 2013, at 7:31 AM, "Oleksandr Petrov" <[hidden email]> wrote:

> Hi,
>
> I'm creating a table via cql3 query like:
>
> CREATE TABLE posts (
>   userid text,
>   blog_name text,
>   entry_title text,
>   posted_at text,
>   PRIMARY KEY (userid, blog_name)
> )
>
> After that i'm trying to insert into same column family via thrift interface, and i'm getting following exception: Not enough bytes to read value of component 0
>
>              Cassandra.java:20833 org.apache.cassandra.thrift.Cassandra$batch_mutate_result.read
>            TServiceClient.java:78 org.apache.thrift.TServiceClient.receiveBase
>                Cassandra.java:964 org.apache.cassandra.thrift.Cassandra$Client.recv_batch_mutate
>                Cassandra.java:950 org.apache.cassandra.thrift.Cassandra$Client.batch_mutate
>
> Thrift client doesn't even display that column family when running describe_keyspace.
>
>
> I may be missing something, and I realize that CQL3 is way to, but i'm still oblivious of wether it's even possible to combine cql3 and thrift things.
>
> --
> alex p



--
alex p
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Inserting via thrift interface to column family created with Compound Key via cql3

Michael Kjellman
Did you pack the composite correctly? This exception normally shows up when the composite bytes are malformed

On Jan 30, 2013, at 7:45 AM, "Oleksandr Petrov" <[hidden email]> wrote:

Yes, execute_cql3_query, exactly.


On Wed, Jan 30, 2013 at 4:37 PM, Michael Kjellman <[hidden email]> wrote:
Are you using execute_cql3_query() ?

On Jan 30, 2013, at 7:31 AM, "Oleksandr Petrov" <[hidden email]> wrote:

> Hi,
>
> I'm creating a table via cql3 query like:
>
> CREATE TABLE posts (
>   userid text,
>   blog_name text,
>   entry_title text,
>   posted_at text,
>   PRIMARY KEY (userid, blog_name)
> )
>
> After that i'm trying to insert into same column family via thrift interface, and i'm getting following exception: Not enough bytes to read value of component 0
>
>              Cassandra.java:20833 org.apache.cassandra.thrift.Cassandra$batch_mutate_result.read
>            TServiceClient.java:78 org.apache.thrift.TServiceClient.receiveBase
>                Cassandra.java:964 org.apache.cassandra.thrift.Cassandra$Client.recv_batch_mutate
>                Cassandra.java:950 org.apache.cassandra.thrift.Cassandra$Client.batch_mutate
>
> Thrift client doesn't even display that column family when running describe_keyspace.
>
>
> I may be missing something, and I realize that CQL3 is way to, but i'm still oblivious of wether it's even possible to combine cql3 and thrift things.
>
> --
> alex p



--
alex p
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Inserting via thrift interface to column family created with Compound Key via cql3

Michael Kjellman
From src/java/org/apache/cassandra/db/marshal/CompositeType.java
/*
 * The encoding of a CompositeType column name should be:
 *   <component><component><component> ...
 * where <component> is:
 *   <length of value><value><'end-of-component' byte>
 * where <length of value> is a 2 bytes unsigned short the and the
 * 'end-of-component' byte should always be 0 for actual column name.
 * However, it can set to 1 for query bounds. This allows to query for the
 * equivalent of 'give me the full super-column'. That is, if during a slice
 * query uses:
 *   start = <3><"foo".getBytes()><0>
 *   end   = <3><"foo".getBytes()><1>
 * then he will be sure to get *all* the columns whose first component is "foo".
 * If for a component, the 'end-of-component' is != 0, there should not be any
 * following component. The end-of-component can also be -1 to allow
 * non-inclusive query. For instance:
 *   start = <3><"foo".getBytes()><-1>
 * allows to query everything that is greater than <3><"foo".getBytes()>, but
 * not <3><"foo".getBytes()> itself.
 */

Or am I missing the fact that you are inserting with cql3 as well?

From: Michael Kjellman <[hidden email]>
Reply-To: "[hidden email]" <[hidden email]>
Date: Wednesday, January 30, 2013 8:03 AM
To: "[hidden email]" <[hidden email]>
Subject: Re: Inserting via thrift interface to column family created with Compound Key via cql3

Did you pack the composite correctly? This exception normally shows up when the composite bytes are malformed

On Jan 30, 2013, at 7:45 AM, "Oleksandr Petrov" <[hidden email]> wrote:

Yes, execute_cql3_query, exactly.


On Wed, Jan 30, 2013 at 4:37 PM, Michael Kjellman <[hidden email]> wrote:
Are you using execute_cql3_query() ?

On Jan 30, 2013, at 7:31 AM, "Oleksandr Petrov" <[hidden email]> wrote:

> Hi,
>
> I'm creating a table via cql3 query like:
>
> CREATE TABLE posts (
>   userid text,
>   blog_name text,
>   entry_title text,
>   posted_at text,
>   PRIMARY KEY (userid, blog_name)
> )
>
> After that i'm trying to insert into same column family via thrift interface, and i'm getting following exception: Not enough bytes to read value of component 0
>
>              Cassandra.java:20833 org.apache.cassandra.thrift.Cassandra$batch_mutate_result.read
>            TServiceClient.java:78 org.apache.thrift.TServiceClient.receiveBase
>                Cassandra.java:964 org.apache.cassandra.thrift.Cassandra$Client.recv_batch_mutate
>                Cassandra.java:950 org.apache.cassandra.thrift.Cassandra$Client.batch_mutate
>
> Thrift client doesn't even display that column family when running describe_keyspace.
>
>
> I may be missing something, and I realize that CQL3 is way to, but i'm still oblivious of wether it's even possible to combine cql3 and thrift things.
>
> --
> alex p



--
alex p
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Inserting via thrift interface to column family created with Compound Key via cql3

Oleksandr Petrov
BTW, thanks for chiming in!

No-no, I'm using Thrift client, not inserting via cql.
I'm serializing via CompositeType, actually. CompositeType.getInstance(UTF8Type, UTF8Type).decompose(["firstkeypart", "secondkeypart"]);

Hm... From what you say I understand that it's technically possible :/ 
So I must be wrong somewhere,

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Inserting via thrift interface to column family created with Compound Key via cql3

aaron morton
Whats the full error stack on the client ? 

Are you using a pre-build thrift client or you own ? If the later try using a pre built client first, like Hector or pycassa. If it works there look into how that code works and go from there. 

Cheers

-----------------
Aaron Morton
Freelance Cassandra Developer
New Zealand

@aaronmorton

On 31/01/2013, at 5:24 AM, Oleksandr Petrov <[hidden email]> wrote:

BTW, thanks for chiming in!

No-no, I'm using Thrift client, not inserting via cql.
I'm serializing via CompositeType, actually. CompositeType.getInstance(UTF8Type, UTF8Type).decompose(["firstkeypart", "secondkeypart"]);

Hm... From what you say I understand that it's technically possible :/ 
So I must be wrong somewhere,


Loading...