Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2950,7 +2950,7 @@ public static boolean shouldInferInequalityPredicates(Session session)
return session.getSystemProperty(INFER_INEQUALITY_PREDICATES, Boolean.class);
}

public static boolean useHBOForScaledWriters(Session session)
public static boolean useHistoryBasedScaledWriters(Session session)
{
return session.getSystemProperty(ENABLE_HISTORY_BASED_SCALED_WRITER, Boolean.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@

import java.util.Optional;

import static com.facebook.presto.SystemSessionProperties.useHBOForScaledWriters;
import static com.facebook.presto.SystemSessionProperties.useHistoryBasedScaledWriters;
import static com.facebook.presto.sql.planner.plan.Patterns.tableWriterNode;
import static com.google.common.base.Preconditions.checkState;

public class ScaledWriterRule
implements Rule<TableWriterNode>
{
private String statsSource;

@Override
public Pattern<TableWriterNode> getPattern()
{
Expand All @@ -37,13 +39,26 @@ public Pattern<TableWriterNode> getPattern()
@Override
public boolean isEnabled(Session session)
{
return useHBOForScaledWriters(session);
return useHistoryBasedScaledWriters(session);
}

@Override
public boolean isCostBased(Session session)
{
return true;
}

@Override
public String getStatsSource()
{
return statsSource;
}

@Override
public Result apply(TableWriterNode node, Captures captures, Context context)
{
double taskNumber = context.getStatsProvider().getStats(node).getTableWriterNodeStatsEstimate().getTaskCountIfScaledWriter();
statsSource = context.getStatsProvider().getStats(node).getSourceInfo().getSourceInfoName();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this construct is used several times I wonder if we should introduce a utility function in PlannerUtils:getStatsSource(Context context, PlanNode node)

if (Double.isNaN(taskNumber)) {
return Result.empty();
}
Expand Down