use of com.facebook.presto.iceberg.util.PageListBuilder in project presto by prestodb.
the class FilesTable method buildPages.
private static List<Page> buildPages(ConnectorTableMetadata tableMetadata, ConnectorSession session, Table icebergTable, Optional<Long> snapshotId) {
PageListBuilder pagesBuilder = forTable(tableMetadata);
TableScan tableScan = getTableScan(TupleDomain.all(), snapshotId, icebergTable).includeColumnStats();
Map<Integer, Type> idToTypeMap = getIdToTypeMap(icebergTable.schema());
tableScan.planFiles().forEach(fileScanTask -> {
DataFile dataFile = fileScanTask.file();
pagesBuilder.beginRow();
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.lowerBounds(), pagesBuilder)) {
pagesBuilder.appendIntegerVarcharMap(dataFile.lowerBounds().entrySet().stream().collect(toImmutableMap(Map.Entry<Integer, ByteBuffer>::getKey, entry -> Transforms.identity(idToTypeMap.get(entry.getKey())).toHumanString(Conversions.fromByteBuffer(idToTypeMap.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(idToTypeMap.get(entry.getKey())).toHumanString(Conversions.fromByteBuffer(idToTypeMap.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());
}
pagesBuilder.endRow();
});
return pagesBuilder.build();
}
use of com.facebook.presto.iceberg.util.PageListBuilder in project presto by prestodb.
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 PrestoException(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 com.facebook.presto.iceberg.util.PageListBuilder in project presto by prestodb.
the class SnapshotsTable method buildPages.
private static List<Page> buildPages(ConnectorTableMetadata tableMetadata, ConnectorSession session, Table icebergTable) {
PageListBuilder pagesBuilder = PageListBuilder.forTable(tableMetadata);
icebergTable.snapshots().forEach(snapshot -> {
pagesBuilder.beginRow();
pagesBuilder.appendTimestampTzMillis(snapshot.timestampMillis(), session.getSqlFunctionProperties().getTimeZoneKey());
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();
}
Aggregations