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.chova...@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
>

Reply via email to