本文整理了Java中com.netflix.metacat.common.QualifiedName
类的一些代码示例,展示了QualifiedName
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QualifiedName
类的具体详情如下:
包路径:com.netflix.metacat.common.QualifiedName
类名称:QualifiedName
[英]A fully qualified name that references a source of data.
[中]
代码示例来源:origin: Netflix/metacat
/**
* Constructor.
*
* @param tableName table name
* @param partitionName partition name
* @param cause error cause
*/
public PartitionNotFoundException(
final QualifiedName tableName,
final String partitionName,
@Nullable final Throwable cause
) {
super(QualifiedName.ofPartition(tableName.getCatalogName(),
tableName.getDatabaseName(), tableName.getTableName(), partitionName),
String.format("Partition %s not found for table %s", partitionName, tableName),
cause, false, false);
this.tableName = tableName;
this.partitionName = partitionName;
}
}
代码示例来源:origin: Netflix/metacat
/**
* Check at database level.
*/
private void checkPermit(final Map<QualifiedName, Set<String>> accessACL,
final String userName,
final QualifiedName name,
final MetacatOperation op) {
final Set<String> users =
accessACL.get(QualifiedName.ofDatabase(name.getCatalogName(), name.getDatabaseName()));
if ((users != null) && !users.isEmpty() && !users.contains(userName)) {
throw new MetacatUnAuthorizedException(String.format("%s is not permitted for %s %s",
userName, op.name(), name
));
}
}
代码示例来源:origin: Netflix/metacat
/**
* {@inheritDoc}
*/
@Override
public void delete(final QualifiedName name) {
final QualifiedName tableName = QualifiedName
.ofTable(name.getCatalogName(), name.getDatabaseName(), name.getTableName());
delete(tableName, Lists.newArrayList(name.getPartitionName()));
}
代码示例来源:origin: Netflix/metacat
/**
* {@inheritDoc}
*/
@Override
protected String getDropTableSql(final QualifiedName name, final String finalTableName) {
return "DROP TABLE " + name.getCatalogName() + "." + name.getDatabaseName() + "." + finalTableName;
}
}
代码示例来源:origin: Netflix/metacat
/**
* The view is going to be represented by a table in a special db in Franklin. As such there must be
* a conversion from view id -> view table id like so:
* [dbName]_[tableName]_[viewName]
*/
private String createViewName(final QualifiedName name) {
return String.format("%s_%s_%s", name.getDatabaseName(), name.getTableName(), name.getViewName());
}
}
代码示例来源:origin: Netflix/metacat
for (String tableName : metacatHiveClient.getAllTables(name.getDatabaseName())) {
final QualifiedName qualifiedName = QualifiedName.ofDatabase(name.getCatalogName(), tableName);
if (prefix != null && !qualifiedName.toString().startsWith(prefix.toString())) {
continue;
final Table table = metacatHiveClient.getTableByName(name.getDatabaseName(), tableName);
tableInfos.add(hiveMetacatConverters.toTableInfo(name, table));
ConnectorUtils.sort(tableInfos, sort, Comparator.comparing(p -> p.getName().getTableName()));
代码示例来源:origin: Netflix/metacat
/**
* {@inheritDoc}
*/
@Override
public void rename(final QualifiedName name, final QualifiedName newViewName) {
final QualifiedName oldViewQName =
QualifiedName.ofTable(name.getCatalogName(), VIEW_DB_NAME, createViewName(name));
final QualifiedName newViewQName = QualifiedName
.ofTable(newViewName.getCatalogName(), VIEW_DB_NAME, createViewName(newViewName));
tableService.rename(oldViewQName, newViewQName, true);
}
代码示例来源:origin: Netflix/metacat
@Override
public int getPartitionCount(@Nonnull final ConnectorRequestContext context,
@Nonnull final QualifiedName table,
final TableInfo tableInfo
) {
return partitionDao.count(catalogName, table.getDatabaseName(), table.getTableName()).intValue();
}
代码示例来源:origin: Netflix/metacat
/**
* Returns true if tableName is enabled for deifnition metadata delete either explicitly or if the
* table's database/catalog is configure to.
*
* @param tableName table name
* @return whether or not to delete definition metadata
*/
private boolean isEnabledForTableDefinitionMetadataDelete(final QualifiedName tableName) {
final Set<QualifiedName> enableDeleteForQualifiedNames = config.getNamesEnabledForDefinitionMetadataDelete();
return enableDeleteForQualifiedNames.contains(tableName)
|| enableDeleteForQualifiedNames.contains(
QualifiedName.ofDatabase(tableName.getCatalogName(), tableName.getDatabaseName()))
|| enableDeleteForQualifiedNames.contains(QualifiedName.ofCatalog(tableName.getCatalogName()));
}
代码示例来源:origin: Netflix/metacat
@Override
public void renameTableTags(final QualifiedName name, final String newTableName) {
try {
final QualifiedName newName = QualifiedName.ofTable(name.getCatalogName(), name.getDatabaseName(),
newTableName);
if (get(newName) != null) {
delete(newName, true);
}
jdbcTemplate.update(SQL_UPDATE_TAG_ITEM, new String[]{newName.toString(), name.toString()},
new int[]{Types.VARCHAR, Types.VARCHAR});
} catch (Exception e) {
final String message = String.format("Failed to rename item name %s", name);
log.error(message, e);
throw new UserMetadataServiceException(message, e);
}
}
代码示例来源:origin: Netflix/metacat
@Override
public List<QualifiedName> listNames(@Nonnull final ConnectorRequestContext context,
@Nonnull final QualifiedName name,
@Nullable final QualifiedName prefix,
@Nullable final Sort sort,
@Nullable final Pageable pageable) {
log.debug("List table names for database {} with table name prefix {}", name, prefix);
return tableDao.searchBySourceDatabaseTableName(catalogName, name.getDatabaseName(),
prefix == null ? null : prefix.getTableName(), sort, pageable).stream()
.map(t -> QualifiedName.ofTable(catalogName, name.getDatabaseName(), t.getName()))
.collect(Collectors.toList());
}
代码示例来源:origin: Netflix/metacat
switch (parts.length) {
case 1:
return ofCatalog(parts[0]);
case 2:
return ofDatabase(parts[0], parts[1]);
case 3:
return ofTable(parts[0], parts[1], parts[2]);
case 4:
if (isView || !parts[3].contains("=")) {
return ofView(parts[0], parts[1], parts[2], parts[3]);
} else {
return ofPartition(parts[0], parts[1], parts[2], parts[3]);
代码示例来源:origin: Netflix/metacat
/**
* {@inheritDoc}.
*/
@Override
public List<QualifiedName> listNames(
final ConnectorRequestContext requestContext,
final QualifiedName name,
@Nullable final QualifiedName prefix,
@Nullable final Sort sort,
@Nullable final Pageable pageable) {
return Lists.newArrayList(QualifiedName.ofDatabase(name.getCatalogName(), DruidConfigConstants.DRUID_DB));
}
代码示例来源:origin: Netflix/metacat
@Override
public void delete(@Nonnull final ConnectorRequestContext context, @Nonnull final QualifiedName name) {
log.debug("Start: Delete partition {}", name);
partitionDao.deleteByNames(catalogName, name.getDatabaseName(), name.getTableName(),
Lists.newArrayList(name.getPartitionName()));
log.debug("End: Delete partition {}", name);
}
代码示例来源:origin: Netflix/metacat
@Override
public void create(@Nonnull final ConnectorRequestContext context, @Nonnull final TableInfo tableInfo) {
log.debug("Start: Create table {}", tableInfo.getName());
Preconditions.checkArgument(tableInfo.getSerde() == null
|| !Strings.isNullOrEmpty(tableInfo.getSerde().getOwner()), "Table owner is null or empty");
final QualifiedName tableName = tableInfo.getName();
if (tableDao.getBySourceDatabaseTableName(catalogName, tableName.getDatabaseName(),
tableName.getTableName()) != null) {
throw new TableAlreadyExistsException(tableName);
}
final Database database = databaseDao
.getBySourceDatabaseName(catalogName, tableName.getDatabaseName());
if (database == null) {
throw new DatabaseNotFoundException(QualifiedName.ofDatabase(catalogName, tableName.getDatabaseName()));
}
tableDao.save(infoConverter.fromTableInfo(database, tableInfo));
log.debug("End: Create table {}", tableInfo.getName());
}
代码示例来源:origin: Netflix/metacat
@Override
public Table load(final String tableName) {
final QualifiedName table = QualifiedName.fromString(tableName);
return super.load(table.getDatabaseName(), table.getTableName());
}
代码示例来源:origin: Netflix/metacat
/**
* {@inheritDoc}
*/
@Override
public boolean exists(final QualifiedName name) {
final CatalogDto catalogDto = catalogService.get(QualifiedName.ofCatalog(name.getCatalogName()));
return catalogDto.getDatabases().contains(name.getDatabaseName());
}
代码示例来源:origin: Netflix/metacat
@Override
public List<QualifiedName> listNames(@Nonnull final ConnectorRequestContext context,
@Nonnull final QualifiedName name,
@Nullable final QualifiedName prefix,
@Nullable final Sort sort,
@Nullable final Pageable pageable) {
log.debug("List database names for catalog {} and database with prefix {}", name, prefix);
return databaseDao.searchBySourceDatabaseName(catalogName, prefix == null ? "" : prefix.getTableName(),
sort, pageable).stream().map(d -> QualifiedName.ofDatabase(catalogName, d.getName())).collect(
Collectors.toList());
}
代码示例来源:origin: Netflix/metacat
@Override
public List<QualifiedName> listNames(@Nonnull final ConnectorRequestContext context,
@Nonnull final QualifiedName name,
@Nullable final QualifiedName prefix,
@Nullable final Sort sort,
@Nullable final Pageable pageable) {
log.debug("Get partition names for table {} with prefix {}", name, prefix);
return _getPartitions(name, null, null, sort, pageable, true).stream().map(BaseInfo::getName)
.filter(partitionName -> partitionName.getPartitionName().startsWith(prefix.getPartitionName()))
.collect(Collectors.toList());
}
代码示例来源:origin: Netflix/metacat
@Override
public DatabaseInfo get(@Nonnull final ConnectorRequestContext context, @Nonnull final QualifiedName name) {
final String databaseName = name.getDatabaseName();
Preconditions.checkNotNull(databaseName, "Database name is null");
log.debug("Get database {}", name);
final Database database = databaseDao.getBySourceDatabaseName(catalogName, databaseName);
if (database == null) {
throw new DatabaseNotFoundException(name);
}
return infoConverter.toDatabaseInfo(QualifiedName.ofCatalog(catalogName), database);
}
内容来源于网络,如有侵权,请联系作者删除!