com.facebook.presto.metadata.Metadata.getCatalogNames()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中com.facebook.presto.metadata.Metadata.getCatalogNames()方法的一些代码示例,展示了Metadata.getCatalogNames()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Metadata.getCatalogNames()方法的具体详情如下:
包路径:com.facebook.presto.metadata.Metadata
类名称:Metadata
方法名:getCatalogNames

Metadata.getCatalogNames介绍

[英]Gets all the loaded catalogs
[中]获取所有加载的目录

代码示例

代码示例来源:origin: prestodb/presto

public static SortedMap<String, ConnectorId> listCatalogs(Session session, Metadata metadata, AccessControl accessControl)
{
  Map<String, ConnectorId> catalogNames = metadata.getCatalogNames(session);
  Set<String> allowedCatalogs = accessControl.filterCatalogs(session.getIdentity(), catalogNames.keySet());
  ImmutableSortedMap.Builder<String, ConnectorId> result = ImmutableSortedMap.naturalOrder();
  for (Map.Entry<String, ConnectorId> entry : catalogNames.entrySet()) {
    if (allowedCatalogs.contains(entry.getKey())) {
      result.put(entry);
    }
  }
  return result.build();
}

代码示例来源:origin: uk.co.nichesolutions.presto/presto-main

@Override
  public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession session, TupleDomain<Integer> constraint)
  {
    Builder table = InMemoryRecordSet.builder(CATALOG_TABLE);
    for (Map.Entry<String, String> entry : metadata.getCatalogNames().entrySet()) {
      table.addRow(entry.getKey(), entry.getValue());
    }
    return table.build().cursor();
  }
}

代码示例来源:origin: uk.co.nichesolutions.presto/presto-main

@Override
protected RelationType visitShowCatalogs(ShowCatalogs node, AnalysisContext context)
{
  List<Expression> rows = metadata.getCatalogNames().keySet().stream()
      .map(name -> row(new StringLiteral(name)))
      .collect(toList());
  Query query = simpleQuery(
      selectList(new AllColumns()),
      aliased(new Values(rows), "catalogs", ImmutableList.of("Catalog")));
  return process(query, context);
}

代码示例来源:origin: uk.co.nichesolutions.presto/presto-main

@Override
  public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession session, TupleDomain<Integer> constraint)
  {
    Builder table = InMemoryRecordSet.builder(METADATA);
    for (String name : metadata.getCatalogNames().keySet()) {
      table.addRow(name);
    }
    return table.build().cursor();
  }
}

代码示例来源:origin: uk.co.nichesolutions.presto/presto-main

Set<String> catalogs = metadata.getCatalogNames().keySet();

代码示例来源:origin: uk.co.nichesolutions.presto/presto-main

@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession connectorSession, TupleDomain<Integer> constraint)
{
  GlobalSystemTransactionHandle transaction = checkType(transactionHandle, GlobalSystemTransactionHandle.class, "transaction");
  Session session = toSession(transaction.getTransactionId(), connectorSession);
  Optional<String> catalogFilter = stringFilter(constraint, 0);
  Optional<String> schemaFilter = stringFilter(constraint, 1);
  Optional<String> tableFilter = stringFilter(constraint, 2);
  Builder table = InMemoryRecordSet.builder(METADATA);
  for (String catalog : filter(metadata.getCatalogNames().keySet(), catalogFilter)) {
    QualifiedTablePrefix prefix = FilterUtil.tablePrefix(catalog, schemaFilter, tableFilter);
    for (Entry<QualifiedObjectName, List<ColumnMetadata>> entry : metadata.listTableColumns(session, prefix).entrySet()) {
      addColumnRows(table, entry.getKey(), entry.getValue());
    }
  }
  return table.build().cursor();
}

代码示例来源:origin: uk.co.nichesolutions.presto/presto-main

@Override
  public CompletableFuture<?> execute(RenameTable statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine)
  {
    Session session = stateMachine.getSession();
    QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getSource());
    Optional<TableHandle> tableHandle = metadata.getTableHandle(session, tableName);
    if (!tableHandle.isPresent()) {
      throw new SemanticException(MISSING_TABLE, statement, "Table '%s' does not exist", tableName);
    }

    QualifiedObjectName target = createQualifiedObjectName(session, statement, statement.getTarget());
    if (!metadata.getCatalogNames().containsKey(target.getCatalogName())) {
      throw new SemanticException(MISSING_CATALOG, statement, "Target catalog '%s' does not exist", target.getCatalogName());
    }
    if (metadata.getTableHandle(session, target).isPresent()) {
      throw new SemanticException(TABLE_ALREADY_EXISTS, statement, "Target table '%s' already exists", target);
    }
    if (!tableName.getCatalogName().equals(target.getCatalogName())) {
      throw new SemanticException(NOT_SUPPORTED, statement, "Table rename across catalogs is not supported");
    }
    accessControl.checkCanRenameTable(session.getRequiredTransactionId(), session.getIdentity(), tableName, target);

    metadata.renameTable(session, tableHandle.get(), target);

    return completedFuture(null);
  }
}

代码示例来源:origin: uk.co.nichesolutions.presto/presto-main

@Override
  public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession connectorSession, TupleDomain<Integer> constraint)
  {
    GlobalSystemTransactionHandle transaction = checkType(transactionHandle, GlobalSystemTransactionHandle.class, "transaction");
    Session session = toSession(transaction.getTransactionId(), connectorSession);
    Optional<String> catalogFilter = FilterUtil.stringFilter(constraint, 1);

    Builder table = InMemoryRecordSet.builder(METADATA);
    for (String catalog : filter(metadata.getCatalogNames().keySet(), catalogFilter)) {
      for (String schema : metadata.listSchemaNames(session, catalog)) {
        table.addRow(schema, catalog);
      }
    }
    return table.build().cursor();
  }
}

代码示例来源:origin: uk.co.nichesolutions.presto/presto-main

if (!metadata.getCatalogNames().containsKey(name.getCatalogName())) {
  throw new SemanticException(MISSING_CATALOG, table, "Catalog %s does not exist", name.getCatalogName());

代码示例来源:origin: uk.co.nichesolutions.presto/presto-main

@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession connectorSession, TupleDomain<Integer> constraint)
{
  GlobalSystemTransactionHandle transaction = checkType(transactionHandle, GlobalSystemTransactionHandle.class, "transaction");
  Session session = toSession(transaction.getTransactionId(), connectorSession);
  Optional<String> catalogFilter = stringFilter(constraint, 0);
  Optional<String> schemaFilter = stringFilter(constraint, 1);
  Optional<String> tableFilter = stringFilter(constraint, 2);
  Optional<String> typeFilter = stringFilter(constraint, 3);
  Builder table = InMemoryRecordSet.builder(METADATA);
  for (String catalog : filter(metadata.getCatalogNames().keySet(), catalogFilter)) {
    QualifiedTablePrefix prefix = tablePrefix(catalog, schemaFilter, tableFilter);
    if (FilterUtil.emptyOrEquals(typeFilter, "TABLE")) {
      for (QualifiedObjectName name : metadata.listTables(session, prefix)) {
        table.addRow(tableRow(name, "TABLE"));
      }
    }
    if (FilterUtil.emptyOrEquals(typeFilter, "VIEW")) {
      for (QualifiedObjectName name : metadata.listViews(session, prefix)) {
        table.addRow(tableRow(name, "VIEW"));
      }
    }
  }
  return table.build().cursor();
}

相关文章