Skip to content

Commit

Permalink
Rename classes to match coding style
Browse files Browse the repository at this point in the history
Acronyms in names should be camel-cased (IO -> Io).
  • Loading branch information
martint committed Feb 5, 2019
1 parent 12c9b50 commit efc95d6
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 44 deletions.
Expand Up @@ -38,12 +38,12 @@
import io.prestosql.spi.type.TypeSignature;
import io.prestosql.sql.planner.Plan;
import io.prestosql.sql.planner.plan.ExchangeNode;
import io.prestosql.sql.planner.planPrinter.IOPlanPrinter.ColumnConstraint;
import io.prestosql.sql.planner.planPrinter.IOPlanPrinter.FormattedDomain;
import io.prestosql.sql.planner.planPrinter.IOPlanPrinter.FormattedMarker;
import io.prestosql.sql.planner.planPrinter.IOPlanPrinter.FormattedRange;
import io.prestosql.sql.planner.planPrinter.IOPlanPrinter.IOPlan;
import io.prestosql.sql.planner.planPrinter.IOPlanPrinter.IOPlan.TableColumnInfo;
import io.prestosql.sql.planner.planPrinter.IoPlanPrinter.ColumnConstraint;
import io.prestosql.sql.planner.planPrinter.IoPlanPrinter.FormattedDomain;
import io.prestosql.sql.planner.planPrinter.IoPlanPrinter.FormattedMarker;
import io.prestosql.sql.planner.planPrinter.IoPlanPrinter.FormattedRange;
import io.prestosql.sql.planner.planPrinter.IoPlanPrinter.IoPlan;
import io.prestosql.sql.planner.planPrinter.IoPlanPrinter.IoPlan.TableColumnInfo;
import io.prestosql.testing.MaterializedResult;
import io.prestosql.testing.MaterializedRow;
import io.prestosql.tests.AbstractTestIntegrationSmokeTest;
Expand Down Expand Up @@ -180,8 +180,8 @@ public void testIOExplain()

MaterializedResult result = computeActual("EXPLAIN (TYPE IO, FORMAT JSON) INSERT INTO test_orders SELECT custkey, orderkey, processing FROM test_orders where custkey <= 10");
assertEquals(
jsonCodec(IOPlan.class).fromJson((String) getOnlyElement(result.getOnlyColumnAsSet())),
new IOPlan(
jsonCodec(IoPlan.class).fromJson((String) getOnlyElement(result.getOnlyColumnAsSet())),
new IoPlan(
ImmutableSet.of(new TableColumnInfo(
new CatalogSchemaTableName(catalog, "tpch", "test_orders"),
ImmutableSet.of(
Expand Down Expand Up @@ -215,8 +215,8 @@ public void testIOExplain()

result = computeActual("EXPLAIN (TYPE IO, FORMAT JSON) INSERT INTO test_orders SELECT custkey, orderkey + 10 FROM test_orders where custkey <= 10");
assertEquals(
jsonCodec(IOPlan.class).fromJson((String) getOnlyElement(result.getOnlyColumnAsSet())),
new IOPlan(
jsonCodec(IoPlan.class).fromJson((String) getOnlyElement(result.getOnlyColumnAsSet())),
new IoPlan(
ImmutableSet.of(new TableColumnInfo(
new CatalogSchemaTableName(catalog, "tpch", "test_orders"),
ImmutableSet.of(
Expand Down
Expand Up @@ -30,7 +30,7 @@
import io.prestosql.sql.planner.PlanOptimizers;
import io.prestosql.sql.planner.SubPlan;
import io.prestosql.sql.planner.optimizations.PlanOptimizer;
import io.prestosql.sql.planner.planPrinter.IOPlanPrinter;
import io.prestosql.sql.planner.planPrinter.IoPlanPrinter;
import io.prestosql.sql.planner.planPrinter.PlanPrinter;
import io.prestosql.sql.tree.ExplainType.Type;
import io.prestosql.sql.tree.Expression;
Expand All @@ -43,7 +43,7 @@
import java.util.Optional;

import static io.prestosql.spi.StandardErrorCode.NOT_SUPPORTED;
import static io.prestosql.sql.planner.planPrinter.IOPlanPrinter.textIOPlan;
import static io.prestosql.sql.planner.planPrinter.IoPlanPrinter.textIoPlan;
import static java.lang.String.format;
import static java.util.Objects.requireNonNull;

Expand Down Expand Up @@ -121,7 +121,7 @@ public String getPlan(Session session, Statement statement, Type planType, List<
SubPlan subPlan = getDistributedPlan(session, statement, parameters, warningCollector);
return PlanPrinter.textDistributedPlan(subPlan, metadata.getFunctionRegistry(), session, false);
case IO:
return IOPlanPrinter.textIOPlan(getLogicalPlan(session, statement, parameters, warningCollector).getRoot(), metadata, session);
return IoPlanPrinter.textIoPlan(getLogicalPlan(session, statement, parameters, warningCollector).getRoot(), metadata, session);
}
throw new IllegalArgumentException("Unhandled plan type: " + planType);
}
Expand Down Expand Up @@ -161,7 +161,7 @@ public String getJsonPlan(Session session, Statement statement, Type planType, L
switch (planType) {
case IO:
Plan plan = getLogicalPlan(session, statement, parameters, warningCollector);
return textIOPlan(plan.getRoot(), metadata, session);
return textIoPlan(plan.getRoot(), metadata, session);
default:
throw new PrestoException(NOT_SUPPORTED, format("Unsupported explain plan type %s for JSON format", planType));
}
Expand Down
Expand Up @@ -47,7 +47,7 @@
import io.prestosql.sql.planner.plan.TableWriterNode.InsertHandle;
import io.prestosql.sql.planner.plan.TableWriterNode.InsertReference;
import io.prestosql.sql.planner.plan.TableWriterNode.WriterTarget;
import io.prestosql.sql.planner.planPrinter.IOPlanPrinter.IOPlan.IOPlanBuilder;
import io.prestosql.sql.planner.planPrinter.IoPlanPrinter.IoPlan.IoPlanBuilder;

import java.util.HashSet;
import java.util.Map;
Expand All @@ -64,36 +64,36 @@
import static java.lang.String.format;
import static java.util.Objects.requireNonNull;

public class IOPlanPrinter
public class IoPlanPrinter
{
private final Metadata metadata;
private final Session session;

private IOPlanPrinter(Metadata metadata, Session session)
private IoPlanPrinter(Metadata metadata, Session session)
{
this.metadata = requireNonNull(metadata, "metadata is null");
this.session = requireNonNull(session, "session is null");
}

public static String textIOPlan(PlanNode plan, Metadata metadata, Session session)
public static String textIoPlan(PlanNode plan, Metadata metadata, Session session)
{
return new IOPlanPrinter(metadata, session).print(plan);
return new IoPlanPrinter(metadata, session).print(plan);
}

private String print(PlanNode plan)
{
IOPlanBuilder ioPlanBuilder = new IOPlanBuilder();
plan.accept(new IOPlanVisitor(), ioPlanBuilder);
return jsonCodec(IOPlan.class).toJson(ioPlanBuilder.build());
IoPlanBuilder ioPlanBuilder = new IoPlanBuilder();
plan.accept(new IoPlanVisitor(), ioPlanBuilder);
return jsonCodec(IoPlan.class).toJson(ioPlanBuilder.build());
}

public static class IOPlan
public static class IoPlan
{
private final Set<TableColumnInfo> inputTableColumnInfos;
private final Optional<CatalogSchemaTableName> outputTable;

@JsonCreator
public IOPlan(
public IoPlan(
@JsonProperty("inputTableColumnInfos") Set<TableColumnInfo> inputTableColumnInfos,
@JsonProperty("outputTable") Optional<CatalogSchemaTableName> outputTable)
{
Expand Down Expand Up @@ -122,7 +122,7 @@ public boolean equals(Object obj)
if (obj == null || getClass() != obj.getClass()) {
return false;
}
IOPlan o = (IOPlan) obj;
IoPlan o = (IoPlan) obj;
return Objects.equals(inputTableColumnInfos, o.inputTableColumnInfos) &&
Objects.equals(outputTable, o.outputTable);
}
Expand All @@ -142,12 +142,12 @@ public String toString()
.toString();
}

protected static class IOPlanBuilder
protected static class IoPlanBuilder
{
private Set<TableColumnInfo> inputTableColumnInfos;
private Optional<CatalogSchemaTableName> outputTable;

private IOPlanBuilder()
private IoPlanBuilder()
{
this.inputTableColumnInfos = new HashSet<>();
this.outputTable = Optional.empty();
Expand All @@ -163,9 +163,9 @@ private void setOutputTable(CatalogSchemaTableName outputTable)
this.outputTable = Optional.of(outputTable);
}

private IOPlan build()
private IoPlan build()
{
return new IOPlan(inputTableColumnInfos, outputTable);
return new IoPlan(inputTableColumnInfos, outputTable);
}
}

Expand Down Expand Up @@ -461,20 +461,20 @@ public String toString()
}
}

private class IOPlanVisitor
extends PlanVisitor<Void, IOPlanBuilder>
private class IoPlanVisitor
extends PlanVisitor<Void, IoPlanBuilder>
{
@Override
protected Void visitPlan(PlanNode node, IOPlanBuilder context)
protected Void visitPlan(PlanNode node, IoPlanBuilder context)
{
return processChildren(node, context);
}

@Override
public Void visitTableScan(TableScanNode node, IOPlanBuilder context)
public Void visitTableScan(TableScanNode node, IoPlanBuilder context)
{
TableMetadata tableMetadata = metadata.getTableMetadata(session, node.getTable());
context.addInputTableColumnInfo(new IOPlan.TableColumnInfo(
context.addInputTableColumnInfo(new IoPlan.TableColumnInfo(
new CatalogSchemaTableName(
tableMetadata.getConnectorId().getCatalogName(),
tableMetadata.getTable().getSchemaName(),
Expand All @@ -484,7 +484,7 @@ public Void visitTableScan(TableScanNode node, IOPlanBuilder context)
}

@Override
public Void visitTableFinish(TableFinishNode node, IOPlanBuilder context)
public Void visitTableFinish(TableFinishNode node, IoPlanBuilder context)
{
WriterTarget writerTarget = node.getTarget();
if (writerTarget instanceof CreateHandle) {
Expand Down Expand Up @@ -576,7 +576,7 @@ private String getVarcharValue(Type type, Object value)
throw new PrestoException(NOT_SUPPORTED, format("Unsupported data type in EXPLAIN (TYPE IO): %s", type.getDisplayName()));
}

private Void processChildren(PlanNode node, IOPlanBuilder context)
private Void processChildren(PlanNode node, IoPlanBuilder context)
{
for (PlanNode child : node.getSources()) {
child.accept(this, context);
Expand Down
Expand Up @@ -20,12 +20,12 @@
import io.prestosql.metadata.SessionPropertyManager;
import io.prestosql.plugin.tpch.TpchConnectorFactory;
import io.prestosql.spi.connector.CatalogSchemaTableName;
import io.prestosql.sql.planner.planPrinter.IOPlanPrinter.ColumnConstraint;
import io.prestosql.sql.planner.planPrinter.IOPlanPrinter.FormattedDomain;
import io.prestosql.sql.planner.planPrinter.IOPlanPrinter.FormattedMarker;
import io.prestosql.sql.planner.planPrinter.IOPlanPrinter.FormattedRange;
import io.prestosql.sql.planner.planPrinter.IOPlanPrinter.IOPlan;
import io.prestosql.sql.planner.planPrinter.IOPlanPrinter.IOPlan.TableColumnInfo;
import io.prestosql.sql.planner.planPrinter.IoPlanPrinter.ColumnConstraint;
import io.prestosql.sql.planner.planPrinter.IoPlanPrinter.FormattedDomain;
import io.prestosql.sql.planner.planPrinter.IoPlanPrinter.FormattedMarker;
import io.prestosql.sql.planner.planPrinter.IoPlanPrinter.FormattedRange;
import io.prestosql.sql.planner.planPrinter.IoPlanPrinter.IoPlan;
import io.prestosql.sql.planner.planPrinter.IoPlanPrinter.IoPlan.TableColumnInfo;
import io.prestosql.testing.LocalQueryRunner;
import io.prestosql.testing.MaterializedResult;
import org.testng.annotations.Test;
Expand Down Expand Up @@ -139,7 +139,7 @@ public void testIOExplain()
new FormattedMarker(Optional.of("P"), EXACTLY),
new FormattedMarker(Optional.of("P"), EXACTLY)))))));
assertEquals(
jsonCodec(IOPlan.class).fromJson((String) getOnlyElement(result.getOnlyColumnAsSet())),
new IOPlan(ImmutableSet.of(input), Optional.empty()));
jsonCodec(IoPlan.class).fromJson((String) getOnlyElement(result.getOnlyColumnAsSet())),
new IoPlan(ImmutableSet.of(input), Optional.empty()));
}
}

0 comments on commit efc95d6

Please sign in to comment.