当前位置: 首页>>代码示例>>Java>>正文


Java ColumnMetadata类代码示例

本文整理汇总了Java中com.facebook.presto.spi.ColumnMetadata的典型用法代码示例。如果您正苦于以下问题:Java ColumnMetadata类的具体用法?Java ColumnMetadata怎么用?Java ColumnMetadata使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ColumnMetadata类属于com.facebook.presto.spi包,在下文中一共展示了ColumnMetadata类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTableColMetadata

import com.facebook.presto.spi.ColumnMetadata; //导入依赖的package包/类
public Optional<List<ColumnMetadata>> getTableColMetadata(String connectorId, String dbName, String tblName)
{
    log.debug("Get list of column metadata of table " + formName(dbName, tblName));
    List<ColumnMetadata> colMetadatas = new ArrayList<>();
    MetaProto.StringListType dataTypeList = metaClient.listColumnsDataType(dbName, tblName);
    MetaProto.StringListType colNameList = metaClient.listColumns(dbName, tblName);
    if (dataTypeList.getIsEmpty() || colNameList.getIsEmpty()) {
        log.warn("No col matches!");
        return Optional.empty();
    }
    for (int i = 0; i < dataTypeList.getStrCount(); i++) {
        String dataType = dataTypeList.getStr(i);
        Type type = getType(dataType);
        ColumnMetadata metadata = new ColumnMetadata(
                colNameList.getStr(i),
                type,
                "",
                false);
        colMetadatas.add(metadata);
    }
    return Optional.of(colMetadatas);
}
 
开发者ID:dbiir,项目名称:paraflow,代码行数:23,代码来源:MetaDataQuery.java

示例2: createTable

import com.facebook.presto.spi.ColumnMetadata; //导入依赖的package包/类
@Override
public void createTable(ConnectorSession session, ConnectorTableMetadata tableMetadata)
{
    log.debug("Create table " + tableMetadata.getTable().getTableName());
    String tblName = tableMetadata.getTable().getTableName();
    String dbName = tableMetadata.getTable().getSchemaName();
    List<ColumnMetadata> columns = tableMetadata.getColumns();
    List<String> columnName = new LinkedList<>();
    List<String> dataType = new LinkedList<>();
    for (ColumnMetadata column : columns) {
        columnName.add(column.getName());
        dataType.add(column.getType().getDisplayName());
    }
    String userName = "";
    String storageFormatName = "";
    metaClient.createRegularTable(dbName, tblName, userName, storageFormatName, columnName, dataType);
}
 
开发者ID:dbiir,项目名称:paraflow,代码行数:18,代码来源:MetaDataQuery.java

示例3: listTableColumns

import com.facebook.presto.spi.ColumnMetadata; //导入依赖的package包/类
@Override
public Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(ConnectorSession session, SchemaTablePrefix prefix)
{
    requireNonNull(prefix, "prefix is null");

    ImmutableMap.Builder<SchemaTableName, List<ColumnMetadata>> columns = ImmutableMap.builder();

    List<SchemaTableName> tableNames = prefix.getSchemaName() == null ? listTables(session, null) : ImmutableList.of(new SchemaTableName(prefix.getSchemaName(), prefix.getTableName()));

    for (SchemaTableName tableName : tableNames) {
        ConnectorTableMetadata tableMetadata = getTableMetadata(tableName);
        // table can disappear during listing operation
        if (tableMetadata != null) {
            columns.put(tableName, tableMetadata.getColumns());
        }
    }
    return columns.build();
}
 
开发者ID:xiaoyao1991,项目名称:presto-ethereum,代码行数:19,代码来源:EthereumMetadata.java

示例4: listTableColumns

import com.facebook.presto.spi.ColumnMetadata; //导入依赖的package包/类
@Override
public Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(ConnectorSession session, SchemaTablePrefix prefix)
{
    requireNonNull(prefix, "prefix is null");
    KuduClient kuduClient = kuduClientManager.getClient();

    ImmutableMap.Builder<SchemaTableName, List<ColumnMetadata>> columns = ImmutableMap.builder();
    for (SchemaTableName tableName : listTables(session, prefix)) {
        KuduTableHandle tableHandle = kuduTables.getTables(kuduClient).get(tableName);
        if (tableHandle != null) {
            columns.put(tableName, kuduTables.getColumns(kuduClient, tableHandle));
        }
    }
    kuduClientManager.close(kuduClient);
    return columns.build();
}
 
开发者ID:trackingio,项目名称:presto-kudu,代码行数:17,代码来源:KuduMetadata.java

示例5: getColumnHandles

import com.facebook.presto.spi.ColumnMetadata; //导入依赖的package包/类
@Override
public Map<String, ColumnHandle> getColumnHandles(ConnectorSession session, ConnectorTableHandle tableHandle)
{
    ExampleTableHandle exampleTableHandle = checkType(tableHandle, ExampleTableHandle.class, "tableHandle");
    checkArgument(exampleTableHandle.getConnectorId().equals(connectorId), "tableHandle is not for this connector");

    ExampleTable table = exampleClient.getTable(exampleTableHandle.getSchemaName(), exampleTableHandle.getTableName());
    if (table == null) {
        throw new TableNotFoundException(exampleTableHandle.toSchemaTableName());
    }

    ImmutableMap.Builder<String, ColumnHandle> columnHandles = ImmutableMap.builder();
    int index = 0;
    for (ColumnMetadata column : table.getColumnsMetadata()) {
        columnHandles.put(column.getName(), new ExampleColumnHandle(connectorId, column.getName(), column.getType(), index));
        index++;
    }
    return columnHandles.build();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:20,代码来源:ExampleMetadata.java

示例6: getTableMetadata

import com.facebook.presto.spi.ColumnMetadata; //导入依赖的package包/类
@Override
public ConnectorTableMetadata getTableMetadata(ConnectorSession session, ConnectorTableHandle tableHandle)
{
    RaptorTableHandle handle = checkType(tableHandle, RaptorTableHandle.class, "tableHandle");
    SchemaTableName tableName = new SchemaTableName(handle.getSchemaName(), handle.getTableName());
    List<ColumnMetadata> columns = dao.getTableColumns(handle.getTableId()).stream()
            .map(TableColumn::toColumnMetadata)
            .filter(isSampleWeightColumn().negate())
            .collect(toCollection(ArrayList::new));
    if (columns.isEmpty()) {
        throw new PrestoException(RAPTOR_ERROR, "Table does not have any columns: " + tableName);
    }

    columns.add(hiddenColumn(SHARD_UUID_COLUMN_NAME, VARCHAR));
    return new ConnectorTableMetadata(tableName, columns);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:RaptorMetadata.java

示例7: addColumn

import com.facebook.presto.spi.ColumnMetadata; //导入依赖的package包/类
@Override
public void addColumn(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnMetadata column)
{
    RaptorTableHandle table = checkType(tableHandle, RaptorTableHandle.class, "tableHandle");

    // Always add new columns to the end.
    // TODO: This needs to be updated when we support dropping columns.
    List<TableColumn> existingColumns = dao.listTableColumns(table.getSchemaName(), table.getTableName());
    TableColumn lastColumn = existingColumns.get(existingColumns.size() - 1);
    long columnId = lastColumn.getColumnId() + 1;
    int ordinalPosition = existingColumns.size();

    String type = column.getType().getTypeSignature().toString();
    dao.insertColumn(table.getTableId(), columnId, column.getName(), ordinalPosition, type, null);
    shardManager.addColumn(table.getTableId(), new ColumnInfo(columnId, column.getType()));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:RaptorMetadata.java

示例8: getTableMetadata

import com.facebook.presto.spi.ColumnMetadata; //导入依赖的package包/类
@SuppressWarnings("ValueOfIncrementOrDecrementUsed")
private ConnectorTableMetadata getTableMetadata(SchemaTableName schemaTableName)
{
    RedisTableDescription table = getDefinedTables().get(schemaTableName);
    if (table == null) {
        throw new TableNotFoundException(schemaTableName);
    }

    ImmutableList.Builder<ColumnMetadata> builder = ImmutableList.builder();

    appendFields(builder, table.getKey());
    appendFields(builder, table.getValue());

    for (RedisInternalFieldDescription fieldDescription : internalFieldDescriptions) {
        builder.add(fieldDescription.getColumnMetadata(hideInternalColumns));
    }

    return new ConnectorTableMetadata(schemaTableName, builder.build());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:20,代码来源:RedisMetadata.java

示例9: listTableColumns

import com.facebook.presto.spi.ColumnMetadata; //导入依赖的package包/类
@Override
public Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(ConnectorSession session, SchemaTablePrefix prefix)
{
    requireNonNull(prefix, "prefix is null");
    if (prefix.getSchemaName() != null && !prefix.getSchemaName().equals(SCHEMA_NAME)) {
        return ImmutableMap.of();
    }

    ImmutableMap.Builder<SchemaTableName, List<ColumnMetadata>> columns = ImmutableMap.builder();

    List<SchemaTableName> tableNames;
    if (prefix.getTableName() == null) {
        tableNames = listTables(session, prefix.getSchemaName());
    }
    else {
        tableNames = ImmutableList.of(new SchemaTableName(prefix.getSchemaName(), prefix.getTableName()));
    }

    for (SchemaTableName tableName : tableNames) {
        JmxTableHandle tableHandle = getTableHandle(session, tableName);
        columns.put(tableName, tableHandle.getTableMetadata().getColumns());
    }
    return columns.build();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:25,代码来源:JmxMetadata.java

示例10: addColumn

import com.facebook.presto.spi.ColumnMetadata; //导入依赖的package包/类
@Override
public void addColumn(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnMetadata column)
{
    if (!allowAddColumn) {
        throw new PrestoException(PERMISSION_DENIED, "Adding Columns is disabled in this Hive catalog");
    }

    HiveTableHandle handle = checkType(tableHandle, HiveTableHandle.class, "tableHandle");
    Optional<Table> tableMetadata = metastore.getTable(handle.getSchemaName(), handle.getTableName());
    if (!tableMetadata.isPresent()) {
        throw new TableNotFoundException(handle.getSchemaTableName());
    }
    Table table = tableMetadata.get();
    StorageDescriptor sd = table.getSd();

    ImmutableList.Builder<FieldSchema> columns = ImmutableList.builder();
    columns.addAll(sd.getCols());
    columns.add(new FieldSchema(column.getName(), toHiveType(column.getType()).getHiveTypeName(), column.getComment()));
    sd.setCols(columns.build());

    table.setSd(sd);
    metastore.alterTable(handle.getSchemaName(), handle.getTableName(), table);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:24,代码来源:HiveMetadata.java

示例11: listTableColumns

import com.facebook.presto.spi.ColumnMetadata; //导入依赖的package包/类
@Override
public Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(ConnectorSession session, SchemaTablePrefix prefix)
{
    ImmutableMap.Builder<SchemaTableName, List<ColumnMetadata>> columns = ImmutableMap.builder();
    for (SchemaTableName tableName : listTables(session, prefix.getSchemaName())) {
        try {
            JdbcTableHandle tableHandle = jdbcClient.getTableHandle(tableName);
            if (tableHandle == null) {
                continue;
            }
            columns.put(tableName, getTableMetadata(session, tableHandle).getColumns());
        }
        catch (TableNotFoundException e) {
            // table disappeared during listing operation
        }
    }
    return columns.build();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:19,代码来源:JdbcMetadata.java

示例12: getTableMetadata

import com.facebook.presto.spi.ColumnMetadata; //导入依赖的package包/类
@Test
public void getTableMetadata()
{
    // known table
    ConnectorTableMetadata tableMetadata = metadata.getTableMetadata(SESSION, tableHandle);
    assertEquals(tableMetadata.getTable(), new SchemaTableName("example", "numbers"));
    assertEquals(tableMetadata.getColumns(), ImmutableList.of(
            new ColumnMetadata("text", VARCHAR, false),
            new ColumnMetadata("value", BIGINT, false)));

    // escaping name patterns
    JdbcTableHandle specialTableHandle = metadata.getTableHandle(SESSION, new SchemaTableName("exa_ple", "num_ers"));
    ConnectorTableMetadata specialTableMetadata = metadata.getTableMetadata(SESSION, specialTableHandle);
    assertEquals(specialTableMetadata.getTable(), new SchemaTableName("exa_ple", "num_ers"));
    assertEquals(specialTableMetadata.getColumns(), ImmutableList.of(
            new ColumnMetadata("te_t", VARCHAR, false),
            new ColumnMetadata("va%ue", BIGINT, false)));

    // unknown tables should produce null
    unknownTableMetadata(new JdbcTableHandle(CONNECTOR_ID, new SchemaTableName("u", "numbers"), null, "unknown", "unknown"));
    unknownTableMetadata(new JdbcTableHandle(CONNECTOR_ID, new SchemaTableName("example", "numbers"), null, "example", "unknown"));
    unknownTableMetadata(new JdbcTableHandle(CONNECTOR_ID, new SchemaTableName("example", "numbers"), null, "unknown", "numbers"));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:24,代码来源:TestJdbcMetadata.java

示例13: testCreateTableUnsupportedType

import com.facebook.presto.spi.ColumnMetadata; //导入依赖的package包/类
@Test
public void testCreateTableUnsupportedType()
{
    for (HiveStorageFormat storageFormat : createTableFormats) {
        try {
            ConnectorSession session = newSession();
            List<ColumnMetadata> columns = ImmutableList.of(new ColumnMetadata("dummy", HYPER_LOG_LOG, false));
            ConnectorTableMetadata tableMetadata = new ConnectorTableMetadata(invalidTable, columns, createTableProperties(storageFormat), session.getUser());
            metadata.beginCreateTable(session, tableMetadata);
            fail("create table with unsupported type should fail for storage format " + storageFormat);
        }
        catch (PrestoException e) {
            assertEquals(e.getErrorCode(), NOT_SUPPORTED.toErrorCode());
        }
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:AbstractTestHiveClient.java

示例14: buildColumns

import com.facebook.presto.spi.ColumnMetadata; //导入依赖的package包/类
private InternalTable buildColumns(Session session, String catalogName, Map<String, NullableValue> filters)
{
    InternalTable.Builder table = InternalTable.builder(informationSchemaTableColumns(TABLE_COLUMNS));
    for (Entry<QualifiedObjectName, List<ColumnMetadata>> entry : getColumnsList(session, catalogName, filters).entrySet()) {
        QualifiedObjectName tableName = entry.getKey();
        int ordinalPosition = 1;
        for (ColumnMetadata column : entry.getValue()) {
            if (column.isHidden()) {
                continue;
            }
            table.add(
                    tableName.getCatalogName(),
                    tableName.getSchemaName(),
                    tableName.getObjectName(),
                    column.getName(),
                    ordinalPosition,
                    null,
                    "YES",
                    column.getType().getDisplayName(),
                    column.getComment());
            ordinalPosition++;
        }
    }
    return table.build();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:26,代码来源:InformationSchemaPageSourceProvider.java

示例15: cursor

import com.facebook.presto.spi.ColumnMetadata; //导入依赖的package包/类
@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();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:19,代码来源:ColumnJdbcTable.java


注:本文中的com.facebook.presto.spi.ColumnMetadata类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。