Cassandra Client驱动程序为什么比CQLSH响应更多的信息

发布于 2025-01-25 23:55:29 字数 1889 浏览 5 评论 0原文

我正在使用 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>

我的问题是:

  1. 为什么客户驱动程序可以提供更多结果信息。
  2. 我可以使用CQLSH获得相同的结果吗?
  3. 上面的结果包括属性,它的结构看起来像:
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:

  1. Why could client driver provide more information of the results.
  2. Can I get the same results by using cqlsh?
  3. 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 Rows?

Thank you so much.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

提赋 2025-02-01 23:55:29

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文