cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philippe Suray <philippe.su...@market-ip.com>
Subject date type and SimpleDateSerializer for Cassandra-2.2.0
Date Fri, 21 Aug 2015 11:57:01 GMT
Hello,

I have recently installed Datastax-Cassandra-2.2.0 on a Debian system.
I successfully started Cassandra.

In order to test it, I have written a small client in Java that use cassandra-driver-core-2.1.7.1.jar
from Datastax.
I also installed the DevCenter in order to create a keyspace and a table. Here is the generated
CQL

CREATE KEYSPACE IF NOT EXISTS test
WITH REPLICATION = {
       'class' : 'NetworkTopologyStrategy',
       'datacenter1' : 3
};
CREATE TABLE IF NOT EXISTS test.incoming_message (
       id uuid,
       device_id text,
       creation_date date,
       event_timestamp timestamp,
       raw_message text,
       PRIMARY KEY ((device_id, creation_date ), event_timestamp)
) WITH CLUSTERING ORDER BY (event_timestamp DESC);


Based on this http://cassandra.apache.org/doc/cql3/CQL-2.2.html#usingdates, I used 'date'
type to define a column 'creation_date' for 'incoming_message' table
I tried to insert data in the table with this code:
Insert insert = QueryBuilder.insertInto("incoming_message")
                        .value("id", UUIDs.random())
                        .value("device_id", celloMessage.getUnitID())
                        .value("creation_date", SimpleDateSerializer.timeInMillisToDay(DateTime.now(DateTimeZone.UTC).getMillis()))
                        .value("event_timestamp", DateTime.now(DateTimeZone.UTC).getMillis())
                        .value("raw_message", Hex.encodeHexString(celloMessage.getMessage()));

I use a helper class SimpleDateSerializer in order to format the date. This class can be found
in Cassandra-clientutil-2.2.0.jar
When I try to insert records, I have this stack:
Caused by: com.datastax.driver.core.exceptions.InvalidQueryException: Unable to make unsigned
int (for date) from: '-2147466980'
       at com.datastax.driver.core.Responses$Error.asException(Responses.java:102)
       at com.datastax.driver.core.DefaultResultSetFuture.onSet(DefaultResultSetFuture.java:118)
       at com.datastax.driver.core.RequestHandler.setFinalResult(RequestHandler.java:183)
       at com.datastax.driver.core.RequestHandler.access$2300(RequestHandler.java:45)
       at com.datastax.driver.core.RequestHandler$SpeculativeExecution.setFinalResult(RequestHandler.java:748)
       at com.datastax.driver.core.RequestHandler$SpeculativeExecution.onSet(RequestHandler.java:573)
       at com.datastax.driver.core.Connection$Dispatcher.channelRead0(Connection.java:991)
       at com.datastax.driver.core.Connection$Dispatcher.channelRead0(Connection.java:913)
       at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
       at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
       at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
       at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:254)
       at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
       at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
       at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
       at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
       at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
       at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:244)
       at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
       at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
       at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
       at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
       at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
       at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
       at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
       at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
       ... 2 more

What Am I doing wrong?

Thank you for your help.

Regards

Philippe SURAY

Mime
View raw message