You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Olivier Rosello <or...@corp.free.fr> on 2010/04/23 11:59:50 UTC
How to insert a row with a TimeUUIDType column in C++
Here is my test code :
ColumnPath new_col;
new_col.__isset.column = true; /* this is required! */
new_col.column_family.assign("Incoming");
new_col.column.assign("1968ec4a-2a73-11df-9aca-00012e27a270");
client.insert("MyKeyspace", "somekey", new_col, "Random Value", time(NULL), ONE);
I didn't found in the C++ Cassandra/Thrift API how to specify TimeUUID bytes (16) to the column name. The ColumnPath type get only a string field for the name "column".
With a String like this example shows, the TimeUUID is a 36 chars String and this code throws a Exception "UUIDs must be exactly 16 bytes".
I didn't found a function like "client.insert_timeuuid_column" which convert the column name to an uint8_t[16]... or anything else which could help me.
Cheers,
Olivier
--
Olivier
RE: How to insert a row with a TimeUUIDType column in C++
Posted by Mark Jones <MJ...@imagehawk.com>.
Turns out assign can be called with the length as well
So mod your code to be
new_col.column.assign((char *)uuid, 16);
and you are fixed.
-----Original Message-----
From: Mark Jones [mailto:MJones@imagehawk.com]
Sent: Friday, April 23, 2010 10:52 AM
To: user@cassandra.apache.org
Subject: RE: How to insert a row with a TimeUUIDType column in C++
std::string strUUID(uuid, 16) will do the right thing for you.
-----Original Message-----
From: Olivier Rosello [mailto:orosello@corp.free.fr]
Sent: Friday, April 23, 2010 9:59 AM
To: user@cassandra.apache.org
Subject: Re: How to insert a row with a TimeUUIDType column in C++
Le vendredi 23 avril 2010 à 08:30 -0500, Jonathan Ellis a écrit :
> want to look for a C++ library that deals
> with UUIDs. Cassandra or Thrift aren't
Tank you for the response.
That's not the problem for me.
The problem is that new_col.column type is string.
uint8_t uuid[17];
uuid_generate_time(uuid); // returns a 16 bytes uuid v1
uuid[16] = 0;
ColumnPath new_col;
new_col.__isset.column = true; /* this is required! */
new_col.column_family.assign("Incoming");
new_col.column.assign((char *)uuid);
client.insert("MyKeyspace", "somekey", new_col, "Random Value",
time(NULL), ONE);
This works, except that sometimes, there are \0 bytes in uuid, so to
column.assign get a string shorter than 16 bytes...
My question is : how could I attribute the 16 bytes of uuid to column
without using a string ? :)
Cheers,
Olivier
--
Olivier Rosello -+- Free Mobile -+-
orosello@corp.free.fr -+- 1231, avenue du mondial 98 - 34000 Montpellier
Tel : +33 4 34 67 89 08 -+-
RE: How to insert a row with a TimeUUIDType column in C++
Posted by Mark Jones <MJ...@imagehawk.com>.
std::string strUUID(uuid, 16) will do the right thing for you.
-----Original Message-----
From: Olivier Rosello [mailto:orosello@corp.free.fr]
Sent: Friday, April 23, 2010 9:59 AM
To: user@cassandra.apache.org
Subject: Re: How to insert a row with a TimeUUIDType column in C++
Le vendredi 23 avril 2010 à 08:30 -0500, Jonathan Ellis a écrit :
> want to look for a C++ library that deals
> with UUIDs. Cassandra or Thrift aren't
Tank you for the response.
That's not the problem for me.
The problem is that new_col.column type is string.
uint8_t uuid[17];
uuid_generate_time(uuid); // returns a 16 bytes uuid v1
uuid[16] = 0;
ColumnPath new_col;
new_col.__isset.column = true; /* this is required! */
new_col.column_family.assign("Incoming");
new_col.column.assign((char *)uuid);
client.insert("MyKeyspace", "somekey", new_col, "Random Value",
time(NULL), ONE);
This works, except that sometimes, there are \0 bytes in uuid, so to
column.assign get a string shorter than 16 bytes...
My question is : how could I attribute the 16 bytes of uuid to column
without using a string ? :)
Cheers,
Olivier
--
Olivier Rosello -+- Free Mobile -+-
orosello@corp.free.fr -+- 1231, avenue du mondial 98 - 34000 Montpellier
Tel : +33 4 34 67 89 08 -+-
Re: How to insert a row with a TimeUUIDType column in C++
Posted by Olivier Rosello <or...@corp.free.fr>.
Le vendredi 23 avril 2010 à 08:30 -0500, Jonathan Ellis a écrit :
> want to look for a C++ library that deals
> with UUIDs. Cassandra or Thrift aren't
Tank you for the response.
That's not the problem for me.
The problem is that new_col.column type is string.
uint8_t uuid[17];
uuid_generate_time(uuid); // returns a 16 bytes uuid v1
uuid[16] = 0;
ColumnPath new_col;
new_col.__isset.column = true; /* this is required! */
new_col.column_family.assign("Incoming");
new_col.column.assign((char *)uuid);
client.insert("MyKeyspace", "somekey", new_col, "Random Value",
time(NULL), ONE);
This works, except that sometimes, there are \0 bytes in uuid, so to
column.assign get a string shorter than 16 bytes...
My question is : how could I attribute the 16 bytes of uuid to column
without using a string ? :)
Cheers,
Olivier
--
Olivier Rosello -+- Free Mobile -+-
orosello@corp.free.fr -+- 1231, avenue du mondial 98 - 34000 Montpellier
Tel : +33 4 34 67 89 08 -+-
Re: How to insert a row with a TimeUUIDType column in C++
Posted by Jonathan Ellis <jb...@gmail.com>.
I would assume that you'd want to look for a C++ library that deals
with UUIDs. Cassandra or Thrift aren't in the business of doing that
conversion.
On Fri, Apr 23, 2010 at 4:59 AM, Olivier Rosello <or...@corp.free.fr> wrote:
> Here is my test code :
>
> ColumnPath new_col;
> new_col.__isset.column = true; /* this is required! */
> new_col.column_family.assign("Incoming");
> new_col.column.assign("1968ec4a-2a73-11df-9aca-00012e27a270");
> client.insert("MyKeyspace", "somekey", new_col, "Random Value", time(NULL), ONE);
>
> I didn't found in the C++ Cassandra/Thrift API how to specify TimeUUID bytes (16) to the column name. The ColumnPath type get only a string field for the name "column".
>
> With a String like this example shows, the TimeUUID is a 36 chars String and this code throws a Exception "UUIDs must be exactly 16 bytes".
>
> I didn't found a function like "client.insert_timeuuid_column" which convert the column name to an uint8_t[16]... or anything else which could help me.
>
> Cheers,
>
> Olivier
>
>
>
> --
> Olivier
>
>
>
Re: How to insert a row with a TimeUUIDType column in C++
Posted by Jonathan Ellis <jb...@gmail.com>.
http://php.net/manual/en/function.pack.php
2010/5/31 刘大伟 <li...@gmail.com>:
> How can I get 16 bytes timeUUID ?
>
>
> string(36) "4698cc00-6d2f-11df-8c7f-9f342400a648" TException: UUIDs must be
> exactly 16 bytes Error:
>
>
> On Fri, Apr 23, 2010 at 5:59 PM, Olivier Rosello <or...@corp.free.fr>
> wrote:
>>
>> Here is my test code :
>>
>> ColumnPath new_col;
>> new_col.__isset.column = true; /* this is required! */
>> new_col.column_family.assign("Incoming");
>> new_col.column.assign("1968ec4a-2a73-11df-9aca-00012e27a270");
>> client.insert("MyKeyspace", "somekey", new_col, "Random Value",
>> time(NULL), ONE);
>>
>> I didn't found in the C++ Cassandra/Thrift API how to specify TimeUUID
>> bytes (16) to the column name. The ColumnPath type get only a string field
>> for the name "column".
>>
>> With a String like this example shows, the TimeUUID is a 36 chars String
>> and this code throws a Exception "UUIDs must be exactly 16 bytes".
>>
>> I didn't found a function like "client.insert_timeuuid_column" which
>> convert the column name to an uint8_t[16]... or anything else which could
>> help me.
>>
>> Cheers,
>>
>> Olivier
>>
>>
>>
>> --
>> Olivier
>>
>>
>
>
>
> --
> 执著而努力着 david.liu
>
>
--
Jonathan Ellis
Project Chair, Apache Cassandra
co-founder of Riptano, the source for professional Cassandra support
http://riptano.com
Re: How to insert a row with a TimeUUIDType column in C++
Posted by 刘大伟 <li...@gmail.com>.
How can I get 16 bytes timeUUID ?
string(36) "4698cc00-6d2f-11df-8c7f-9f342400a648" TException: UUIDs must be
exactly 16 bytes Error:
On Fri, Apr 23, 2010 at 5:59 PM, Olivier Rosello <or...@corp.free.fr>wrote:
> Here is my test code :
>
> ColumnPath new_col;
> new_col.__isset.column = true; /* this is required! */
> new_col.column_family.assign("Incoming");
> new_col.column.assign("1968ec4a-2a73-11df-9aca-00012e27a270");
> client.insert("MyKeyspace", "somekey", new_col, "Random Value", time(NULL),
> ONE);
>
> I didn't found in the C++ Cassandra/Thrift API how to specify TimeUUID
> bytes (16) to the column name. The ColumnPath type get only a string field
> for the name "column".
>
> With a String like this example shows, the TimeUUID is a 36 chars String
> and this code throws a Exception "UUIDs must be exactly 16 bytes".
>
> I didn't found a function like "client.insert_timeuuid_column" which
> convert the column name to an uint8_t[16]... or anything else which could
> help me.
>
> Cheers,
>
> Olivier
>
>
>
> --
> Olivier
>
>
>
--
执著而努力着 david.liu