首页 文章

从cassandra中的keyspace中检索thrift和CQL的所有columnfamily /表

提问于
浏览
0

我使用hector来操作2.1.8版本的cassandra,并希望从应用程序中的某些键空间中检索所有表 . 我使用“KeyspaceDefinition.getCfDefs()”来检索键空间中的columnfamily列表 .

但是,我发现getCfDefs()函数只能检索由thrift api创建的columnfamily,例如“me.prettyprint.hector.api.Cluster.updateColumnFamily”,而不是由CQL创建的表,例如cqlsh client .

那么,如何使用hector从某些键空间中检索所有表?

1 回答

  • 2

    您可以使用系统元数据表以编程方式检查键空间的所有表元数据:

    select * from system.schema_columnfamilies where keyspace_name='ks';
    select * from system.schema_columns where keyspace_name='ks';
    

    您需要自己聚合这些列和表 .

    或者,如果您没有绑定到此客户端,则可以使用cqlsh来解决相关的密钥空间,或者使用其中一个DataStax驱动程序和元数据API(javapython) .

相关问题