Skip to content

Commit

Permalink
Remove unused catalog name from system connector
Browse files Browse the repository at this point in the history
  • Loading branch information
electrum committed May 10, 2019
1 parent 2446e6b commit f7d52ac
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ private synchronized void addCatalogConnector(CatalogName catalogName, Connector
}

MaterializedConnector systemConnector = new MaterializedConnector(systemId, new SystemConnector(
systemId,
nodeManager,
systemTablesProvider,
transactionId -> transactionManager.getConnectorTransaction(transactionId, catalogName)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package io.prestosql.connector.system;

import io.prestosql.connector.CatalogName;
import io.prestosql.metadata.InternalNodeManager;
import io.prestosql.spi.connector.ConnectorMetadata;
import io.prestosql.spi.connector.ConnectorPageSourceProvider;
Expand All @@ -32,34 +31,29 @@
public class SystemConnector
implements InternalConnector
{
private final CatalogName catalogName;
private final ConnectorMetadata metadata;
private final ConnectorSplitManager splitManager;
private final ConnectorPageSourceProvider pageSourceProvider;
private final Function<TransactionId, ConnectorTransactionHandle> transactionHandleFunction;

public SystemConnector(
CatalogName catalogName,
InternalNodeManager nodeManager,
Set<SystemTable> tables,
Function<TransactionId, ConnectorTransactionHandle> transactionHandleFunction)
{
this(catalogName, nodeManager, new StaticSystemTablesProvider(tables), transactionHandleFunction);
this(nodeManager, new StaticSystemTablesProvider(tables), transactionHandleFunction);
}

public SystemConnector(
CatalogName catalogName,
InternalNodeManager nodeManager,
SystemTablesProvider tables,
Function<TransactionId, ConnectorTransactionHandle> transactionHandleFunction)
{
requireNonNull(catalogName, "catalogName is null");
requireNonNull(nodeManager, "nodeManager is null");
requireNonNull(tables, "tables is null");
requireNonNull(transactionHandleFunction, "transactionHandleFunction is null");

this.catalogName = catalogName;
this.metadata = new SystemTablesMetadata(catalogName, tables);
this.metadata = new SystemTablesMetadata(tables);
this.splitManager = new SystemSplitManager(nodeManager, tables);
this.pageSourceProvider = new SystemPageSourceProvider(tables);
this.transactionHandleFunction = transactionHandleFunction;
Expand All @@ -68,7 +62,7 @@ public SystemConnector(
@Override
public ConnectorTransactionHandle beginTransaction(TransactionId transactionId, IsolationLevel isolationLevel, boolean readOnly)
{
return new SystemTransactionHandle(catalogName, transactionId, transactionHandleFunction);
return new SystemTransactionHandle(transactionId, transactionHandleFunction);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import io.prestosql.connector.CatalogName;
import io.prestosql.spi.PrestoException;
import io.prestosql.spi.connector.ColumnHandle;
import io.prestosql.spi.connector.ColumnMetadata;
Expand Down Expand Up @@ -48,13 +47,10 @@
public class SystemTablesMetadata
implements ConnectorMetadata
{
private final CatalogName catalogName;

private final SystemTablesProvider tables;

public SystemTablesMetadata(CatalogName catalogName, SystemTablesProvider tables)
public SystemTablesMetadata(SystemTablesProvider tables)
{
this.catalogName = requireNonNull(catalogName, "connectorId");
this.tables = requireNonNull(tables, "tables is null");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import io.prestosql.connector.CatalogName;
import io.prestosql.spi.connector.ConnectorTransactionHandle;
import io.prestosql.transaction.TransactionId;

import java.util.Objects;
import java.util.function.Function;

import static com.google.common.base.MoreObjects.toStringHelper;
Expand All @@ -30,39 +28,28 @@
public class SystemTransactionHandle
implements ConnectorTransactionHandle
{
private final CatalogName catalogName;
private final TransactionId transactionId;
private final Supplier<ConnectorTransactionHandle> connectorTransactionHandle;

SystemTransactionHandle(
CatalogName catalogName,
TransactionId transactionId,
Function<TransactionId, ConnectorTransactionHandle> transactionHandleFunction)
{
this.catalogName = requireNonNull(catalogName, "catalogName is null");
this.transactionId = requireNonNull(transactionId, "transactionId is null");
requireNonNull(transactionHandleFunction, "transactionHandleFunction is null");
this.connectorTransactionHandle = Suppliers.memoize(() -> transactionHandleFunction.apply(transactionId));
}

@JsonCreator
public SystemTransactionHandle(
@JsonProperty("catalogName") CatalogName catalogName,
@JsonProperty("transactionId") TransactionId transactionId,
@JsonProperty("connectorTransactionHandle") ConnectorTransactionHandle connectorTransactionHandle)
{
this.catalogName = requireNonNull(catalogName, "catalogName is null");
this.transactionId = requireNonNull(transactionId, "transactionId is null");
requireNonNull(connectorTransactionHandle, "connectorTransactionHandle is null");
this.connectorTransactionHandle = () -> connectorTransactionHandle;
}

@JsonProperty
public CatalogName getCatalogName()
{
return catalogName;
}

@JsonProperty
public TransactionId getTransactionId()
{
Expand All @@ -78,7 +65,7 @@ public ConnectorTransactionHandle getConnectorTransactionHandle()
@Override
public int hashCode()
{
return Objects.hash(catalogName, transactionId);
return transactionId.hashCode();
}

@Override
Expand All @@ -90,16 +77,14 @@ public boolean equals(Object obj)
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final SystemTransactionHandle other = (SystemTransactionHandle) obj;
return Objects.equals(this.catalogName, other.catalogName) &&
Objects.equals(this.transactionId, other.transactionId);
SystemTransactionHandle other = (SystemTransactionHandle) obj;
return transactionId.equals(other.transactionId);
}

@Override
public String toString()
{
return toStringHelper(this)
.add("catalogName", catalogName)
.add("transactionHandle", transactionId)
.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel
@Override
public ConnectorMetadata getMetadata(ConnectorTransactionHandle transaction)
{
return new SystemTablesMetadata(new CatalogName("test_session_connector"), new StaticSystemTablesProvider(ImmutableSet.of()));
return new SystemTablesMetadata(new StaticSystemTablesProvider(ImmutableSet.of()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ private static CatalogName registerBogusConnector(CatalogManager catalogManager,
new InformationSchemaConnector(catalogName, nodeManager, metadata, accessControl),
systemId,
new SystemConnector(
systemId,
nodeManager,
connector.getSystemTables(),
transactionId -> transactionManager.getConnectorTransaction(transactionId, catalog))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1782,7 +1782,6 @@ private Catalog createTestingCatalog(String catalogName, CatalogName catalog)
new InformationSchemaConnector(catalogName, nodeManager, metadata, accessControl),
systemId,
new SystemConnector(
systemId,
nodeManager,
connector.getSystemTables(),
transactionId -> transactionManager.getConnectorTransaction(transactionId, catalog)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ private static void registerConnector(
new InformationSchemaConnector(catalogName, nodeManager, metadata, new AllowAllAccessControl()),
systemId,
new SystemConnector(
systemId,
nodeManager,
connector.getSystemTables(),
transactionId -> transactionManager.getConnectorTransaction(transactionId, catalog))));
Expand Down

0 comments on commit f7d52ac

Please sign in to comment.