use of com.netflix.metacat.connector.polaris.store.entities.PolarisDatabaseEntity in project metacat by Netflix.
the class PolarisConnectorDatabaseService method get.
/**
* {@inheritDoc}.
*/
@Override
public DatabaseInfo get(final ConnectorRequestContext context, final QualifiedName name) {
try {
final PolarisDatabaseMapper mapper = new PolarisDatabaseMapper(name.getCatalogName());
final PolarisDatabaseEntity db = polarisStoreService.getDatabase(name.getDatabaseName()).orElseThrow(() -> new DatabaseNotFoundException(name));
return mapper.toInfo(db);
} catch (DatabaseNotFoundException exception) {
log.error(String.format("Not found exception for polaris database %s", name), exception);
throw exception;
} catch (Exception exception) {
throw new ConnectorException(String.format("Failed get polaris database %s", name), exception);
}
}
use of com.netflix.metacat.connector.polaris.store.entities.PolarisDatabaseEntity in project metacat by Netflix.
the class PolarisConnectorDatabaseService method list.
/**
* {@inheritDoc}.
*/
@Override
public List<DatabaseInfo> list(final ConnectorRequestContext context, final QualifiedName name, @Nullable final QualifiedName prefix, @Nullable final Sort sort, @Nullable final Pageable pageable) {
try {
final PolarisDatabaseMapper mapper = new PolarisDatabaseMapper(name.getCatalogName());
List<PolarisDatabaseEntity> dbs = polarisStoreService.getAllDatabases();
if (prefix != null) {
dbs = dbs.stream().filter(n -> QualifiedName.ofDatabase(name.getCatalogName(), n.getDbName()).startsWith(prefix)).collect(Collectors.toCollection(ArrayList::new));
}
if (sort != null) {
ConnectorUtils.sort(dbs, sort, Comparator.comparing(p -> p.getDbName()));
}
return ConnectorUtils.paginate(dbs, pageable).stream().map(d -> mapper.toInfo(d)).collect(Collectors.toList());
} catch (Exception exception) {
throw new ConnectorException(String.format("Failed databases list polaris prefix %s", prefix), exception);
}
}
use of com.netflix.metacat.connector.polaris.store.entities.PolarisDatabaseEntity in project metacat by Netflix.
the class PolarisStoreConnector method getAllDatabases.
/**
* Fetches all database entities.
*
* @return Polaris Database entities
*/
@Override
@Transactional(propagation = Propagation.SUPPORTS)
public List<PolarisDatabaseEntity> getAllDatabases() {
final int pageFetchSize = 1000;
final List<PolarisDatabaseEntity> retval = new ArrayList<>();
Pageable page = PageRequest.of(0, pageFetchSize);
boolean hasNext;
do {
final Slice<PolarisDatabaseEntity> dbs = dbRepo.getDatabases(page);
retval.addAll(dbs.toList());
hasNext = dbs.hasNext();
if (hasNext) {
page = dbs.nextPageable();
}
} while (hasNext);
return retval;
}
Aggregations