use of com.facebook.presto.iceberg.IcebergOrcColumn.ROOT_COLUMN_ID in project presto by prestodb.
the class IcebergPageSourceProvider method getFileOrcColumns.
private static List<IcebergOrcColumn> getFileOrcColumns(OrcReader reader) {
List<OrcType> orcTypes = reader.getFooter().getTypes();
OrcType rootOrcType = orcTypes.get(ROOT_COLUMN_ID);
List<IcebergOrcColumn> columnAttributes = ImmutableList.of();
if (rootOrcType.getOrcTypeKind() == OrcType.OrcTypeKind.STRUCT) {
columnAttributes = IntStream.range(0, rootOrcType.getFieldCount()).mapToObj(fieldId -> new IcebergOrcColumn(fieldId, rootOrcType.getFieldTypeIndex(fieldId), // so we use 'Optional.empty()' temporarily.
Optional.empty(), rootOrcType.getFieldName(fieldId), REGULAR, orcTypes.get(rootOrcType.getFieldTypeIndex(fieldId)).getOrcTypeKind(), orcTypes.get(rootOrcType.getFieldTypeIndex(fieldId)).getAttributes())).collect(toImmutableList());
} else if (rootOrcType.getOrcTypeKind() == OrcType.OrcTypeKind.LIST) {
columnAttributes = ImmutableList.of(new IcebergOrcColumn(0, rootOrcType.getFieldTypeIndex(0), Optional.empty(), "item", REGULAR, orcTypes.get(rootOrcType.getFieldTypeIndex(0)).getOrcTypeKind(), orcTypes.get(rootOrcType.getFieldTypeIndex(0)).getAttributes()));
} else if (rootOrcType.getOrcTypeKind() == OrcType.OrcTypeKind.MAP) {
columnAttributes = ImmutableList.of(new IcebergOrcColumn(0, rootOrcType.getFieldTypeIndex(0), Optional.empty(), "key", REGULAR, orcTypes.get(rootOrcType.getFieldTypeIndex(0)).getOrcTypeKind(), orcTypes.get(rootOrcType.getFieldTypeIndex(0)).getAttributes()), new IcebergOrcColumn(1, rootOrcType.getFieldTypeIndex(1), Optional.empty(), "value", REGULAR, orcTypes.get(rootOrcType.getFieldTypeIndex(1)).getOrcTypeKind(), orcTypes.get(rootOrcType.getFieldTypeIndex(1)).getAttributes()));
} else if (rootOrcType.getOrcTypeKind() == OrcType.OrcTypeKind.UNION) {
columnAttributes = IntStream.range(0, rootOrcType.getFieldCount()).mapToObj(fieldId -> new IcebergOrcColumn(fieldId, rootOrcType.getFieldTypeIndex(fieldId), Optional.empty(), "field" + fieldId, REGULAR, orcTypes.get(rootOrcType.getFieldTypeIndex(fieldId)).getOrcTypeKind(), orcTypes.get(rootOrcType.getFieldTypeIndex(fieldId)).getAttributes())).collect(toImmutableList());
}
return columnAttributes;
}
Aggregations