use of io.trino.spi.connector.ConnectorTransactionHandle in project trino by trinodb.
the class KinesisRecordSetProvider method getRecordSet.
@Override
public RecordSet getRecordSet(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorSplit split, List<? extends ColumnHandle> columns) {
KinesisSplit kinesisSplit = (KinesisSplit) split;
List<KinesisColumnHandle> kinesisColumns = columns.stream().map(x -> (KinesisColumnHandle) x).collect(toImmutableList());
ImmutableList.Builder<KinesisColumnHandle> handleBuilder = ImmutableList.builder();
RowDecoder messageDecoder = decoderFactory.create(kinesisSplit.getMessageDataFormat(), new HashMap<>(), kinesisColumns.stream().filter(column -> !column.isInternal()).collect(toImmutableSet()));
for (ColumnHandle handle : columns) {
KinesisColumnHandle columnHandle = (KinesisColumnHandle) handle;
handleBuilder.add(columnHandle);
}
return new KinesisRecordSet(kinesisSplit, session, clientManager, handleBuilder.build(), messageDecoder, kinesisConfig);
}
use of io.trino.spi.connector.ConnectorTransactionHandle in project trino by trinodb.
the class KafkaRecordSetProvider method getRecordSet.
@Override
public RecordSet getRecordSet(ConnectorTransactionHandle transaction, ConnectorSession session, ConnectorSplit split, ConnectorTableHandle table, List<? extends ColumnHandle> columns) {
KafkaSplit kafkaSplit = (KafkaSplit) split;
List<KafkaColumnHandle> kafkaColumns = columns.stream().map(KafkaColumnHandle.class::cast).collect(toImmutableList());
RowDecoder keyDecoder = decoderFactory.create(kafkaSplit.getKeyDataFormat(), getDecoderParameters(kafkaSplit.getKeyDataSchemaContents()), kafkaColumns.stream().filter(col -> !col.isInternal()).filter(KafkaColumnHandle::isKeyCodec).collect(toImmutableSet()));
RowDecoder messageDecoder = decoderFactory.create(kafkaSplit.getMessageDataFormat(), getDecoderParameters(kafkaSplit.getMessageDataSchemaContents()), kafkaColumns.stream().filter(col -> !col.isInternal()).filter(col -> !col.isKeyCodec()).collect(toImmutableSet()));
return new KafkaRecordSet(kafkaSplit, consumerFactory, session, kafkaColumns, keyDecoder, messageDecoder);
}
use of io.trino.spi.connector.ConnectorTransactionHandle in project trino by trinodb.
the class TpchConnectorFactory method create.
@Override
public Connector create(String catalogName, Map<String, String> properties, ConnectorContext context) {
int splitsPerNode = getSplitsPerNode(properties);
ColumnNaming columnNaming = ColumnNaming.valueOf(properties.getOrDefault(TPCH_COLUMN_NAMING_PROPERTY, ColumnNaming.SIMPLIFIED.name()).toUpperCase(ENGLISH));
DecimalTypeMapping decimalTypeMapping = DecimalTypeMapping.valueOf(properties.getOrDefault(TPCH_DOUBLE_TYPE_MAPPING_PROPERTY, DecimalTypeMapping.DOUBLE.name()).toUpperCase(ENGLISH));
NodeManager nodeManager = context.getNodeManager();
return new Connector() {
@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit) {
return TpchTransactionHandle.INSTANCE;
}
@Override
public ConnectorMetadata getMetadata(ConnectorSession session, ConnectorTransactionHandle transaction) {
return new TpchMetadata(columnNaming, decimalTypeMapping, predicatePushdownEnabled, partitioningEnabled, getTpchTableScanRedirectionCatalog(properties), getTpchTableScanRedirectionSchema(properties));
}
@Override
public ConnectorSplitManager getSplitManager() {
return new TpchSplitManager(nodeManager, splitsPerNode);
}
@Override
public ConnectorPageSourceProvider getPageSourceProvider() {
if (isProducePages(properties)) {
return new TpchPageSourceProvider(getMaxRowsPerPage(properties), decimalTypeMapping);
}
throw new UnsupportedOperationException();
}
@Override
public ConnectorRecordSetProvider getRecordSetProvider() {
if (!isProducePages(properties)) {
return new TpchRecordSetProvider(decimalTypeMapping);
}
throw new UnsupportedOperationException();
}
@Override
public ConnectorNodePartitioningProvider getNodePartitioningProvider() {
return new TpchNodePartitioningProvider(nodeManager, splitsPerNode);
}
};
}
use of io.trino.spi.connector.ConnectorTransactionHandle in project trino by trinodb.
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, boolean autoCommit) {
return TpcdsTransactionHandle.INSTANCE;
}
@Override
public ConnectorMetadata getMetadata(ConnectorSession session, 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);
}
};
}
Aggregations