如何使用Cassandra Trigger(已编辑)从复合键columnFamily中删除

时间:2015-10-25 08:44:13

标签: java triggers cassandra cassandra-2.0 nosql

我正在尝试使用cassandra触发器扩充方法中的复合主键删除一行columnFamily。

这是我的columnFamily架构

CREATE TABLE cart (
 product_id int,
 user_id int,
 quantity int,
 PRIMARY KEY (product_id, user_id)
);  

这是我试过的

CFMetaData cfMetaData = Schema.instance.getCFMetaData(keySpace, columnFamily);

for (ColumnDefinition columnDefinition : cfMetaData.allColumns()) {
    Mutation mutation = new Mutation(keySpace, key);
    mutation.delete(columnFamily, CellNames.simpleDense(columnDefinition.name.bytes), System.currentTimeMillis());
    mutations.add(mutation);
}

但它给了我这个错误

org.apache.cassandra.serializers.MarshalException: Expected 4 or 0 byte int (8)
at org.apache.cassandra.serializers.Int32Serializer.validate(Int32Serializer.java:42) ~[apache-cassandra-2.2.2.jar:2.2.2]
at org.apache.cassandra.db.marshal.AbstractType.validate(AbstractType.java:113) ~[apache-cassandra-2.2.2.jar:2.2.2]
at org.apache.cassandra.db.marshal.AbstractType.validateCollectionMember(AbstractType.java:246) ~[apache-cassandra-2.2.2.jar:2.2.2]
at org.apache.cassandra.db.composites.AbstractCType.validate(AbstractCType.java:210) ~[apache-cassandra-2.2.2.jar:2.2.2]
at org.apache.cassandra.db.AbstractCell.validateName(AbstractCell.java:159) ~[apache-cassandra-2.2.2.jar:2.2.2]
at org.apache.cassandra.db.BufferDeletedCell.validateFields(BufferDeletedCell.java:103) ~[apache-cassandra-2.2.2.jar:2.2.2]
at org.apache.cassandra.triggers.TriggerExecutor.validate(TriggerExecutor.java:198) ~[apache-cassandra-2.2.2.jar:2.2.2]
at org.apache.cassandra.triggers.TriggerExecutor.execute(TriggerExecutor.java:129) ~[apache-cassandra-2.2.2.jar:2.2.2]
at org.apache.cassandra.service.StorageProxy.mutateWithTriggers(StorageProxy.java:632) ~[apache-cassandra-2.2.2.jar:2.2.2]
at org.apache.cassandra.cql3.statements.ModificationStatement.executeWithoutCondition(ModificationStatement.java:488) ~[apache-cassandra-2.2.2.jar:2.2.2]
at org.apache.cassandra.cql3.statements.ModificationStatement.execute(ModificationStatement.java:474) ~[apache-cassandra-2.2.2.jar:2.2.2]
at org.apache.cassandra.cql3.QueryProcessor.processStatement(QueryProcessor.java:225) ~[apache-cassandra-2.2.2.jar:2.2.2]
at org.apache.cassandra.cql3.QueryProcessor.process(QueryProcessor.java:256) ~[apache-cassandra-2.2.2.jar:2.2.2]
at org.apache.cassandra.cql3.QueryProcessor.process(QueryProcessor.java:241) ~[apache-cassandra-2.2.2.jar:2.2.2]
at org.apache.cassandra.transport.messages.QueryMessage.execute(QueryMessage.java:123) ~[apache-cassandra-2.2.2.jar:2.2.2]
at org.apache.cassandra.transport.Message$Dispatcher.channelRead0(Message.java:507) [apache-cassandra-2.2.2.jar:2.2.2]
at org.apache.cassandra.transport.Message$Dispatcher.channelRead0(Message.java:401) [apache-cassandra-2.2.2.jar:2.2.2]
at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [netty-all-4.0.23.Final.jar:4.0.23.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333) [netty-all-4.0.23.Final.jar:4.0.23.Final]
at io.netty.channel.AbstractChannelHandlerContext.access$700(AbstractChannelHandlerContext.java:32) [netty-all-4.0.23.Final.jar:4.0.23.Final]
at io.netty.channel.AbstractChannelHandlerContext$8.run(AbstractChannelHandlerContext.java:324) [netty-all-4.0.23.Final.jar:4.0.23.Final]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [na:1.7.0_79]
at org.apache.cassandra.concurrent.AbstractTracingAwareExecutorService$FutureTask.run(AbstractTracingAwareExecutorService.java:164) [apache-cassandra-2.2.2.jar:2.2.2]
at org.apache.cassandra.concurrent.SEPWorker.run(SEPWorker.java:105) [apache-cassandra-2.2.2.jar:2.2.2]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_79]

0 个答案:

没有答案