You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Jaydeep Chovatia <Ja...@openwave.com> on 2011/01/04 23:32:01 UTC

Cassandra LongType data insertion problem

Hi,

I have configured Cassandra Column Family (standard CF) of LongType. If I try to insert data (using batch_mutate) in this Column Family then it shows me following error: "A long is exactly 8 bytes". I have tried assigning column name of 8 bytes, 7 bytes, etc. but it shows same error.

Please find my sample program details:
Platform: Linux
Language: C++, Cassandra Thrift interface

        Column c1;
        c1.name = "12345678";
        c1.value = SString(len).AsPtr();
        c1.timestamp = curTime;
        columns.push_back(c1);

Any help on this would be appreciated.

Thank you,
Jaydeep

Re: Deletion via SliceRange

Posted by Jonathan Ellis <jb...@gmail.com>.
It's not on anyone's short list, that I know of.

https://issues.apache.org/jira/browse/CASSANDRA-494

On Tue, Jan 4, 2011 at 5:18 PM, mike dooley <do...@apple.com> wrote:
> any idea when Deletion via SliceRanges will be supported?
>
>     [java] Caused by: InvalidRequestException(why:Deletion does not yet support SliceRange predicates.)
>     [java]     at org.apache.cassandra.thrift.Cassandra$batch_mutate_result.read(Cassandra.java:16477)
>
> thanks,
> -mike



-- 
Jonathan Ellis
Project Chair, Apache Cassandra
co-founder of Riptano, the source for professional Cassandra support
http://riptano.com

Deletion via SliceRange

Posted by mike dooley <do...@apple.com>.
any idea when Deletion via SliceRanges will be supported?

     [java] Caused by: InvalidRequestException(why:Deletion does not yet support SliceRange predicates.)
     [java] 	at org.apache.cassandra.thrift.Cassandra$batch_mutate_result.read(Cassandra.java:16477)

thanks,
-mike

Re: Cassandra LongType data insertion problem

Posted by Tyler Hobbs <ty...@riptano.com>.
Oops, I made one typo there. It should be:

"my_long = my_long >> 8;"

That is, shift by a byte, not a bit.
- Tyler

On Tue, Jan 4, 2011 at 10:50 PM, Tyler Hobbs <ty...@riptano.com> wrote:

> Here's an example:
>
> int64_t my_long = 12345678;
> char chars[8];
> for(int i = 0; i < 8; ++i) {
> chars[i] = my_long & 0xff;
> my_long = my_long >> 1;
> }
>
> std::string str_long(chars, 8);
>
> Column c1;
> c1.name = str_long;
> // etc ...
>
> Basically, Thrift expects a string which is a big-endian binary
> representation of a long. When you create the std::string, you have to
> specify the length of the char[] so that it doesn't terminate the string on
> a 0x00 byte.
>
> The approach is similar for integers and UUIDs.
> - Tyler
>
>
> On Tue, Jan 4, 2011 at 4:32 PM, Jaydeep Chovatia <
> Jaydeep.Chovatia@openwave.com> wrote:
>
>>  Hi,
>>
>>
>>
>> I have configured Cassandra Column Family (standard CF) of LongType. If I
>> try to insert data (using batch_mutate) in this Column Family then it
>> shows me following error: “*A long is exactly 8 bytes”. *I have tried
>> assigning column name of 8 bytes, 7 bytes, etc. but it shows same error.
>>
>>
>>
>> Please find my sample program details:
>>
>> *Platform*: Linux
>>
>> *Language*: C++, Cassandra Thrift interface
>>
>>
>>
>>         Column c1;
>>
>>         c1.name = "12345678";
>>
>>         c1.value = SString(len).AsPtr();
>>
>>         c1.timestamp = curTime;
>>
>>         columns.push_back(c1);
>>
>>
>>
>> Any help on this would be appreciated.
>>
>>
>>
>> Thank you,
>>
>> Jaydeep
>>
>
>

Re: Cassandra LongType data insertion problem

Posted by Tyler Hobbs <ty...@riptano.com>.
Here's an example:

int64_t my_long = 12345678;
char chars[8];
for(int i = 0; i < 8; ++i) {
chars[i] = my_long & 0xff;
my_long = my_long >> 1;
}

std::string str_long(chars, 8);

Column c1;
c1.name = str_long;
// etc ...

Basically, Thrift expects a string which is a big-endian binary
representation of a long. When you create the std::string, you have to
specify the length of the char[] so that it doesn't terminate the string on
a 0x00 byte.

The approach is similar for integers and UUIDs.
- Tyler

On Tue, Jan 4, 2011 at 4:32 PM, Jaydeep Chovatia <
Jaydeep.Chovatia@openwave.com> wrote:

>  Hi,
>
>
>
> I have configured Cassandra Column Family (standard CF) of LongType. If I
> try to insert data (using batch_mutate) in this Column Family then it
> shows me following error: “*A long is exactly 8 bytes”. *I have tried
> assigning column name of 8 bytes, 7 bytes, etc. but it shows same error.
>
>
>
> Please find my sample program details:
>
> *Platform*: Linux
>
> *Language*: C++, Cassandra Thrift interface
>
>
>
>         Column c1;
>
>         c1.name = "12345678";
>
>         c1.value = SString(len).AsPtr();
>
>         c1.timestamp = curTime;
>
>         columns.push_back(c1);
>
>
>
> Any help on this would be appreciated.
>
>
>
> Thank you,
>
> Jaydeep
>