【发布时间】:2017-09-16 02:26:15
【问题描述】:
document 列出了 Cassandra 2.2 的许多 CQL 限制。我对Set 和List 的收集限制特别感兴趣。如果我的解释正确,文档说明 Sets 中的值限制为 65535 字节。
据我所知,这个限制是存在的,因为集合标识是使用存储引擎单元的列名中的复合值实现的(类似于集群列值限制),CQL 将其限制为那么多字节。
考虑一个带有Set 赞的表格
CREATE TABLE test.bounds (
someid text,
someorder text,
words set<text>,
PRIMARY KEY (someid, someorder)
)
与
PreparedStatement ps = session.prepare("INSERT INTO test.bounds (someid, someorder, words) VALUES (?, ?, ?)");
BoundStatement bs = ps.bind("id", "order", ImmutableSet.of(StringUtils.repeat('a', 66000)));
session.execute(bs);
这将引发预期的异常
Caused by: com.datastax.driver.core.exceptions.InvalidQueryException: The sum of all clustering columns is too long (66024 > 65535)
现在,如果我将表格更改为使用 List 而不是 Set
CREATE TABLE test.bounds (
someid text,
someorder text,
words list<text>,
PRIMARY KEY (someid, someorder)
)
并使用
BoundStatement bs = ps.bind("id", "order", ImmutableList.of(StringUtils.repeat('a', 66000)));
我没有收到异常。 但是,文档指出 List 的值大小也限制为 65535 字节。文档不正确还是我误解了?
我假设List 值在底层存储中实现为简单的列值,并且通过它们的时间戳来维护顺序。
【问题讨论】: