use of com.netflix.metacat.common.server.connectors.ConnectorTableService in project metacat by Netflix.
the class ConnectorTableServiceProxy method get.
/**
* Returns table if <code>useCache</code> is true and object exists in the cache. If <code>useCache</code> is false
* or object does not exists in the cache, it is retrieved from the store.
* @param name table name
* @param getTableServiceParameters get table parameters
* @param useCache true, if table can be retrieved from cache
* @return table dto
*/
@Cacheable(key = "'table.' + #name", condition = "#useCache")
public TableInfo get(final QualifiedName name, final GetTableServiceParameters getTableServiceParameters, final boolean useCache) {
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
final ConnectorRequestContext connectorRequestContext = converterUtil.toConnectorContext(metacatRequestContext);
connectorRequestContext.setIncludeMetadata(getTableServiceParameters.isIncludeMetadataFromConnector());
final ConnectorTableService service = connectorManager.getTableService(name);
return service.get(connectorRequestContext, name);
}
use of com.netflix.metacat.common.server.connectors.ConnectorTableService in project metacat by Netflix.
the class MViewServiceImpl method list.
/**
* {@inheritDoc}
*/
@Override
public List<NameDateDto> list(final QualifiedName name) {
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
final QualifiedName viewDbName = QualifiedName.ofDatabase(name.getCatalogName(), VIEW_DB_NAME);
final ConnectorTableService service = connectorManager.getTableService(viewDbName);
List<QualifiedName> tableNames = Lists.newArrayList();
try {
final ConnectorRequestContext connectorRequestContext = converterUtil.toConnectorContext(metacatRequestContext);
tableNames = service.listNames(connectorRequestContext, viewDbName, null, null, null);
} catch (Exception ignored) {
// ignore. Return an empty list if database 'franklinviews' does not exist
}
if (!name.isDatabaseDefinition() && name.isCatalogDefinition()) {
return tableNames.stream().map(viewName -> {
final NameDateDto dto = new NameDateDto();
dto.setName(viewName);
return dto;
}).collect(Collectors.toList());
} else {
final String prefix = String.format("%s_%s_", name.getDatabaseName(), MoreObjects.firstNonNull(name.getTableName(), ""));
return tableNames.stream().filter(qualifiedTableName -> qualifiedTableName.getTableName().startsWith(prefix)).map(qualifiedTableName -> {
final NameDateDto dto = new NameDateDto();
dto.setName(QualifiedName.ofView(qualifiedTableName.getCatalogName(), name.getDatabaseName(), name.getTableName(), qualifiedTableName.getTableName().substring(prefix.length())));
return dto;
}).collect(Collectors.toList());
}
}
Aggregations