UUIDs must be exactly 16 bytes

1,638 views
Skip to first unread message

Geeeeeek

unread,
Jan 24, 2012, 10:44:11 AM1/24/12
to hector-users
Hi..
I have created a columnfamily through CQL:

CREATE COLUMNFAMILY site_pages (
page_id uuid PRIMARY KEY,
site_url text,
page_url text,
html text
);

In the hector template code, I have the below to insert the data:

ColumnFamilyTemplate<String, String> templateSitePages = new
ThriftColumnFamilyTemplate<String, String>(ksp, "site_pages",
StringSerializer.get(), StringSerializer.get());

ColumnFamilyUpdater<String, String> updater =
templateSitePages.createUpdater();
updater.addKey("page_id");
updater.setUUID("page_id", page_id);
updater.setString("site_url", siteURL);
updater.setString("page_url", pageURL);
updater.setString("html", pageHtml);

On execution, I get the below Stack trace:


me.prettyprint.hector.api.exceptions.HInvalidRequestException:
InvalidRequestException(why:UUIDs must be exactly 16 bytes)
at
me.prettyprint.cassandra.service.ExceptionsTranslatorImpl.translate(ExceptionsTranslatorImpl.java:
52)
at
me.prettyprint.cassandra.connection.HConnectionManager.operateWithFailover(HConnectionManager.java:
247)
at
me.prettyprint.cassandra.model.ExecutingKeyspace.doExecuteOperation(ExecutingKeyspace.java:
97)
at
me.prettyprint.cassandra.model.MutatorImpl.execute(MutatorImpl.java:
243)
at
me.prettyprint.cassandra.service.template.AbstractColumnFamilyTemplate.executeBatch(AbstractColumnFamilyTemplate.java:
115)
at
me.prettyprint.cassandra.service.template.AbstractColumnFamilyTemplate.executeIfNotBatched(AbstractColumnFamilyTemplate.java:
149)
at
me.prettyprint.cassandra.service.template.ColumnFamilyTemplate.update(ColumnFamilyTemplate.java:
69)
at com.my.db.HectorDB.insertSitePages(HectorDB.java:74)
at com.my.db.DBMethods.insertSitePages(DBMethods.java:12)
at com.my.Test.main(Test.java:21)
Caused by: InvalidRequestException(why:UUIDs must be exactly 16 bytes)
at org.apache.cassandra.thrift.Cassandra
$batch_mutate_result.read(Cassandra.java:19479)
at org.apache.cassandra.thrift.Cassandra
$Client.recv_batch_mutate(Cassandra.java:1035)
at org.apache.cassandra.thrift.Cassandra
$Client.batch_mutate(Cassandra.java:1009)
at me.prettyprint.cassandra.model.MutatorImpl
$3.execute(MutatorImpl.java:246)
at me.prettyprint.cassandra.model.MutatorImpl
$3.execute(MutatorImpl.java:243)
at
me.prettyprint.cassandra.service.Operation.executeAndSetResult(Operation.java:
99)
at
me.prettyprint.cassandra.connection.HConnectionManager.operateWithFailover(HConnectionManager.java:
241)
... 8 more


Any suggestions?

Patricio Echagüe

unread,
Jan 26, 2012, 1:35:54 AM1/26/12
to hector...@googlegroups.com

How do you create pade_Id ?

Sent from my Android

Geeeeeek

unread,
Jan 26, 2012, 2:34:12 AM1/26/12
to hector-users
Hi..

I have moved from CQL to Hector method of creating CF.
I am creating the CF like this:

ColumnFamilyDefinition cfDef =
HFactory.createColumnFamilyDefinition(keyspaceName, "cfname",
ComparatorType.UUIDTYPE, columnList);

ColumnFamilyTemplate<UUID, String> template =
new ThriftColumnFamilyTemplate<UUID, String>(
ksp, "cfname", UUIDSerializer.get(),
StringSerializer.get());

ColumnFamilyUpdater<UUID, String> updater =
template.createUpdater(UUIDKeyHere); // UUIDKeyHere is a UUID Format
updater.setString("site_url", siteURL);

template.update(updater);


I get the below Trace now:


me.prettyprint.hector.api.exceptions.HInvalidRequestException:
InvalidRequestException(why:Column name 736974655f75726c is not valid
for comparator org.apache.cassandra.db.marshal.UUIDType)
Connect to the existing group...
at
me.prettyprint.cassandra.service.ExceptionsTranslatorImpl.translate(ExceptionsTranslatorImpl.java:
52)
at me.prettyprint.cassandra.service.ThriftCluster
$6.execute(ThriftCluster.java:152)
at me.prettyprint.cassandra.service.ThriftCluster
$6.execute(ThriftCluster.java:142)
at
me.prettyprint.cassandra.service.Operation.executeAndSetResult(Operation.java:
99)
at
me.prettyprint.cassandra.connection.HConnectionManager.operateWithFailover(HConnectionManager.java:
241)
at
me.prettyprint.cassandra.service.ThriftCluster.addKeyspace(ThriftCluster.java:
156)
at com.cinteron.db.HectorDB.createSchema(HectorDB.java:58)
at com.cinteron.db.HectorDB.<init>(HectorDB.java:40)
at com.cinteron.db.DBMethods.<init>(DBMethods.java:9)
at com.cinteron.seo.Test.main(Test.java:20)

-geeek

Patricio Echagüe

unread,
Jan 26, 2012, 10:43:28 AM1/26/12
to hector...@googlegroups.com

Looks like you are not generating the uuid in the right way. Can you show us how you create the uuid value?

Sent from my Android

Geeeeeek

unread,
Jan 26, 2012, 11:14:15 AM1/26/12
to hector-users
Like this:
http://wiki.apache.org/cassandra/FAQ#working_with_timeuuid_in_java





On Jan 26, 8:43 pm, Patricio Echagüe <patric...@gmail.com> wrote:
> Looks like you are not generating the uuid in the right way. Can you show
> us how you create the uuid value?
>
> Sent from my Android

Patricio Echagüe

unread,
Jan 26, 2012, 11:29:08 AM1/26/12
to hector...@googlegroups.com

Mind printing the value you are inserting?

Sent from my Android

Geeeeeek

unread,
Jan 26, 2012, 12:06:21 PM1/26/12
to hector-users
79634aa0-481c-11e1-90b7-0221e998cc56

:)

Regs.


On Jan 26, 9:29 pm, Patricio Echagüe <patric...@gmail.com> wrote:
> Mind printing the value you are inserting?
>
> Sent from my Android

Nate McCall

unread,
Jan 26, 2012, 12:30:47 PM1/26/12
to hector...@googlegroups.com
What library did you use to produce this UUID?

Nate McCall

unread,
Jan 26, 2012, 12:31:54 PM1/26/12
to hector...@googlegroups.com
Ok, just saw the wiki reference page - can you try creating a UUID
with our TimeUUIDUtils so we can rule out UUID construction?

Patricio Echagüe

unread,
Jan 26, 2012, 12:32:13 PM1/26/12
to hector...@googlegroups.com
Also, can you try creating the UUID like UUID.fromString("foo") and see what happens ?

Geeeeeek

unread,
Jan 26, 2012, 12:49:22 PM1/26/12
to hector-users
Hi..

I tried :

ColumnFamilyUpdater<UUID, String> updater =
template.createUpdater(TimeUUIDUtils.getUniqueTimeUUIDinMillis());

I get the below trace:

me.prettyprint.hector.api.exceptions.HInvalidRequestException:
InvalidRequestException(why:Column name 736974655f75726c is not valid
for comparator org.apache.cassandra.db.marshal.UUIDType)
at
me.prettyprint.cassandra.service.ExceptionsTranslatorImpl.translate(ExceptionsTranslatorImpl.java:
52)
at me.prettyprint.cassandra.service.ThriftCluster
$6.execute(ThriftCluster.java:152)
at me.prettyprint.cassandra.service.ThriftCluster
$6.execute(ThriftCluster.java:142)
at
me.prettyprint.cassandra.service.Operation.executeAndSetResult(Operation.java:
99)
at
me.prettyprint.cassandra.connection.HConnectionManager.operateWithFailover(HConnectionManager.java:
241)
at
me.prettyprint.cassandra.service.ThriftCluster.addKeyspace(ThriftCluster.java:
156)
at com.cinteron.db.HectorDB.createSchema(HectorDB.java:62)
at com.cinteron.db.HectorDB.<init>(HectorDB.java:45)
at com.cinteron.db.DBMethods.<init>(DBMethods.java:9)
at com.cinteron.seo.Test.main(Test.java:20)
Caused by: InvalidRequestException(why:Column name 736974655f75726c is
not valid for comparator org.apache.cassandra.db.marshal.UUIDType)
at org.apache.cassandra.thrift.Cassandra
$system_add_keyspace_result.read(Cassandra.java:28494)
at org.apache.cassandra.thrift.Cassandra
$Client.recv_system_add_keyspace(Cassandra.java:1539)
at org.apache.cassandra.thrift.Cassandra
$Client.system_add_keyspace(Cassandra.java:1514)
at me.prettyprint.cassandra.service.ThriftCluster
$6.execute(ThriftCluster.java:146)
... 8 more





On Jan 26, 10:31 pm, Nate McCall <n...@datastax.com> wrote:
> Ok, just saw the wiki reference page - can you try creating a UUID
> with our TimeUUIDUtils so we can rule out UUID construction?
>
>
>
>
>
>
>
> On Thu, Jan 26, 2012 at 5:30 PM, Nate McCall <n...@datastax.com> wrote:
> > What library did you use to produce this UUID?
>

Geeeeeek

unread,
Jan 26, 2012, 12:50:53 PM1/26/12
to hector-users
Hi..
I tried:

UUID.fromString("79634aa0-481c-11e1-90b7-0221e998cc56")

I get:

me.prettyprint.hector.api.exceptions.HInvalidRequestException:
InvalidRequestException(why:Column name 736974655f75726c is not valid
for comparator org.apache.cassandra.db.marshal.UUIDType)
at
me.prettyprint.cassandra.service.ExceptionsTranslatorImpl.translate(ExceptionsTranslatorImpl.java:
52)
at me.prettyprint.cassandra.service.ThriftCluster
$6.execute(ThriftCluster.java:152)
at me.prettyprint.cassandra.service.ThriftCluster
$6.execute(ThriftCluster.java:142)
at
me.prettyprint.cassandra.service.Operation.executeAndSetResult(Operation.java:
99)
at
me.prettyprint.cassandra.connection.HConnectionManager.operateWithFailover(HConnectionManager.java:
241)
at
me.prettyprint.cassandra.service.ThriftCluster.addKeyspace(ThriftCluster.java:
156)
at com.cinteron.db.HectorDB.createSchema(HectorDB.java:62)
at com.cinteron.db.HectorDB.<init>(HectorDB.java:45)
at com.cinteron.db.DBMethods.<init>(DBMethods.java:9)
at com.cinteron.seo.Test.main(Test.java:20)



On Jan 26, 10:32 pm, Patricio Echagüe <patric...@gmail.com> wrote:
> Also, can you try creating the UUID like UUID.fromString("foo") and see
> what happens ?
>
>
>
>
>
>
>
> On Thu, Jan 26, 2012 at 9:30 AM, Nate McCall <n...@datastax.com> wrote:
> > What library did you use to produce this UUID?
>

Nate McCall

unread,
Jan 26, 2012, 12:51:32 PM1/26/12
to hector...@googlegroups.com
Oh. This is on the keyspace/column family definition. Can you show me
the contents of "columnLIst" from the following invocation:

ColumnFamilyDefinition cfDef =
HFactory.createColumnFamilyDefinition(keyspaceName, "cfname",
ComparatorType.UUIDTYPE, columnList);

Geeeeeek

unread,
Jan 26, 2012, 12:56:17 PM1/26/12
to hector-users
Hi..

List<ColumnDefinition> columnList = new
ArrayList<ColumnDefinition>();columnList.add(createColumn("site_url",
ComparatorType.UTF8TYPE, "pil_site_url_index", ColumnIndexType.KEYS));
columnList.add(createColumn("page_url", ComparatorType.UTF8TYPE,
"pil_page_url_index", ColumnIndexType.KEYS));
columnList.add(createColumn("parent_url", ComparatorType.UTF8TYPE,
"pil_parent_url_index", ColumnIndexType.KEYS));
columnList.add(createColumn("nofollow",
ComparatorType.UTF8TYPE,null,null));
columnList.add(createColumn("anchor_text",
ComparatorType.UTF8TYPE,null,null));



private BasicColumnDefinition createColumn(String columnName,
ComparatorType comparatorType, String indexName, ColumnIndexType
columnIndexType){
BasicColumnDefinition columnDefinition = new
BasicColumnDefinition();

columnDefinition.setName(StringSerializer.get().toByteBuffer(columnName));
if(columnIndexType!=null){
columnDefinition.setIndexType(columnIndexType);
}
if(indexName!=null && indexName!=""){
columnDefinition.setIndexName(indexName);
}
columnDefinition.setValidationClass(comparatorType.getClassName());
return columnDefinition;
}

Regs.

Nate McCall

unread,
Jan 26, 2012, 1:24:57 PM1/26/12
to hector...@googlegroups.com
Ok, I see - you cant define the comparator in the column family to be
UUIDType and then create column meta data of UTF8Type. You have to
pick one or the other. Or use composites to prefix your column names
with UUIDs.

Geeeeeek

unread,
Jan 26, 2012, 9:29:31 PM1/26/12
to hector-users

1. My understanding based on online reference was: Comparators are
only for Row Keys, and here the row key is the UUID.
2. So, Then if I define the CF comparator as UTFType, One of the
columns in the metadata cannot have LongType ?
3. Right now, I have converted the comparator as UTFType and inserting
the key as uuid.toString. Is this right?
4. Composites to prefix? You mean like this?:
uuid1 (RowKey)
- uuid1:site_url -> 'http://somedomain.com/'
- uuid1:parent_url -> 'http://somedomain.com/def.html'
- uuid1:page_url -> 'http://somedomain.com/abc.html'
- uuid1:nofollow -> 'false'
- uuid1:anchor_text -> 'some text'
uuid2 (RowKey)
- uuid2:parent_url -> 'http://somedomain.com/def.html'
- uuid2:page_url -> 'http://somedomain.com/abc2.html'
- uuid2:nofollow -> 'false'
- uuid2:anchor_text -> 'some text 2'

But, i dont see any benefit with the above structure. Thought of
making the pageURL as Row Key but dont want to make it complex.. Lot
of options ;-)

Hontvári József Levente

unread,
Jan 26, 2012, 9:55:32 PM1/26/12
to hector...@googlegroups.com
Maybe it is just a terminology problem, but AFAIK comparators are for
column names. Keys has validators.

>>> if(indexName!=null&& indexName!=""){

>>>>>>>> On Jan 26, 9:29 pm, Patricio Echag�e<patric...@gmail.com> wrote:
>>>>>>>>> Mind printing the value you are inserting?
>>>>>>>>> Sent from my Android
>>>>>>>>> On Jan 26, 2012 8:14 AM, "Geeeeeek"<w3engine...@gmail.com> wrote:
>>>>>>>>>> Like this:
>>>>>>>>>> http://wiki.apache.org/cassandra/FAQ#working_with_timeuuid_in_java

Geeeeeek

unread,
Jan 29, 2012, 11:35:46 AM1/29/12
to hector-users
Hi..
Can someone help?


2. So, Then if I define the CF comparator as UTFType, One of the
columns in the metadata cannot have IntegerType ? If no, how do i
insert integer ?
3. Right now, I have converted the comparator as UTFType and inserting
the key as uuid.toString. Is this right?


Regs

B. Todd Burruss

unread,
Jan 29, 2012, 4:16:02 PM1/29/12
to hector...@googlegroups.com
you are correct. the comparator declared in the ColumnFamily is for
all columns. if you have different column name types, then you must
use BytesType as the comparator - which is probably ok for your use
case since the comparator is for sorting purposes only
Reply all
Reply to author
Forward
0 new messages