I don't know Hector very much really, but I highly suspect that
"ts.toString()" is wrong, since composite column names are not strings. So
again, not a Hector expert, but I can't really see how converting the
composite into string could work.

--
Sylvain


On Wed, Jul 17, 2013 at 11:14 PM, Rahul Gupta <rgu...@dekaresearch.com>wrote:

>  Getting error while trying to persist data in a Column Family having a
> CompositeType comparator****
>
> ** **
>
> *Using Cassandra ver 1.1.9.7*
>
> *Hector Core ver 1.1.5 API ( which uses Thrift 1.1.10)*
>
> ** **
>
> *Created Column Family using cassandra-cli:*
>
> ** **
>
> create column family event_counts****
>
> with comparator = 'CompositeType(DateType,UTF8Type)'****
>
> and key_validation_class = 'UUIDType'****
>
> and default_validation_class = 'CounterColumnType';****
>
> ** **
>
> *Persistence Code(*sumLoad.java):****
>
> ** **
>
> *import* me.prettyprint.cassandra.serializers.StringSerializer;****
>
> *import* me.prettyprint.cassandra.serializers.DateSerializer;****
>
> *import* me.prettyprint.cassandra.service.CassandraHostConfigurator;****
>
> *import* me.prettyprint.hector.api.Cluster;****
>
> *import* me.prettyprint.hector.api.Keyspace;****
>
> *import* me.prettyprint.hector.api.beans.Composite;****
>
> *import* me.prettyprint.hector.api.beans.HCounterColumn;****
>
> *import* me.prettyprint.hector.api.factory.HFactory;****
>
> *import* me.prettyprint.hector.api.mutation.Mutator;****
>
> *import* java.sql.Date;****
>
> *import* java.util.logging.Level;****
>
> ** **
>
>             *public* *class* sumLoad { ****
>
>             ****
>
>                 *final* *static* Cluster *cluster* = HFactory.*
> getOrCreateCluster*("Dev", *new* CassandraHostConfigurator("
> 100.10.0.6:9160"));****
>
>                 *final* *static* Keyspace *keyspace* = HFactory.*
> createKeyspace*("Events", *cluster*);****
>
>                 *final* *static* StringSerializer *ss* = StringSerializer.
> *get*();****
>
> ** **
>
>                 *private* *boolean* storeCounts(String vKey, String
> counterCF, Date dateStr, String vStr, *long* value)****
>
>                 {****
>
>                             *try*****
>
>                             {****
>
>                        Mutator<String> m1 = HFactory.*createMutator*(*
> keyspace*, StringSerializer.*get*());****
>
>                        ****
>
>                        Composite ts = *new* Composite();****
>
>                        ts.addComponent(dateStr, DateSerializer.*get*());**
> **
>
>                        ts.addComponent(vStr, StringSerializer.*get*());***
> *
>
>                        HCounterColumn<String> hColumn_ts = HFactory.*
> createCounterColumn*(ts.toString(), value, StringSerializer.*get*());****
>
>                         ****
>
>                        m1.insertCounter(vKey, counterCF, hColumn_ts);****
>
>                        m1.execute();         ****
>
>                        *return* *true*;****
>
>                             }****
>
>                             *catch*(Exception ex)****
>
>                             {****
>
>                                         LOGGER.*log*(Level.*WARNING*, "Unable
> to store record", ex);                  ****
>
>                             }****
>
>                             *return* *false*;****
>
>                 }           ****
>
> ** **
>
>                 *public* *static* *void* main(String[] args) {****
>
> ** **
>
>                         Date vDate = *new* Date(0);****
>
>                         sumLoad SumLoad = *new* sumLoad();****
>
> SumLoad.storeCounts("b9874e3e-4a0e-4e60-ae23-c3f1e575af93", "event_counts",
> vDate, "StoreThisString", 673);****
>
>                 }****
>
> ** **
>
>             }****
>
> ** **
>
> *Error:*
>
> ** **
>
> [main] INFO me.prettyprint.cassandra.service.JmxMonitor - Registering JMX
> me.prettyprint.cassandra.service_Dev:ServiceType=hector,MonitorType=hector
> ****
>
> Unable to store record****
>
> *me.prettyprint.hector.api.exceptions.HInvalidRequestException*:
> InvalidRequestException(why:Not enough bytes to read value of component 0)
> ****
>
> ** **
>
> ** **
>
> *Rahul Gupta*
> This e-mail and the information, including any attachments, it contains
> are intended to be a confidential communication only to the person or
> entity to whom it is addressed and may contain information that is
> privileged. If the reader of this message is not the intended recipient,
> you are hereby notified that any dissemination, distribution or copying of
> this communication is strictly prohibited. If you have received this
> communication in error, please immediately notify the sender and destroy
> the original message.****
>
> ** **
>
> ------------------------------
> This e-mail and the information, including any attachments, it contains
> are intended to be a confidential communication only to the person or
> entity to whom it is addressed and may contain information that is
> privileged. If the reader of this message is not the intended recipient,
> you are hereby notified that any dissemination, distribution or copying of
> this communication is strictly prohibited. If you have received this
> communication in error, please immediately notify the sender and destroy
> the original message.
>
> Thank you.
>
> Please consider the environment before printing this email.
>

Reply via email to