Cassandra-批次过大 [英] Cassandra - Batch too large

查看:158
本文介绍了Cassandra-批次过大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个必须添加到采购订单中的产品列表。采购订单具有序列号,添加产品后,其状态应更改为表明这些产品已可供购买。

I have a list of Products which have to be added to a Purchase Order. The Purchase order has a sequence number and once the Products are added, their status should be changed to indicate that these are out for purchase.

正在处理的典型产品数在1个采购订单中将是500。

The typical number of Products being processed in 1 Purchase Order would be 500.

在数据库上-我有2个表-> 1个用于产品,另一个用于采购订单。这意味着我需要进行500次更新和1次插入。
当我尝试在BatchStatement中执行此操作时,出现错误-批处理太大。

On the DB - I have 2 tables -> 1 for Products and another for Purchase Orders. Which means I need 500 updates and 1 insert to be done. When I try to do this in a BatchStatement I get the error - Batch too large.

来自各个方面的建议告诉我,我应该使用多个异步查询。但是,我担心的是整个操作的原子性。
请根据我的要求提出最佳的前进方式。

Suggestions from various quarters tell me that I should use multiple async queries. My concern however is atomicity of the entire operation. Please suggest what would be the best way forward given my requirement.

预先感谢。

推荐答案

这很有趣。在批处理中插入大量插入(> 10)(以实现原子性)确实会带来不好的效果,因此提高批处理限制并不是一种选择。

This is interesting. Inserting a lot of inserts (> 10) into a batch (to achieve atomicity) is really going to be a bad performancer, so raising the batch limit is not really an option.

由于Cassandra还在单行级别管理原子性,因此您可以通过添加表以标记采购订单的方式来更改模型,从而利用这一优势,在该行中,仅将采购订单ID和物料都存储在一行中地图,因此您的查询具有幂等性。然后,您可以根据需要扩展或后期处理该表以继续工作。

Since Cassandra manages atomicity at single row level also, you could exploit that by changing your model by adding a table to "bookmark" your purchase orders, where you store there in one row only both the purchase order id and the items into a map, so you have idempotency in your queries. You can then expand or post process this table to continue your workflow as needed.

这篇关于Cassandra-批次过大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆