Search in sources :

Example 1 with Location

use of com.netflix.metacat.connector.s3.model.Location in project metacat by Netflix.

the class S3ConnectorInfoConverter method toFields.

private List<FieldInfo> toFields(final Table table) {
    List<FieldInfo> result = Lists.newArrayList();
    final Location location = table.getLocation();
    if (location != null) {
        final Schema schema = location.getSchema();
        if (schema != null) {
            result = schema.getFields().stream().sorted(Comparator.comparing(Field::getPos)).map(this::toFieldInfo).collect(Collectors.toList());
        }
    }
    return result;
}
Also used : Field(com.netflix.metacat.connector.s3.model.Field) Schema(com.netflix.metacat.connector.s3.model.Schema) FieldInfo(com.netflix.metacat.common.server.connectors.model.FieldInfo) Location(com.netflix.metacat.connector.s3.model.Location)

Example 2 with Location

use of com.netflix.metacat.connector.s3.model.Location in project metacat by Netflix.

the class S3ConnectorInfoConverter method toAuditInfo.

/**
     * Creates audit info from s3 table info.
     * @param table table info
     * @return audit info
     */
public AuditInfo toAuditInfo(final Table table) {
    final AuditInfo result = AuditInfo.builder().createdDate(table.getCreatedDate()).lastModifiedDate(table.getLastUpdatedDate()).build();
    final Location location = table.getLocation();
    if (location != null) {
        final Info info = location.getInfo();
        if (info != null) {
            result.setCreatedBy(info.getOwner());
            result.setLastModifiedBy(info.getOwner());
        }
    }
    return result;
}
Also used : AuditInfo(com.netflix.metacat.common.server.connectors.model.AuditInfo) AuditInfo(com.netflix.metacat.common.server.connectors.model.AuditInfo) DatabaseInfo(com.netflix.metacat.common.server.connectors.model.DatabaseInfo) FieldInfo(com.netflix.metacat.common.server.connectors.model.FieldInfo) PartitionInfo(com.netflix.metacat.common.server.connectors.model.PartitionInfo) StorageInfo(com.netflix.metacat.common.server.connectors.model.StorageInfo) Info(com.netflix.metacat.connector.s3.model.Info) TableInfo(com.netflix.metacat.common.server.connectors.model.TableInfo) Location(com.netflix.metacat.connector.s3.model.Location)

Example 3 with Location

use of com.netflix.metacat.connector.s3.model.Location in project metacat by Netflix.

the class S3ConnectorInfoConverter method toLocation.

/**
     * Creates location.
     * @param tableInfo table info
     * @return location
     */
public Location toLocation(final TableInfo tableInfo) {
    final Location location = fromStorageInfo(tableInfo.getSerde());
    final Schema schema = new Schema();
    schema.setLocation(location);
    schema.setFields(toFields(tableInfo, schema));
    location.setSchema(schema);
    return location;
}
Also used : Schema(com.netflix.metacat.connector.s3.model.Schema) Location(com.netflix.metacat.connector.s3.model.Location)

Example 4 with Location

use of com.netflix.metacat.connector.s3.model.Location in project metacat by Netflix.

the class S3ConnectorInfoConverter method toStorageInfo.

/**
     * Converts from s3 table info to storage info.
     * @param table table info
     * @return table info
     */
StorageInfo toStorageInfo(final Table table) {
    StorageInfo result = null;
    final Location location = table.getLocation();
    if (location != null) {
        final Map<String, String> infoParameters = Maps.newHashMap();
        result = new StorageInfo();
        result.setUri(location.getUri());
        final Info info = location.getInfo();
        if (info != null) {
            result.setOwner(info.getOwner());
            result.setInputFormat(info.getInputFormat());
            result.setOutputFormat(info.getOutputFormat());
            result.setSerializationLib(info.getSerializationLib());
            if (info.getParameters() != null) {
                infoParameters.putAll(info.getParameters());
            }
        }
        result.setSerdeInfoParameters(infoParameters);
        result.setParameters(Maps.newHashMap());
    }
    return result;
}
Also used : StorageInfo(com.netflix.metacat.common.server.connectors.model.StorageInfo) AuditInfo(com.netflix.metacat.common.server.connectors.model.AuditInfo) DatabaseInfo(com.netflix.metacat.common.server.connectors.model.DatabaseInfo) FieldInfo(com.netflix.metacat.common.server.connectors.model.FieldInfo) PartitionInfo(com.netflix.metacat.common.server.connectors.model.PartitionInfo) StorageInfo(com.netflix.metacat.common.server.connectors.model.StorageInfo) Info(com.netflix.metacat.connector.s3.model.Info) TableInfo(com.netflix.metacat.common.server.connectors.model.TableInfo) Location(com.netflix.metacat.connector.s3.model.Location)

Example 5 with Location

use of com.netflix.metacat.connector.s3.model.Location in project metacat by Netflix.

the class S3ConnectorInfoConverter method getOwner.

/**
     * Gets the owner for the given table.
     * @param table table info
     * @return owner name
     */
public String getOwner(final Table table) {
    String result = null;
    final Location location = table.getLocation();
    if (location != null) {
        final Info info = location.getInfo();
        if (info != null) {
            result = info.getOwner();
        }
    }
    return result;
}
Also used : AuditInfo(com.netflix.metacat.common.server.connectors.model.AuditInfo) DatabaseInfo(com.netflix.metacat.common.server.connectors.model.DatabaseInfo) FieldInfo(com.netflix.metacat.common.server.connectors.model.FieldInfo) PartitionInfo(com.netflix.metacat.common.server.connectors.model.PartitionInfo) StorageInfo(com.netflix.metacat.common.server.connectors.model.StorageInfo) Info(com.netflix.metacat.connector.s3.model.Info) TableInfo(com.netflix.metacat.common.server.connectors.model.TableInfo) Location(com.netflix.metacat.connector.s3.model.Location)

Aggregations

Location (com.netflix.metacat.connector.s3.model.Location)8 FieldInfo (com.netflix.metacat.common.server.connectors.model.FieldInfo)5 TableInfo (com.netflix.metacat.common.server.connectors.model.TableInfo)5 Info (com.netflix.metacat.connector.s3.model.Info)5 AuditInfo (com.netflix.metacat.common.server.connectors.model.AuditInfo)4 DatabaseInfo (com.netflix.metacat.common.server.connectors.model.DatabaseInfo)4 PartitionInfo (com.netflix.metacat.common.server.connectors.model.PartitionInfo)4 StorageInfo (com.netflix.metacat.common.server.connectors.model.StorageInfo)4 Schema (com.netflix.metacat.connector.s3.model.Schema)3 Field (com.netflix.metacat.connector.s3.model.Field)2 Table (com.netflix.metacat.connector.s3.model.Table)2 QualifiedName (com.netflix.metacat.common.QualifiedName)1 TableNotFoundException (com.netflix.metacat.common.server.connectors.exception.TableNotFoundException)1