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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations