Skip to content

Commit

Permalink
Remove usage of ConnectorTableLayoutHandle from SplitManager
Browse files Browse the repository at this point in the history
  • Loading branch information
Praveen2112 committed Jan 13, 2022
1 parent 99d9027 commit d058c8a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 50 deletions.
37 changes: 8 additions & 29 deletions core/trino-main/src/main/java/io/trino/split/SplitManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,16 @@
import io.trino.Session;
import io.trino.connector.CatalogName;
import io.trino.execution.QueryManagerConfig;
import io.trino.metadata.Metadata;
import io.trino.metadata.TableHandle;
import io.trino.spi.connector.ConnectorSession;
import io.trino.spi.connector.ConnectorSplitManager;
import io.trino.spi.connector.ConnectorSplitManager.SplitSchedulingStrategy;
import io.trino.spi.connector.ConnectorSplitSource;
import io.trino.spi.connector.ConnectorTableLayoutHandle;
import io.trino.spi.connector.Constraint;
import io.trino.spi.connector.DynamicFilter;

import javax.inject.Inject;

import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

Expand All @@ -42,16 +39,10 @@ public class SplitManager
private final ConcurrentMap<CatalogName, ConnectorSplitManager> splitManagers = new ConcurrentHashMap<>();
private final int minScheduleSplitBatchSize;

// NOTE: This only used for filling in the table layout if none is present by the time we
// get splits. DO NOT USE IT FOR ANY OTHER PURPOSE, as it will be removed once table layouts
// are gone entirely
private final Metadata metadata;

@Inject
public SplitManager(QueryManagerConfig config, Metadata metadata)
public SplitManager(QueryManagerConfig config)
{
this.minScheduleSplitBatchSize = config.getMinScheduleSplitBatchSize();
this.metadata = metadata;
}

public void addConnectorSplitManager(CatalogName catalogName, ConnectorSplitManager connectorSplitManager)
Expand Down Expand Up @@ -81,25 +72,13 @@ public SplitSource getSplits(

ConnectorSession connectorSession = session.toConnectorSession(catalogName);

ConnectorSplitSource source;
if (metadata.usesLegacyTableLayouts(session, table)) {
ConnectorTableLayoutHandle layout = table.getLayout()
.orElseGet(() -> metadata.getLayout(session, table, Constraint.alwaysTrue(), Optional.empty())
.get()
.getNewTableHandle()
.getLayout().get());

source = splitManager.getSplits(table.getTransaction(), connectorSession, layout, splitSchedulingStrategy);
}
else {
source = splitManager.getSplits(
table.getTransaction(),
connectorSession,
table.getConnectorHandle(),
splitSchedulingStrategy,
dynamicFilter,
constraint);
}
ConnectorSplitSource source = splitManager.getSplits(
table.getTransaction(),
connectorSession,
table.getConnectorHandle(),
splitSchedulingStrategy,
dynamicFilter,
constraint);

SplitSource splitSource = new ConnectorAwareSplitSource(catalogName, source);
if (minScheduleSplitBatchSize > 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ private LocalQueryRunner(
blockEncodingSerde,
nodeManager.getCurrentNode().getNodeVersion());
this.plannerContext = new PlannerContext(metadata, typeOperators, blockEncodingSerde, typeManager);
this.splitManager = new SplitManager(new QueryManagerConfig(), metadata);
this.splitManager = new SplitManager(new QueryManagerConfig());
this.planFragmenter = new PlanFragmenter(metadata, this.nodePartitioningManager, new QueryManagerConfig());
this.joinCompiler = new JoinCompiler(typeOperators);
PageIndexerFactory pageIndexerFactory = new GroupByHashPageIndexerFactory(joinCompiler, blockTypeOperators);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,6 @@ default List<GrantInfo> listTablePrivileges(ConnectorSession session, SchemaTabl
* <ul>
* <li>{@link #getTableProperties(ConnectorSession session, ConnectorTableHandle table)}</li>
* <li>{@link #getInfo(ConnectorTableHandle table)} </li>
* <li>{@link ConnectorSplitManager#getSplits(ConnectorTransactionHandle, ConnectorSession, ConnectorTableHandle, ConnectorSplitManager.SplitSchedulingStrategy)}</li>
* </ul>
*/
default boolean usesLegacyTableLayouts()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@

public interface ConnectorSplitManager
{
@Deprecated
default ConnectorSplitSource getSplits(
ConnectorTransactionHandle transactionHandle,
ConnectorSession session,
ConnectorTableLayoutHandle layout,
SplitSchedulingStrategy splitSchedulingStrategy)
{
throw new UnsupportedOperationException();
}

@Deprecated
default ConnectorSplitSource getSplits(
ConnectorTransactionHandle transaction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import io.trino.spi.connector.ConnectorSplitManager;
import io.trino.spi.connector.ConnectorSplitSource;
import io.trino.spi.connector.ConnectorTableHandle;
import io.trino.spi.connector.ConnectorTableLayoutHandle;
import io.trino.spi.connector.ConnectorTransactionHandle;
import io.trino.spi.connector.Constraint;
import io.trino.spi.connector.DynamicFilter;
Expand All @@ -40,14 +39,6 @@ public ClassLoaderSafeConnectorSplitManager(@ForClassLoaderSafe ConnectorSplitMa
this.classLoader = requireNonNull(classLoader, "classLoader is null");
}

@Override
public ConnectorSplitSource getSplits(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorTableLayoutHandle layout, SplitSchedulingStrategy splitSchedulingStrategy)
{
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
return delegate.getSplits(transactionHandle, session, layout, splitSchedulingStrategy);
}
}

@Override
public ConnectorSplitSource getSplits(ConnectorTransactionHandle transaction, ConnectorSession session, ConnectorTableHandle table, SplitSchedulingStrategy splitSchedulingStrategy, DynamicFilter dynamicFilter)
{
Expand Down

0 comments on commit d058c8a

Please sign in to comment.