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

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

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

Metadata.listTables介绍

[英]Get the names that match the specified table prefix (never null).
[中]获取与指定的表前缀匹配的名称(从不为null)。

代码示例

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

public static Set<SchemaTableName> listTables(Session session, Metadata metadata, AccessControl accessControl, QualifiedTablePrefix prefix)
{
  Set<SchemaTableName> tableNames = metadata.listTables(session, prefix).stream()
      .map(QualifiedObjectName::asSchemaTableName)
      .collect(toImmutableSet());
  return accessControl.filterTables(session.getRequiredTransactionId(), session.getIdentity(), prefix.getCatalogName(), tableNames);
}

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

@Override
public List<QualifiedObjectName> listTables(Session session, String catalog, String schema)
{
  lock.readLock().lock();
  try {
    return transaction(transactionManager, accessControl)
        .readOnly()
        .execute(session, transactionSession -> {
          return getMetadata().listTables(transactionSession, new QualifiedTablePrefix(catalog, schema));
        });
  }
  finally {
    lock.readLock().unlock();
  }
}

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

public Set<QualifiedTablePrefix> calculatePrefixesWithTableName(
    ConnectorSession connectorSession,
    Set<QualifiedTablePrefix> prefixes,
    TupleDomain<ColumnHandle> constraint,
    Optional<Predicate<Map<ColumnHandle, NullableValue>>> predicate)
{
  Session session = ((FullConnectorSession) connectorSession).getSession();
  Optional<Set<String>> tables = filterString(constraint, TABLE_NAME_COLUMN_HANDLE);
  if (tables.isPresent()) {
    return prefixes.stream()
        .flatMap(prefix -> tables.get().stream()
            .filter(this::isLowerCase)
            .map(table -> table.toLowerCase(ENGLISH))
            .map(table -> new QualifiedObjectName(catalogName, prefix.getSchemaName().get(), table)))
        .filter(objectName -> metadata.getTableHandle(session, objectName).isPresent() || metadata.getView(session, objectName).isPresent())
        .map(QualifiedObjectName::asQualifiedTablePrefix)
        .collect(toImmutableSet());
  }
  return prefixes.stream()
      .flatMap(prefix -> Stream.concat(
          metadata.listTables(session, prefix).stream(),
          metadata.listViews(session, prefix).stream()))
      .filter(objectName -> !predicate.isPresent() || predicate.get().test(asFixedValues(objectName)))
      .map(QualifiedObjectName::asQualifiedTablePrefix)
      .collect(toImmutableSet());
}

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

public List<QualifiedObjectName> listTables(Session session, String catalog, String schema)
{
  return transaction(prestoServer.getTransactionManager(), prestoServer.getAccessControl())
      .readOnly()
      .execute(session, transactionSession -> {
        return prestoServer.getMetadata().listTables(transactionSession, new QualifiedTablePrefix(catalog, schema));
      });
}

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

private List<QualifiedObjectName> getTablesList(Session session, String catalogName, Map<String, NullableValue> filters)
{
  return metadata.listTables(session, extractQualifiedTablePrefix(catalogName, filters));
}

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

@Override
public List<QualifiedObjectName> listTables(Session session, String catalog, String schema)
{
  lock.readLock().lock();
  try {
    return transaction(transactionManager)
        .readOnly()
        .execute(session, transactionSession -> {
          return getMetadata().listTables(transactionSession, new QualifiedTablePrefix(catalog, schema));
        });
  }
  finally {
    lock.readLock().unlock();
  }
}

代码示例来源:origin: com.facebook.presto/presto-tests

public List<QualifiedObjectName> listTables(Session session, String catalog, String schema)
{
  return transaction(prestoServer.getTransactionManager(), prestoServer.getAccessControl())
      .readOnly()
      .execute(session, transactionSession -> {
        return prestoServer.getMetadata().listTables(transactionSession, new QualifiedTablePrefix(catalog, schema));
      });
}

代码示例来源: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();
}

相关文章