0

I use hector to manipulate cassandra of version 2.1.8 and want to retrieve all the tables from certain keyspace in an application. I use "KeyspaceDefinition.getCfDefs()" to retrieve the columnfamily list in a keyspace.

However, I found that the getCfDefs() function can just retrieve the columnfamily created by the thrift api such as "me.prettyprint.hector.api.Cluster.updateColumnFamily" but not table created by CQL such as cqlsh client.

Then, how to retrieve all the tables from certain keyspace by using hector?

Community
  • 1
  • 1
chenatu
  • 827
  • 2
  • 10
  • 22
  • possible duplicate of [How to list column families in keyspace?](http://stackoverflow.com/questions/22734191/how-to-list-column-families-in-keyspace) – Aaron Aug 05 '15 at 16:58
  • @BryceAtNetwork23 I am trying to do it by using Hector. However, I may use CQL rather than hector in future. – chenatu Aug 05 '15 at 23:48

1 Answers1

2

You can inspect all table metadata for a keyspace programmatically using the system metadata tables:

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

You would need to aggregate these columns and tables yourself.

Alternatively, if you're not tied to this client, you can use cqlsh to "describe" the keyspace in question, or use one of the DataStax drivers with a metadata API (java, python).

Adam Holmberg
  • 7,245
  • 3
  • 30
  • 53
  • Thank you Adam. I discussed with others and found that a thrift client can't see tables created through CQL. I am considering using CQL rather than hector. – chenatu Aug 05 '15 at 23:34