use of com.datastax.driver.core.MaterializedViewMetadata in project metacat by Netflix.
the class CassandraConnectorDatabaseService method listViewNames.
/**
* {@inheritDoc}
*/
@Override
public List<QualifiedName> listViewNames(@Nonnull @NonNull final ConnectorContext context, @Nonnull @NonNull final QualifiedName databaseName) {
final String catalogName = databaseName.getCatalogName();
final String keyspace = databaseName.getDatabaseName();
log.debug("Attempting to get materialized view names for keyspace {} due to request {}", keyspace, context);
try {
final KeyspaceMetadata keyspaceMetadata = this.getCluster().getMetadata().getKeyspace(keyspace);
if (keyspaceMetadata == null) {
throw new DatabaseNotFoundException(databaseName);
}
final ImmutableList.Builder<QualifiedName> viewsBuilder = ImmutableList.builder();
for (final MaterializedViewMetadata view : keyspaceMetadata.getMaterializedViews()) {
viewsBuilder.add(QualifiedName.ofView(catalogName, keyspace, view.getBaseTable().getName(), view.getName()));
}
final List<QualifiedName> views = viewsBuilder.build();
log.debug("Successfully found {} views for keyspace {} due to request {}", views.size(), keyspace, context);
return views;
} catch (final DriverException de) {
log.error(de.getMessage(), de);
throw this.getExceptionMapper().toConnectorException(de, databaseName);
}
}
Aggregations