Cassandra Client驱动程序为什么比CQLSH响应更多的信息
我正在使用 datastax nodejs-driver 以获取Cassandra的密钥空间信息。
const results = await client.execute( `
DESC KEYSPACE ${keyspace}
` );
client.ecute
方法返回一个对象包含很多信息:
ResultSet {
info: {
queriedHost: '127.0.0.1:9042',
triedHosts: { '127.0.0.1:9042': null },
speculativeExecutions: 0,
achievedConsistency: 10,
traceId: undefined,
warnings: undefined,
customPayload: undefined,
isSchemaInAgreement: true
},
rows: [
Row {
keyspace_name: 'xxxx',
type: 'keyspace',
name: 'xxxx',
create_statement: "CREATE KEYSPACE xxxx WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '3'} AND durable_writes = true;"
}
],
rowLength: 1,
columns: [
{ name: 'keyspace_name', type: [Object] },
{ name: 'type', type: [Object] },
{ name: 'name', type: [Object] },
{ name: 'create_statement', type: [Object] }
],
pageState: null,
nextPage: undefined,
nextPageAsync: undefined
}
但是执行desc键xxxx
,只有create> create_statement
part warge响应:
cqlsh> DESC xxxx;
CREATE KEYSPACE xxxx WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '3'} AND durable_writes = true;
cqlsh>
我的问题是:
- 为什么客户驱动程序可以提供更多结果信息。
- 我可以使用CQLSH获得相同的结果吗?
- 上面的结果包括
行
属性,它的结构看起来像:
interface Row {
keyspace_name: string;
type: 'keyspace';
name: string;
create_statement: string;
}
在哪里可以找到不同类型的行
s的声明?
太感谢了。
I am using datastax nodejs-driver to get information of a keyspace from cassandra.
const results = await client.execute( `
DESC KEYSPACE ${keyspace}
` );
The client.execute
method returns an object includes lots of information:
ResultSet {
info: {
queriedHost: '127.0.0.1:9042',
triedHosts: { '127.0.0.1:9042': null },
speculativeExecutions: 0,
achievedConsistency: 10,
traceId: undefined,
warnings: undefined,
customPayload: undefined,
isSchemaInAgreement: true
},
rows: [
Row {
keyspace_name: 'xxxx',
type: 'keyspace',
name: 'xxxx',
create_statement: "CREATE KEYSPACE xxxx WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '3'} AND durable_writes = true;"
}
],
rowLength: 1,
columns: [
{ name: 'keyspace_name', type: [Object] },
{ name: 'type', type: [Object] },
{ name: 'name', type: [Object] },
{ name: 'create_statement', type: [Object] }
],
pageState: null,
nextPage: undefined,
nextPageAsync: undefined
}
But while execute DESC KEYSPACE xxxx
, only the create_statement
part is responded:
cqlsh> DESC xxxx;
CREATE KEYSPACE xxxx WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '3'} AND durable_writes = true;
cqlsh>
My questions are:
- Why could client driver provide more information of the results.
- Can I get the same results by using cqlsh?
- The result above includes a
Row
property, it's structure looks like something like:
interface Row {
keyspace_name: string;
type: 'keyspace';
name: string;
create_statement: string;
}
Where can I find the declarations of different types of Row
s?
Thank you so much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
CQLSH是一种交互式用户外壳,因此在文本中以简洁的查询响应做出响应。 Node.js驱动程序(或带有CQLSH的Python驱动程序)返回结果集对象,并且可读取。机器可读结果通常包含很多其他信息。
cqlsh让我们启用追踪。通过跟踪,您将获得更多的详细信息。
CQLSH is an interactive user shell, so it responds with a succinct query response in text. The Node.js driver (or Python driver with CQLSH) returns a ResultSet object and is machine readable. Machine readable results will usually contain a lot of additional information.
CQLSH let's you enable tracing. With tracing you'll get a more verbose level of information.