我正在尝试恢复我的对象的最后一个状态,但是这个子选择不起作用,我已经看到新版本的cassandra db支持聚合操作和子查询。
select * from event_store
where event_version = (select max(event_version) from event_store)
ALLOW FILTERING;
语法异常:第1:49行输入'select'没有可行的选择(...来自event_version = [(] select ...)的event_store
答案 0 :(得分:5)
您可以使用2个单独的查询来执行此操作:
int HASH_UPDATE(HASH_CTX *c, const void *data_, size_t len)
{
const unsigned char *data = data_;
unsigned char *p;
HASH_LONG l;
size_t n;
if (len == 0)
return 1;
l = (c->Nl + (((HASH_LONG) len) << 3)) & 0xffffffffUL;
/*
* 95-05-24 eay Fixed a bug with the overflow handling, thanks to Wei
Dai
* <weidai@eskimo.com> for pointing it out.
*/
if (l < c->Nl) /* overflow */
c->Nh++;
c->Nh += (HASH_LONG) (len >> 29); /* might cause compiler warning on
* 16-bit */
c->Nl = l;
n = c->num;
if (n != 0) {
p = (unsigned char *)c->data;
if (len >= HASH_CBLOCK || len + n >= HASH_CBLOCK) {
memcpy(p + n, data, HASH_CBLOCK - n);
HASH_BLOCK_DATA_ORDER(c, p, 1);
n = HASH_CBLOCK - n;
data += n;
len -= n;
c->num = 0;
/*
* We use memset rather than OPENSSL_cleanse() here
deliberately.
* Using OPENSSL_cleanse() here could be a performance issue.
It
* will get properly cleansed on finalisation so this isn't a
* security problem.
*/
memset(p, 0, HASH_CBLOCK); /* keep it zeroed */
} else {
memcpy(p + n, data, len);
c->num += (unsigned int)len;
return 1;
}
}
n = len / HASH_CBLOCK;
if (n > 0) {
HASH_BLOCK_DATA_ORDER(c, data, n);
n *= HASH_CBLOCK;
data += n;
len -= n;
}
if (len != 0) {
p = (unsigned char *)c->data;
c->num = (unsigned int)len;
memcpy(p, data, len);
}
return 1;
}
然后
select max(event_version) from event_store;
我可能有点过时,但看起来没有子选择支持:
停止处理此故障单
https://issues.apache.org/jira/browse/CASSANDRA-8846
有人试图这样做:
https://github.com/jobmthomas/Cassandra-SubQuery
但总的来说,cassandra并不支持。