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 @@ -61,18 +61,9 @@
public class CassandraClientModule
extends AbstractConfigurationAwareModule
{
private final TypeManager typeManager;

public CassandraClientModule(TypeManager typeManager)
{
this.typeManager = requireNonNull(typeManager, "typeManager is null");
}

@Override
public void setup(Binder binder)
{
binder.bind(TypeManager.class).toInstance(typeManager);

verifyConnectorUnsafeAllowed(binder, "cassandra");

binder.bind(CassandraConnector.class).in(Scopes.SINGLETON);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public Connector create(String catalogName, Map<String, String> config, Connecto
new ConnectorContextModule(catalogName, context),
new MBeanModule(),
new JsonModule(),
new CassandraClientModule(context.getTypeManager()),
new CassandraClientModule(),
new MBeanServerModule());

Injector injector = app.doNotInitializeLogging()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import com.google.inject.Injector;
import io.airlift.bootstrap.Bootstrap;
import io.trino.plugin.base.ConnectorContextModule;
import io.trino.spi.connector.Connector;
import io.trino.spi.connector.ConnectorContext;
import io.trino.spi.connector.ConnectorFactory;
Expand Down Expand Up @@ -48,7 +49,10 @@ public Connector create(String catalogName, Map<String, String> requiredConfig,
requireNonNull(context, "context is null");
checkStrictSpiVersionMatch(context, this);

Bootstrap app = new Bootstrap("io.trino.bootstrap.catalog." + catalogName, new FakerModule(context.getTypeManager()));
Bootstrap app = new Bootstrap(
"io.trino.bootstrap.catalog." + catalogName,
new ConnectorContextModule(catalogName, context),
Copy link
Contributor

Choose a reason for hiding this comment

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

The ConnectorContextModule binds more than just TypeManager :) , but we just want to use ConnectorContextModule right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we want to use it whenever at least one object from ConnectorContext is passes to the connector.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks

new FakerModule());

Injector injector = app
.doNotInitializeLogging()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,17 @@
package io.trino.plugin.faker;

import com.google.inject.Binder;
import com.google.inject.Inject;
import com.google.inject.Module;
import com.google.inject.Scopes;
import io.trino.spi.type.TypeManager;

import static io.airlift.configuration.ConfigBinder.configBinder;
import static java.util.Objects.requireNonNull;

public class FakerModule
implements Module
{
private final TypeManager typeManager;

@Inject
public FakerModule(TypeManager typeManager)
{
this.typeManager = requireNonNull(typeManager, "typeManager is null");
}

@Override
public void configure(Binder binder)
{
binder.bind(TypeManager.class).toInstance(typeManager);

binder.bind(FakerConnector.class).in(Scopes.SINGLETON);
binder.bind(FakerMetadata.class).in(Scopes.SINGLETON);
binder.bind(FakerSplitManager.class).in(Scopes.SINGLETON);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.google.inject.Injector;
import io.airlift.bootstrap.Bootstrap;
import io.airlift.json.JsonModule;
import io.trino.plugin.base.ConnectorContextModule;
import io.trino.spi.connector.Connector;
import io.trino.spi.connector.ConnectorContext;
import io.trino.spi.connector.ConnectorFactory;
Expand Down Expand Up @@ -44,7 +45,8 @@ public Connector create(String catalogName, Map<String, String> requiredConfig,
Bootstrap app = new Bootstrap(
"io.trino.bootstrap.catalog." + catalogName,
new JsonModule(),
new MemoryModule(context.getTypeManager(), context.getCurrentNode(), context.getNodeManager()));
new ConnectorContextModule(catalogName, context),
new MemoryModule());

Injector injector = app
.doNotInitializeLogging()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,15 @@
import com.google.inject.Binder;
import com.google.inject.Module;
import com.google.inject.Scopes;
import io.trino.spi.Node;
import io.trino.spi.NodeManager;
import io.trino.spi.type.TypeManager;

import static io.airlift.configuration.ConfigBinder.configBinder;
import static java.util.Objects.requireNonNull;

public class MemoryModule
implements Module
{
private final TypeManager typeManager;
private final Node currentNode;
private final NodeManager nodeManager;

public MemoryModule(TypeManager typeManager, Node currentNode, NodeManager nodeManager)
{
this.typeManager = requireNonNull(typeManager, "typeManager is null");
this.currentNode = requireNonNull(currentNode, "currentNode is null");
this.nodeManager = requireNonNull(nodeManager, "nodeManager is null");
}

@Override
public void configure(Binder binder)
{
binder.bind(TypeManager.class).toInstance(typeManager);
binder.bind(Node.class).toInstance(currentNode);
binder.bind(NodeManager.class).toInstance(nodeManager);

binder.bind(MemoryConnector.class).in(Scopes.SINGLETON);
binder.bind(MemoryMetadata.class).in(Scopes.SINGLETON);
binder.bind(MemorySplitManager.class).in(Scopes.SINGLETON);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import com.google.inject.Injector;
import io.airlift.bootstrap.Bootstrap;
import io.trino.plugin.base.ConnectorContextModule;
import io.trino.spi.connector.Connector;
import io.trino.spi.connector.ConnectorContext;
import io.trino.spi.connector.ConnectorFactory;
Expand All @@ -37,7 +38,10 @@ public Connector create(String catalogName, Map<String, String> config, Connecto
{
checkStrictSpiVersionMatch(context, this);

Bootstrap app = new Bootstrap("io.trino.bootstrap.catalog." + catalogName, new TpcdsModule(context.getNodeManager()));
Bootstrap app = new Bootstrap(
"io.trino.bootstrap.catalog." + catalogName,
new ConnectorContextModule(catalogName, context),
new TpcdsModule());

Injector injector = app
.doNotInitializeLogging()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,16 @@
import com.google.inject.Binder;
import com.google.inject.Module;
import com.google.inject.Scopes;
import io.trino.spi.NodeManager;

import static io.airlift.configuration.ConfigBinder.configBinder;
import static java.util.Objects.requireNonNull;

public class TpcdsModule
implements Module
{
private final NodeManager nodeManager;

public TpcdsModule(NodeManager nodeManager)
{
this.nodeManager = requireNonNull(nodeManager, "nodeManager is null");
}

@Override
public void configure(Binder binder)
{
configBinder(binder).bindConfig(TpcdsConfig.class);
binder.bind(NodeManager.class).toInstance(nodeManager);
binder.bind(TpcdsSessionProperties.class).in(Scopes.SINGLETON);
binder.bind(TpcdsMetadata.class).in(Scopes.SINGLETON);
binder.bind(TpcdsSplitManager.class).in(Scopes.SINGLETON);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public Connector create(String catalogName, Map<String, String> properties, Conn
new ConnectorContextModule(catalogName, context),
new MBeanModule(),
new JsonModule(),
new TpchModule(context.getNodeManager(), defaultSplitsPerNode, predicatePushdownEnabled),
new TpchModule(defaultSplitsPerNode, predicatePushdownEnabled),
new MBeanServerModule());

Injector injector = app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,29 @@
import com.google.inject.Binder;
import com.google.inject.Scopes;
import io.airlift.configuration.AbstractConfigurationAwareModule;
import io.trino.spi.NodeManager;
import io.trino.spi.connector.Connector;
import io.trino.spi.connector.ConnectorMetadata;
import io.trino.spi.connector.ConnectorNodePartitioningProvider;
import io.trino.spi.connector.ConnectorPageSourceProvider;
import io.trino.spi.connector.ConnectorSplitManager;

import static io.airlift.configuration.ConfigBinder.configBinder;
import static java.util.Objects.requireNonNull;

public class TpchModule
extends AbstractConfigurationAwareModule
{
private final NodeManager nodeManager;
private final int defaultSplitsPerNode;
private final boolean predicatePushdownEnabled;

public TpchModule(NodeManager nodeManager, int defaultSplitsPerNode, boolean predicatePushdownEnabled)
public TpchModule(int defaultSplitsPerNode, boolean predicatePushdownEnabled)
{
this.nodeManager = requireNonNull(nodeManager, "nodeManager is null");
this.defaultSplitsPerNode = defaultSplitsPerNode;
this.predicatePushdownEnabled = predicatePushdownEnabled;
}

@Override
protected void setup(Binder binder)
{
binder.bind(NodeManager.class).toInstance(nodeManager);
binder.bind(Connector.class).to(TpchConnector.class).in(Scopes.SINGLETON);
binder.bind(ConnectorMetadata.class).to(TpchMetadata.class).in(Scopes.SINGLETON);
binder.bind(ConnectorPageSourceProvider.class).to(TpchPageSourceProvider.class).in(Scopes.SINGLETON);
Expand Down
Loading