gopher_rocks
gopher_rocks

Reputation: 133

Problem when using Hector0.8.0 do addCounter

I'm using hector-core 0.8.0-1 and Cassandra 0.8.0 to test a addCounter operation, but I found my code cannot insert any data into the CF, can anyone tell me the reason?

StringSerializer ser = StringSerializer.get();
Mutator<String> mutator = HFactory.createMutator(keyspace, ser);

List<HCounterColumn<String>> counterColumns = Arrays.asList(
        HFactory.createCounterColumn("1", 30L, ser),
        HFactory.createCounterColumn("2", 20L, ser)
        );  

for (HCounterColumn c : counterColumns)
{   
    mutator.addCounter("testKey1", "CounterColumn", c); 
    mutator.addCounter("testKey2", "CounterColumn", c); 
}   

mutator.execute();

and I found the following info in my log:

> 2011-06-21 17:17:00,025 [Thread-3]
> INFO me.prettyprint.cassandra.hector.TimingLogger
> - Tag                                       Avg(ms) 
>      Min      Max  Std Dev     95th   Count 2011-06-21 17:17:00,030
> [Thread-3] INFO me.prettyprint.cassandra.hector.TimingLogger
> - WRITE.fail_                                  4.84 
>     4.84     4.84     0.00     4.84       1 2011-06-21 17:17:00,031 [Thread-3]
> INFO me.prettyprint.cassandra.hector.TimingLogger
> - META_WRITE.fail_                            17.20 
>    11.31    23.09     5.89    23.09       2 2011-06-21 17:17:00,031 [Thread-3]
> INFO me.prettyprint.cassandra.hector.TimingLogger
> -

seems something wrong while doing mutator.execute();

Thanks in advance!

Upvotes: 1

Views: 630

Answers (2)

Patricio
Patricio

Reputation: 969

This way:

cfDef.setDefaultValidationClass(...)

This is available in the latest version of trunk, 0.7.0 and 0.8.0 branch.

So you need to pull from sources.

or, if you want to do that, and assoming you are using the latest hector available at maven central, you can do this

ThriftCfDef cfDef = new ThriftCfDef(String keyspace, String   columnFamilyName, ComparatorType comparatorType)

cf.setDefaultValidationClass(ComparatorType.COUNTERTYPE.getClassName());

cluster.addColumnFamiily(cfDef);

Upvotes: 2

sdolgy
sdolgy

Reputation: 7001

Currently, in Cassandra 0.8.0, you cannot create counter columns in a Column Family that is not specifically created to handle counters:

create column family Counter1 with default_validation_class = CounterColumnType;

Here is the JIRA reference: https://issues.apache.org/jira/browse/CASSANDRA-2614

Upvotes: 5

Related Questions