use of io.trino.spi.connector.BasicRelationStatistics in project trino by trinodb.
the class PushJoinIntoTableScan method getJoinStatistics.
private JoinStatistics getJoinStatistics(JoinNode join, TableScanNode left, TableScanNode right, Context context) {
return new JoinStatistics() {
@Override
public Optional<BasicRelationStatistics> getLeftStatistics() {
return getBasicRelationStats(left, left.getOutputSymbols(), context);
}
@Override
public Optional<BasicRelationStatistics> getRightStatistics() {
return getBasicRelationStats(right, right.getOutputSymbols(), context);
}
@Override
public Optional<BasicRelationStatistics> getJoinStatistics() {
return getBasicRelationStats(join, join.getOutputSymbols(), context);
}
private Optional<BasicRelationStatistics> getBasicRelationStats(PlanNode node, List<Symbol> outputSymbols, Context context) {
PlanNodeStatsEstimate stats = context.getStatsProvider().getStats(node);
TypeProvider types = context.getSymbolAllocator().getTypes();
double outputRowCount = stats.getOutputRowCount();
double outputSize = stats.getOutputSizeInBytes(outputSymbols, types);
if (isNaN(outputRowCount) || isNaN(outputSize)) {
return Optional.empty();
}
return Optional.of(new BasicRelationStatistics((long) outputRowCount, (long) outputSize));
}
};
}
Aggregations