node.js - 如何取消/中止 Cassandra 查询?

标签 node.js cassandra cassandra-2.0

在 NodeJS Cassandra 代码中,在处理来自 client.stream()client.eachRow() 的每一行的回调时,停止迭代的正确方法是什么?我如何告诉客户端对象我不再对结果感兴趣。引发“错误”或“完成”事件甚至可能是值得的。

此外,如果在以异步方式处理一行时,代码会使用相同的客户端对象启动另一个查询,那么 nodejs-driver 会不会有任何问题?

最佳答案

使用 client.stream,您正在使用 stream.Readable所以你可以调用pause()然而,在流中,驱动程序将继续解析和缓冲数据,并在其运行时拉入新页面(假设启用了自动分页)。

使用 client.streamclient.eachRow 时,您可以提供 autoPage选项来确定驱动程序在到达页面末尾时是否继续分页。如果您担心从大型结果集中读取过多数据,则可以将上一个查询的 pageState 用于下一个查询(例如 here )。不幸的是,这还不适用于 client.stream ( NODEJS-145 )。

Also, would there be any problems with nodejs-driver if, while processing a row in an async fashion, the code starts another query using the same client object?

那不是问题:)

关于node.js - 如何取消/中止 Cassandra 查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31463117/

相关文章:

node.js - websockets 的相对路径

javascript - 从一个函数返回值到另一个函数

cassandra - cqlsh 入门给出了无效的语法

docker - 通过 docker-compose 运行具有多个卷的多个实例

cassandra - cassandra 中的故障检测和恢复机制如何工作?

javascript - 在 JavaScript 中将数组转换为对象

node.js - 获取 Waterline 中插入的记录

Cassandra Gossip 正在增加未决任务

Cassandra LeveledCompactionStrategy 和每次读取的高 SSTable 数

cassandra - 原子批处理在Cassandra中如何工作?