use of io.prestosql.spi.connector.ConnectorTransactionHandle in project hetu-core by openlookeng.
the class TpcdsConnectorFactory method create.
@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) {
int splitsPerNode = getSplitsPerNode(config);
NodeManager nodeManager = context.getNodeManager();
return new Connector() {
@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) {
return TpcdsTransactionHandle.INSTANCE;
}
@Override
public ConnectorMetadata getMetadata(ConnectorTransactionHandle transactionHandle) {
return new TpcdsMetadata();
}
@Override
public ConnectorSplitManager getSplitManager() {
return new TpcdsSplitManager(nodeManager, splitsPerNode, isWithNoSexism(config));
}
@Override
public ConnectorRecordSetProvider getRecordSetProvider() {
return new TpcdsRecordSetProvider();
}
@Override
public ConnectorNodePartitioningProvider getNodePartitioningProvider() {
return new TpcdsNodePartitioningProvider(nodeManager, splitsPerNode);
}
};
}
use of io.prestosql.spi.connector.ConnectorTransactionHandle in project hetu-core by openlookeng.
the class IndexedTpchConnectorFactory method create.
@Override
public Connector create(String catalogName, Map<String, String> properties, ConnectorContext context) {
int splitsPerNode = getSplitsPerNode(properties);
TpchIndexedData indexedData = new TpchIndexedData(indexSpec);
NodeManager nodeManager = context.getNodeManager();
return new Connector() {
@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) {
return TpchTransactionHandle.INSTANCE;
}
@Override
public ConnectorMetadata getMetadata(ConnectorTransactionHandle transactionHandle) {
return new TpchIndexMetadata(indexedData);
}
@Override
public ConnectorSplitManager getSplitManager() {
return new TpchSplitManager(nodeManager, splitsPerNode);
}
@Override
public ConnectorRecordSetProvider getRecordSetProvider() {
return new TpchRecordSetProvider();
}
@Override
public ConnectorIndexProvider getIndexProvider() {
return new TpchIndexProvider(indexedData);
}
@Override
public Set<SystemTable> getSystemTables() {
return ImmutableSet.of(new ExampleSystemTable());
}
@Override
public ConnectorNodePartitioningProvider getNodePartitioningProvider() {
return new TpchNodePartitioningProvider(nodeManager, splitsPerNode);
}
};
}
use of io.prestosql.spi.connector.ConnectorTransactionHandle in project hetu-core by openlookeng.
the class CarbondataPageSourceProvider method createPageSource.
@Override
public ConnectorPageSource createPageSource(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorSplit split, ConnectorTableHandle table, List<ColumnHandle> columns) {
HiveSplit carbonSplit = Types.checkType(((HiveSplitWrapper) (split)).getSplits().get(0), HiveSplit.class, "split is not class HiveSplit");
this.queryId = carbonSplit.getSchema().getProperty("queryId");
if (this.queryId == null) {
// Fall back to hive pagesource.
return super.createPageSource(transactionHandle, session, split, table, columns);
}
try {
hdfsEnvironment.getFileSystem(new HdfsEnvironment.HdfsContext(session, carbonSplit.getDatabase()), new Path(carbonSplit.getSchema().getProperty("tablePath")));
} catch (IOException e) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, "Failed to get file system: " + e.getMessage());
}
return hdfsEnvironment.doAs(session.getUser(), () -> {
Configuration configuration = this.hdfsEnvironment.getConfiguration(new HdfsEnvironment.HdfsContext(session, carbonSplit.getDatabase(), carbonSplit.getTable()), new Path(carbonSplit.getSchema().getProperty("tablePath")));
CarbonTable carbonTable = getCarbonTable(carbonSplit, configuration);
/* So that CarbonTLS can access it */
ThreadLocalSessionInfo.setConfigurationToCurrentThread(configuration);
boolean isFullACID = isFullAcidTable(Maps.fromProperties(carbonSplit.getSchema()));
boolean isDirectVectorFill = (carbonTableReader.config.getPushRowFilter() == null) || carbonTableReader.config.getPushRowFilter().equalsIgnoreCase("false") || columns.stream().anyMatch(c -> c.getColumnName().equalsIgnoreCase(CarbonCommonConstants.CARBON_IMPLICIT_COLUMN_TUPLEID));
return new CarbondataPageSource(carbonTable, queryId, carbonSplit, columns, table, configuration, isDirectVectorFill, isFullACID, session.getUser(), hdfsEnvironment);
});
}
use of io.prestosql.spi.connector.ConnectorTransactionHandle in project hetu-core by openlookeng.
the class TableCommentSystemTable method cursor.
@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession connectorSession, TupleDomain<Integer> constraint) {
Optional<String> catalogFilter = stringFilter(constraint, 0);
Optional<String> schemaFilter = stringFilter(constraint, 1);
Optional<String> tableFilter = stringFilter(constraint, 2);
Session session = toSession(transactionHandle, connectorSession);
Builder table = InMemoryRecordSet.builder(COMMENT_TABLE);
for (String catalog : filter(listCatalogs(session, metadata, accessControl).keySet(), catalogFilter)) {
QualifiedTablePrefix prefix = tablePrefix(catalog, schemaFilter, tableFilter);
Set<SchemaTableName> names = ImmutableSet.of();
try {
names = listTables(session, metadata, accessControl, prefix);
} catch (PrestoException e) {
// listTables throws an exception if cannot connect the database
LOG.debug(e, "Failed to get tables for catalog: %s", catalog);
}
for (SchemaTableName name : names) {
QualifiedObjectName tableName = new QualifiedObjectName(prefix.getCatalogName(), name.getSchemaName(), name.getTableName());
Optional<String> comment = Optional.empty();
try {
comment = metadata.getTableHandle(session, tableName).map(handle -> metadata.getTableMetadata(session, handle)).map(metadata -> metadata.getMetadata().getComment()).get();
} catch (PrestoException e) {
// getTableHandle may throw an exception (e.g. Cassandra connector doesn't allow case insensitive column names)
LOG.debug(e, "Failed to get metadata for table: %s", name);
}
table.addRow(prefix.getCatalogName(), name.getSchemaName(), name.getTableName(), comment.orElse(null));
}
}
return table.build().cursor();
}
use of io.prestosql.spi.connector.ConnectorTransactionHandle in project hetu-core by openlookeng.
the class TestHBase method testRollbackTransaction.
/**
* testRollbackTransaction
*/
@Test
public void testRollbackTransaction() {
ConnectorTransactionHandle transactionHandle = hConnector.beginTransaction(IsolationLevel.READ_COMMITTED, true);
hConnector.getMetadata(transactionHandle);
hConnector.rollback(transactionHandle);
}
Aggregations