use of io.trino.plugin.iceberg.util.PageListBuilder in project trino by trinodb.
the class ManifestsTable method buildPages.
private static List<Page> buildPages(ConnectorTableMetadata tableMetadata, Table icebergTable, long snapshotId) {
PageListBuilder pagesBuilder = PageListBuilder.forTable(tableMetadata);
Snapshot snapshot = icebergTable.snapshot(snapshotId);
if (snapshot == null) {
throw new TrinoException(ICEBERG_INVALID_METADATA, format("Snapshot ID [%s] does not exist for table: %s", snapshotId, icebergTable));
}
Map<Integer, PartitionSpec> partitionSpecsById = icebergTable.specs();
snapshot.allManifests().forEach(file -> {
pagesBuilder.beginRow();
pagesBuilder.appendVarchar(file.path());
pagesBuilder.appendBigint(file.length());
pagesBuilder.appendInteger(file.partitionSpecId());
pagesBuilder.appendBigint(file.snapshotId());
pagesBuilder.appendInteger(file.addedFilesCount());
pagesBuilder.appendInteger(file.existingFilesCount());
pagesBuilder.appendInteger(file.deletedFilesCount());
writePartitionSummaries(pagesBuilder.nextColumn(), file.partitions(), partitionSpecsById.get(file.partitionSpecId()));
pagesBuilder.endRow();
});
return pagesBuilder.build();
}
use of io.trino.plugin.iceberg.util.PageListBuilder in project trino by trinodb.
the class PropertiesTable method buildPages.
private static List<Page> buildPages(ConnectorTableMetadata tableMetadata, Table icebergTable) {
PageListBuilder pagesBuilder = PageListBuilder.forTable(tableMetadata);
icebergTable.properties().entrySet().forEach(prop -> {
pagesBuilder.beginRow();
pagesBuilder.appendVarchar(prop.getKey());
pagesBuilder.appendVarchar(prop.getValue());
pagesBuilder.endRow();
});
return pagesBuilder.build();
}
use of io.trino.plugin.iceberg.util.PageListBuilder in project trino by trinodb.
the class SnapshotsTable method buildPages.
private static List<Page> buildPages(ConnectorTableMetadata tableMetadata, ConnectorSession session, Table icebergTable) {
PageListBuilder pagesBuilder = PageListBuilder.forTable(tableMetadata);
TimeZoneKey timeZoneKey = session.getTimeZoneKey();
icebergTable.snapshots().forEach(snapshot -> {
pagesBuilder.beginRow();
pagesBuilder.appendTimestampTzMillis(snapshot.timestampMillis(), timeZoneKey);
pagesBuilder.appendBigint(snapshot.snapshotId());
if (checkNonNull(snapshot.parentId(), pagesBuilder)) {
pagesBuilder.appendBigint(snapshot.parentId());
}
if (checkNonNull(snapshot.operation(), pagesBuilder)) {
pagesBuilder.appendVarchar(snapshot.operation());
}
if (checkNonNull(snapshot.manifestListLocation(), pagesBuilder)) {
pagesBuilder.appendVarchar(snapshot.manifestListLocation());
}
if (checkNonNull(snapshot.summary(), pagesBuilder)) {
pagesBuilder.appendVarcharVarcharMap(snapshot.summary());
}
pagesBuilder.endRow();
});
return pagesBuilder.build();
}
use of io.trino.plugin.iceberg.util.PageListBuilder in project trino by trinodb.
the class FilesTable method buildPages.
private static List<Page> buildPages(ConnectorTableMetadata tableMetadata, Table icebergTable, long snapshotId) {
PageListBuilder pagesBuilder = PageListBuilder.forTable(tableMetadata);
Map<Integer, Type> idToTypeMapping = getIcebergIdToTypeMapping(icebergTable.schema());
TableScan tableScan = icebergTable.newScan().useSnapshot(snapshotId).includeColumnStats();
tableScan.planFiles().forEach(fileScanTask -> {
DataFile dataFile = fileScanTask.file();
pagesBuilder.beginRow();
pagesBuilder.appendInteger(dataFile.content().id());
pagesBuilder.appendVarchar(dataFile.path().toString());
pagesBuilder.appendVarchar(dataFile.format().name());
pagesBuilder.appendBigint(dataFile.recordCount());
pagesBuilder.appendBigint(dataFile.fileSizeInBytes());
if (checkNonNull(dataFile.columnSizes(), pagesBuilder)) {
pagesBuilder.appendIntegerBigintMap(dataFile.columnSizes());
}
if (checkNonNull(dataFile.valueCounts(), pagesBuilder)) {
pagesBuilder.appendIntegerBigintMap(dataFile.valueCounts());
}
if (checkNonNull(dataFile.nullValueCounts(), pagesBuilder)) {
pagesBuilder.appendIntegerBigintMap(dataFile.nullValueCounts());
}
if (checkNonNull(dataFile.nanValueCounts(), pagesBuilder)) {
pagesBuilder.appendIntegerBigintMap(dataFile.nanValueCounts());
}
if (checkNonNull(dataFile.lowerBounds(), pagesBuilder)) {
pagesBuilder.appendIntegerVarcharMap(dataFile.lowerBounds().entrySet().stream().collect(toImmutableMap(Map.Entry<Integer, ByteBuffer>::getKey, entry -> Transforms.identity(idToTypeMapping.get(entry.getKey())).toHumanString(Conversions.fromByteBuffer(idToTypeMapping.get(entry.getKey()), entry.getValue())))));
}
if (checkNonNull(dataFile.upperBounds(), pagesBuilder)) {
pagesBuilder.appendIntegerVarcharMap(dataFile.upperBounds().entrySet().stream().collect(toImmutableMap(Map.Entry<Integer, ByteBuffer>::getKey, entry -> Transforms.identity(idToTypeMapping.get(entry.getKey())).toHumanString(Conversions.fromByteBuffer(idToTypeMapping.get(entry.getKey()), entry.getValue())))));
}
if (checkNonNull(dataFile.keyMetadata(), pagesBuilder)) {
pagesBuilder.appendVarbinary(Slices.wrappedBuffer(dataFile.keyMetadata()));
}
if (checkNonNull(dataFile.splitOffsets(), pagesBuilder)) {
pagesBuilder.appendBigintArray(dataFile.splitOffsets());
}
if (checkNonNull(dataFile.equalityFieldIds(), pagesBuilder)) {
pagesBuilder.appendIntegerArray(dataFile.equalityFieldIds());
}
pagesBuilder.endRow();
});
return pagesBuilder.build();
}
Aggregations