use of io.prestosql.metadata.MetadataManager in project hetu-core by openlookeng.
the class DataCenterUtility method loadDCCatalogsForShowQueries.
/**
* Utility method to load all DC catalog from ShowQueriesRewrite.
*
* @param session session
* @param metadata metadata
*/
public static void loadDCCatalogsForShowQueries(Metadata metadata, Session session) {
MetadataManager metadataManager = (MetadataManager) metadata;
DataCenterConnectorManager dataCenterConnectorManager = metadataManager.getDataCenterConnectorManager();
if (dataCenterConnectorManager != null) {
dataCenterConnectorManager.loadAllDCCatalogs();
}
}
use of io.prestosql.metadata.MetadataManager in project hetu-core by openlookeng.
the class TestConnectorFilterStatsCalculatorService method setUp.
@BeforeClass
public void setUp() {
session = testSessionBuilder().build();
MetadataManager metadata = MetadataManager.createTestMetadataManager();
FilterStatsCalculator statsCalculator = new FilterStatsCalculator(metadata, new ScalarStatsCalculator(metadata), new StatsNormalizer());
statsCalculatorService = new ConnectorFilterStatsCalculatorService(statsCalculator);
xStats = ColumnStatistics.builder().setDistinctValuesCount(Estimate.of(40)).setRange(new DoubleRange(-10, 10)).setNullsFraction(Estimate.of(0.25)).build();
zeroTableStatistics = TableStatistics.builder().setRowCount(Estimate.zero()).build();
unknownTableStatistics = TableStatistics.builder().setRowCount(Estimate.unknown()).build();
originalTableStatistics = TableStatistics.builder().setRowCount(Estimate.of(100)).setColumnStatistics(xColumn, xStats).build();
originalTableStatisticsWithoutTotalSize = TableStatistics.builder().setRowCount(Estimate.of(100)).setColumnStatistics(xColumn, xStats).build();
standardTypes = TypeProvider.viewOf(ImmutableMap.<Symbol, Type>builder().put(new Symbol("x"), DOUBLE).build());
translator = new TestingRowExpressionTranslator(MetadataManager.createTestMetadataManager());
}
use of io.prestosql.metadata.MetadataManager in project hetu-core by openlookeng.
the class ConnectorManager method addCatalogConnector.
public synchronized void addCatalogConnector(CatalogName catalogName, Connector catalogConnector) {
MaterializedConnector connector = new MaterializedConnector(catalogName, catalogConnector);
MaterializedConnector informationSchemaConnector = new MaterializedConnector(createInformationSchemaCatalogName(catalogName), new InformationSchemaConnector(catalogName.getCatalogName(), nodeManager, metadataManager, accessControlManager));
CatalogName systemId = createSystemTablesCatalogName(catalogName);
SystemTablesProvider systemTablesProvider;
if (nodeManager.getCurrentNode().isCoordinator()) {
systemTablesProvider = new DelegatingSystemTablesProvider(new StaticSystemTablesProvider(connector.getSystemTables()), new MetadataBasedSystemTablesProvider(metadataManager, catalogName.getCatalogName()));
} else {
systemTablesProvider = new StaticSystemTablesProvider(connector.getSystemTables());
}
MaterializedConnector systemConnector = new MaterializedConnector(systemId, new SystemConnector(nodeManager, systemTablesProvider, transactionId -> transactionManager.getConnectorTransaction(transactionId, catalogName)));
Catalog catalog = new Catalog(catalogName.getCatalogName(), connector.getCatalogName(), connector.getConnector(), informationSchemaConnector.getCatalogName(), informationSchemaConnector.getConnector(), systemConnector.getCatalogName(), systemConnector.getConnector());
try {
addConnectorInternal(connector);
addConnectorInternal(informationSchemaConnector);
addConnectorInternal(systemConnector);
catalogManager.registerCatalog(catalog);
} catch (Throwable e) {
catalogManager.removeCatalog(catalog.getCatalogName());
removeConnectorInternal(systemConnector.getCatalogName());
removeConnectorInternal(informationSchemaConnector.getCatalogName());
removeConnectorInternal(connector.getCatalogName());
throw e;
}
}
use of io.prestosql.metadata.MetadataManager in project hetu-core by openlookeng.
the class DataCenterUtility method loadDCCatalogForUseTask.
/**
* Utility method to load DC catalog from Usetask.
*
* @param statement statement
* @param metadata metadata
* @param session session
*/
public static void loadDCCatalogForUseTask(Use statement, Metadata metadata, Session session) {
Optional<Identifier> catalogIdentifier = statement.getCatalog();
Optional<String> catalogName = Optional.empty();
if (!catalogIdentifier.isPresent()) {
catalogName = session.getCatalog();
} else {
catalogName = Optional.ofNullable(catalogIdentifier.get().getValue());
}
if (catalogName.isPresent()) {
if (catalogName.isPresent()) {
MetadataManager metadataManager = (MetadataManager) metadata;
DataCenterConnectorManager dataCenterConnectorManager = metadataManager.getDataCenterConnectorManager();
if (dataCenterConnectorManager != null) {
dataCenterConnectorManager.loadDCCatalog(catalogName.get());
}
}
}
}
use of io.prestosql.metadata.MetadataManager in project hetu-core by openlookeng.
the class DataCenterUtility method isDCCatalog.
/**
* Utility method to check whether a catalog is cross-dc catalog.
*
* @param metadata session
* @param catalogName catalog name
*/
public static boolean isDCCatalog(Metadata metadata, String name) {
String catalogName = name;
if (catalogName != null && catalogName.contains(".")) {
catalogName = catalogName.substring(0, catalogName.indexOf("."));
}
MetadataManager metadataManager = (MetadataManager) metadata;
DataCenterConnectorManager dataCenterConnectorManager = metadataManager.getDataCenterConnectorManager();
if (dataCenterConnectorManager != null) {
return dataCenterConnectorManager.isDCCatalog(catalogName);
}
return false;
}
Aggregations