use of io.prestosql.spi.metadata.TableHandle in project hetu-core by openlookeng.
the class MetadataManager method getTableProperties.
@Override
public TableProperties getTableProperties(Session session, TableHandle handle) {
CatalogName catalogName = handle.getCatalogName();
CatalogMetadata catalogMetadata = getCatalogMetadata(session, catalogName);
ConnectorMetadata metadata = catalogMetadata.getMetadataFor(catalogName);
ConnectorSession connectorSession = session.toConnectorSession(catalogName);
TableProperties tableProperties;
ConcurrentHashMap<ConnectorTableHandle, TableProperties> tablePropertiesMap;
String queryId = session.getQueryId().getId();
if (metadata.usesLegacyTableLayouts()) {
return handle.getLayout().map(layout -> new TableProperties(catalogName, handle.getTransaction(), new ConnectorTableProperties(metadata.getTableLayout(connectorSession, layout)))).orElseGet(() -> getLayout(session, handle, Constraint.alwaysTrue(), Optional.empty()).get().getTableProperties());
}
if (!handle.getConnectorHandle().isTablePropertiesCacheSupported()) {
return new TableProperties(catalogName, handle.getTransaction(), metadata.getTableProperties(connectorSession, handle.getConnectorHandle()));
}
if (tablePropertiesQueryCache.get(queryId) != null && tablePropertiesQueryCache.get(queryId).get(handle.getConnectorHandle()) != null) {
return tablePropertiesQueryCache.get(queryId).get(handle.getConnectorHandle());
} else {
tableProperties = new TableProperties(catalogName, handle.getTransaction(), metadata.getTableProperties(connectorSession, handle.getConnectorHandle()));
if (tablePropertiesQueryCache.containsKey(queryId)) {
tablePropertiesMap = tablePropertiesQueryCache.get(queryId);
} else {
tablePropertiesMap = new ConcurrentHashMap<>();
}
tablePropertiesMap.put(handle.getConnectorHandle(), tableProperties);
tablePropertiesQueryCache.put(queryId, tablePropertiesMap);
}
return tableProperties;
}
use of io.prestosql.spi.metadata.TableHandle in project hetu-core by openlookeng.
the class MetadataManager method applyFilter.
@Override
public Optional<ConstraintApplicationResult<TableHandle>> applyFilter(Session session, TableHandle table, Constraint constraint, List<Constraint> disjunctConstraints, Set<ColumnHandle> allColumnHandles, boolean pushPartitionsOnly) {
CatalogName catalogName = table.getCatalogName();
ConnectorMetadata metadata = getMetadata(session, catalogName);
if (metadata.usesLegacyTableLayouts()) {
return Optional.empty();
}
ConnectorSession connectorSession = session.toConnectorSession(catalogName);
return metadata.applyFilter(connectorSession, table.getConnectorHandle(), constraint, disjunctConstraints, allColumnHandles, pushPartitionsOnly).map(result -> new ConstraintApplicationResult<>(new TableHandle(catalogName, result.getHandle(), table.getTransaction(), Optional.empty()), result.getRemainingFilter()));
}
use of io.prestosql.spi.metadata.TableHandle in project hetu-core by openlookeng.
the class MetadataManager method applySample.
@Override
public Optional<TableHandle> applySample(Session session, TableHandle table, SampleType sampleType, double sampleRatio) {
CatalogName catalogName = table.getCatalogName();
ConnectorMetadata metadata = getMetadata(session, catalogName);
if (metadata.usesLegacyTableLayouts()) {
return Optional.empty();
}
ConnectorSession connectorSession = session.toConnectorSession(catalogName);
return metadata.applySample(connectorSession, table.getConnectorHandle(), sampleType, sampleRatio).map(result -> new TableHandle(catalogName, result, table.getTransaction(), Optional.empty()));
}
use of io.prestosql.spi.metadata.TableHandle in project hetu-core by openlookeng.
the class MetadataManager method getTableHandle.
@Override
public Optional<TableHandle> getTableHandle(Session session, QualifiedObjectName table) {
requireNonNull(table, "table is null");
Optional<CatalogMetadata> catalog = getOptionalCatalogMetadata(session, table.getCatalogName());
if (catalog.isPresent()) {
CatalogMetadata catalogMetadata = catalog.get();
CatalogName catalogName = catalogMetadata.getConnectorId(session, table);
ConnectorMetadata metadata = catalogMetadata.getMetadataFor(catalogName);
ConnectorSession connectorSession = session.toConnectorSession(catalogName);
ConnectorTableHandle tableHandle = metadata.getTableHandle(connectorSession, toSchemaTableName(table));
if (tableHandle != null) {
return Optional.of(new TableHandle(catalogName, tableHandle, catalogMetadata.getTransactionHandleFor(catalogName), Optional.empty()));
}
}
return Optional.empty();
}
use of io.prestosql.spi.metadata.TableHandle in project hetu-core by openlookeng.
the class MetadataManager method beginDelete.
@Override
public TableHandle beginDelete(Session session, TableHandle tableHandle) {
CatalogName catalogName = tableHandle.getCatalogName();
ConnectorMetadata metadata = getMetadataForWrite(session, catalogName);
ConnectorTableHandle newHandle = metadata.beginDelete(session.toConnectorSession(catalogName), tableHandle.getConnectorHandle());
return new TableHandle(tableHandle.getCatalogName(), newHandle, tableHandle.getTransaction(), tableHandle.getLayout());
}
Aggregations