use of com.facebook.presto.decoder.RowDecoder in project presto by prestodb.
the class KafkaRecordSetProvider method getRecordSet.
@Override
public RecordSet getRecordSet(ConnectorTransactionHandle transaction, ConnectorSession session, ConnectorSplit split, List<? extends ColumnHandle> columns) {
KafkaSplit kafkaSplit = convertSplit(split);
ImmutableList.Builder<DecoderColumnHandle> handleBuilder = ImmutableList.builder();
ImmutableMap.Builder<DecoderColumnHandle, FieldDecoder<?>> keyFieldDecoderBuilder = ImmutableMap.builder();
ImmutableMap.Builder<DecoderColumnHandle, FieldDecoder<?>> messageFieldDecoderBuilder = ImmutableMap.builder();
RowDecoder keyDecoder = registry.getRowDecoder(kafkaSplit.getKeyDataFormat());
RowDecoder messageDecoder = registry.getRowDecoder(kafkaSplit.getMessageDataFormat());
for (ColumnHandle handle : columns) {
KafkaColumnHandle columnHandle = convertColumnHandle(handle);
handleBuilder.add(columnHandle);
if (!columnHandle.isInternal()) {
if (columnHandle.isKeyDecoder()) {
FieldDecoder<?> fieldDecoder = registry.getFieldDecoder(kafkaSplit.getKeyDataFormat(), columnHandle.getType().getJavaType(), columnHandle.getDataFormat());
keyFieldDecoderBuilder.put(columnHandle, fieldDecoder);
} else {
FieldDecoder<?> fieldDecoder = registry.getFieldDecoder(kafkaSplit.getMessageDataFormat(), columnHandle.getType().getJavaType(), columnHandle.getDataFormat());
messageFieldDecoderBuilder.put(columnHandle, fieldDecoder);
}
}
}
ImmutableList<DecoderColumnHandle> handles = handleBuilder.build();
ImmutableMap<DecoderColumnHandle, FieldDecoder<?>> keyFieldDecoders = keyFieldDecoderBuilder.build();
ImmutableMap<DecoderColumnHandle, FieldDecoder<?>> messageFieldDecoders = messageFieldDecoderBuilder.build();
return new KafkaRecordSet(kafkaSplit, consumerManager, handles, keyDecoder, messageDecoder, keyFieldDecoders, messageFieldDecoders);
}
use of com.facebook.presto.decoder.RowDecoder in project presto by prestodb.
the class RedisRecordSetProvider method getRecordSet.
@Override
public RecordSet getRecordSet(ConnectorTransactionHandle transaction, ConnectorSession session, ConnectorSplit split, List<? extends ColumnHandle> columns) {
RedisSplit redisSplit = convertSplit(split);
ImmutableList.Builder<DecoderColumnHandle> handleBuilder = ImmutableList.builder();
ImmutableMap.Builder<DecoderColumnHandle, FieldDecoder<?>> keyFieldDecoderBuilder = ImmutableMap.builder();
ImmutableMap.Builder<DecoderColumnHandle, FieldDecoder<?>> valueFieldDecoderBuilder = ImmutableMap.builder();
RowDecoder keyDecoder = registry.getRowDecoder(redisSplit.getKeyDataFormat());
RowDecoder valueDecoder = registry.getRowDecoder(redisSplit.getValueDataFormat());
for (ColumnHandle handle : columns) {
RedisColumnHandle columnHandle = convertColumnHandle(handle);
handleBuilder.add(columnHandle);
if (!columnHandle.isInternal()) {
if (columnHandle.isKeyDecoder()) {
FieldDecoder<?> fieldDecoder = registry.getFieldDecoder(redisSplit.getKeyDataFormat(), columnHandle.getType().getJavaType(), columnHandle.getDataFormat());
keyFieldDecoderBuilder.put(columnHandle, fieldDecoder);
} else {
FieldDecoder<?> fieldDecoder = registry.getFieldDecoder(redisSplit.getValueDataFormat(), columnHandle.getType().getJavaType(), columnHandle.getDataFormat());
valueFieldDecoderBuilder.put(columnHandle, fieldDecoder);
}
}
}
ImmutableList<DecoderColumnHandle> handles = handleBuilder.build();
ImmutableMap<DecoderColumnHandle, FieldDecoder<?>> keyFieldDecoders = keyFieldDecoderBuilder.build();
ImmutableMap<DecoderColumnHandle, FieldDecoder<?>> valueFieldDecoders = valueFieldDecoderBuilder.build();
return new RedisRecordSet(redisSplit, jedisManager, handles, keyDecoder, valueDecoder, keyFieldDecoders, valueFieldDecoders);
}
Aggregations