com.facebook.presto.spi.ConnectorSplit Java Examples

The following examples show how to use com.facebook.presto.spi.ConnectorSplit. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ParaflowPageSourceProvider.java    From paraflow with Apache License 2.0 6 votes vote down vote up
@Override
public ConnectorPageSource createPageSource(ConnectorTransactionHandle transactionHandle, ConnectorSession session,
                                            ConnectorSplit split, List<ColumnHandle> columns)
{
    List<ParaflowColumnHandle> hdfsColumns = columns.stream()
            .map(col -> (ParaflowColumnHandle) col)
            .collect(Collectors.toList());
    ParaflowSplit paraflowSplit = checkType(split, ParaflowSplit.class, "hdfs split");
    Path path = new Path(paraflowSplit.getPath());

    Optional<ConnectorPageSource> pageSource = createParaflowPageSource(
            path,
            paraflowSplit.getStart(),
            paraflowSplit.getLen(),
            hdfsColumns);
    if (pageSource.isPresent()) {
        return pageSource.get();
    }
    throw new RuntimeException("Could not find a file reader for split " + paraflowSplit);
}
 
Example #2
Source File: KinesisSplitManager.java    From presto-kinesis with Apache License 2.0 6 votes vote down vote up
@Override
public ConnectorSplitSource getSplits(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorTableLayoutHandle layout, ConnectorSplitManager.SplitSchedulingStrategy splitSchedulingStrategy)
{
    KinesisTableLayoutHandle kinesislayout = handleResolver.convertLayout(layout);
    KinesisTableHandle kinesisTableHandle = kinesislayout.getTable();

    InternalStreamDescription desc = this.getStreamDescription(kinesisTableHandle.getStreamName());

    ImmutableList.Builder<ConnectorSplit> builder = ImmutableList.builder();
    for (Shard shard : desc.getShards()) {
        KinesisSplit split = new KinesisSplit(connectorId,
                kinesisTableHandle.getStreamName(),
                kinesisTableHandle.getMessageDataFormat(),
                shard.getShardId(),
                shard.getSequenceNumberRange().getStartingSequenceNumber(),
                shard.getSequenceNumberRange().getEndingSequenceNumber());
        builder.add(split);
    }

    return new FixedSplitSource(builder.build());
}
 
Example #3
Source File: EthereumRecordSetProvider.java    From presto-ethereum with Apache License 2.0 6 votes vote down vote up
@Override
public RecordSet getRecordSet(
        ConnectorTransactionHandle transaction,
        ConnectorSession session,
        ConnectorSplit split,
        List<? extends ColumnHandle> columns
) {
    EthereumSplit ethereumSplit = convertSplit(split);

    ImmutableList.Builder<EthereumColumnHandle> handleBuilder = ImmutableList.builder();

    for (ColumnHandle handle : columns) {
        EthereumColumnHandle columnHandle = convertColumnHandle(handle);
        handleBuilder.add(columnHandle);
    }

    return new EthereumRecordSet(web3j, handleBuilder.build(), ethereumSplit);
}
 
Example #4
Source File: KinesisHandleResolver.java    From presto-kinesis with Apache License 2.0 5 votes vote down vote up
KinesisSplit convertSplit(ConnectorSplit split)
{
    requireNonNull(split, "split is null");
    checkArgument(split instanceof KinesisSplit, "split is not an instance of KinesisSplit");
    KinesisSplit kinesisSplit = (KinesisSplit) split;
    checkArgument(kinesisSplit.getConnectorId().equals(connectorId), "split is not for this connector");
    return kinesisSplit;
}
 
Example #5
Source File: ElasticsearchPageSourceProvider.java    From presto-connectors with Apache License 2.0 5 votes vote down vote up
@Override
public ConnectorPageSource createPageSource(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorSplit split, List<ColumnHandle> columns)
{
    ElasticsearchSplit elasticsearchSplit = (ElasticsearchSplit) split;

    ImmutableList.Builder<ElasticsearchColumnHandle> handles = ImmutableList.builder();
    for (ColumnHandle handle : requireNonNull(columns, "columns is null")) {
        handles.add((ElasticsearchColumnHandle) handle);
    }

    return new ElasticsearchPageSource(elasticsearchClient, elasticsearchSplit, handles.build());
}
 
Example #6
Source File: HbaseSplitManager.java    From presto-connectors with Apache License 2.0 5 votes vote down vote up
@Override
public ConnectorSplitSource getSplits(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorTableLayoutHandle layout, SplitSchedulingStrategy splitSchedulingStrategy)
{
    HbaseTableLayoutHandle layoutHandle = (HbaseTableLayoutHandle) layout;
    HbaseTableHandle tableHandle = layoutHandle.getTable();

    String schemaName = tableHandle.getSchema();
    String tableName = tableHandle.getTable();
    String rowIdName = tableHandle.getRowId();

    // Get non-row ID column constraints
    List<HbaseColumnConstraint> constraints = getColumnConstraints(rowIdName, layoutHandle.getConstraint());

    // Get the row domain column range
    Optional<Domain> rDom = getRangeDomain(rowIdName, layoutHandle.getConstraint());

    // Call out to our client to retrieve all tablet split metadata using the row ID domain and the secondary index
    List<TabletSplitMetadata> tabletSplits = client.getTabletSplits(session, schemaName, tableName, rDom, constraints); //tableHandle.getSerializerInstance()

    // Pack the tablet split metadata into a connector split
    ImmutableList.Builder<ConnectorSplit> cSplits = ImmutableList.builder();
    for (TabletSplitMetadata splitMetadata : tabletSplits) {
        HbaseSplit split = new HbaseSplit(
                connectorId,
                schemaName,
                tableName,
                rowIdName,
                splitMetadata,
                constraints,
                tableHandle.getScanAuthorizations());
        cSplits.add(split);
    }

    return new FixedSplitSource(cSplits.build());
}
 
Example #7
Source File: HbaseRecordSetProvider.java    From presto-connectors with Apache License 2.0 5 votes vote down vote up
@Override
public RecordSet getRecordSet(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorSplit split, List<? extends ColumnHandle> columns)
{
    requireNonNull(split, "split is null");
    HbaseSplit hbaseSplit = (HbaseSplit) split;
    checkArgument(hbaseSplit.getConnectorId().equals(connectorId), "split is not for this connector");

    ImmutableList.Builder<HbaseColumnHandle> handles = ImmutableList.builder();
    for (ColumnHandle handle : columns) {
        handles.add((HbaseColumnHandle) handle);
    }

    return new HbaseRecordSet(hbaseClient, session, hbaseSplit, handles.build());
}
 
Example #8
Source File: KinesisRecordSetProvider.java    From presto-kinesis with Apache License 2.0 5 votes vote down vote up
@Override
public RecordSet getRecordSet(ConnectorTransactionHandle transactionHandle, ConnectorSession session,
                              ConnectorSplit split, List<? extends ColumnHandle> columns)
{
    KinesisSplit kinesisSplit = handleResolver.convertSplit(split);

    ImmutableList.Builder<KinesisColumnHandle> handleBuilder = ImmutableList.builder();
    ImmutableMap.Builder<KinesisColumnHandle, KinesisFieldDecoder<?>> messageFieldDecoderBuilder = ImmutableMap.builder();

    KinesisRowDecoder messageDecoder = registry.getRowDecoder(kinesisSplit.getMessageDataFormat());

    for (ColumnHandle handle : columns) {
        KinesisColumnHandle columnHandle = handleResolver.convertColumnHandle(handle);
        handleBuilder.add(columnHandle);

        if (!columnHandle.isInternal()) {
            KinesisFieldDecoder<?> fieldDecoder = registry.getFieldDecoder(kinesisSplit.getMessageDataFormat(),
                    columnHandle.getType().getJavaType(),
                    columnHandle.getDataFormat());

            messageFieldDecoderBuilder.put(columnHandle, fieldDecoder);
        }
    }

    ImmutableList<KinesisColumnHandle> handles = handleBuilder.build();
    ImmutableMap<KinesisColumnHandle, KinesisFieldDecoder<?>> messageFieldDecoders = messageFieldDecoderBuilder.build();

    return new KinesisRecordSet(kinesisSplit, session, clientManager, handles, messageDecoder, messageFieldDecoders, kinesisConnectorConfig);
}
 
Example #9
Source File: KubeRecordSetProvider.java    From kubesql with Apache License 2.0 5 votes vote down vote up
@Override
public RecordSet getRecordSet(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorSplit split, List<? extends ColumnHandle> columns)
{
    requireNonNull(split, "split is null");
    KubeSplit kubeSplit = (KubeSplit) split;

    ImmutableList.Builder<KubeColumnHandle> handles = ImmutableList.builder();
    for (ColumnHandle handle : columns) {
        handles.add((KubeColumnHandle) handle);
    }

    return new KubeRecordSet(kubeTables, kubeSplit, handles.build());
}
 
Example #10
Source File: KuduPageSourceProvider.java    From presto-kudu with Apache License 2.0 5 votes vote down vote up
@Override
public ConnectorPageSource createPageSource(ConnectorTransactionHandle transactionHandle,
                                            ConnectorSession session, ConnectorSplit split, List<ColumnHandle> columns) {
    KuduRecordSet recordSet = (KuduRecordSet) recordSetProvider.getRecordSet(transactionHandle, session, split, columns);
    if (columns.contains(KuduColumnHandle.ROW_ID_HANDLE)) {
        return new KuduUpdatablePageSource(recordSet);
    } else {
        return new RecordPageSource(recordSet);
    }
}
 
Example #11
Source File: KuduRecordSetProvider.java    From presto-kudu with Apache License 2.0 5 votes vote down vote up
@Override
public RecordSet getRecordSet(ConnectorTransactionHandle transactionHandle,
                              ConnectorSession session, ConnectorSplit split, List<? extends ColumnHandle> columns) {
    requireNonNull(split, "split is null");
    requireNonNull(columns, "columns is null");

    KuduSplit kuduSplit = checkType(split, KuduSplit.class, "split is not class KuduSplit");

    return new KuduRecordSet(clientSession, kuduSplit, columns);
}
 
Example #12
Source File: EthereumHandleResolver.java    From presto-ethereum with Apache License 2.0 4 votes vote down vote up
static EthereumSplit convertSplit(ConnectorSplit split) {
    requireNonNull(split, "split is null");
    checkArgument(split instanceof EthereumSplit, "split is not an instance of EthereumSplit");
    return (EthereumSplit) split;
}
 
Example #13
Source File: KinesisHandleResolver.java    From presto-kinesis with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends ConnectorSplit> getSplitClass()
{
    return KinesisSplit.class;
}
 
Example #14
Source File: KuduHandleResolver.java    From presto-kudu with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends ConnectorSplit> getSplitClass() {
    return KuduSplit.class;
}
 
Example #15
Source File: EthereumHandleResolver.java    From presto-ethereum with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends ConnectorSplit> getSplitClass() {
    return EthereumSplit.class;
}
 
Example #16
Source File: ParaflowHandleResolver.java    From paraflow with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends ConnectorSplit> getSplitClass()
{
    return ParaflowSplit.class;
}
 
Example #17
Source File: HbaseHandleResolver.java    From presto-connectors with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends ConnectorSplit> getSplitClass()
{
    return HbaseSplit.class;
}
 
Example #18
Source File: ElasticsearchHandleResolver.java    From presto-connectors with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends ConnectorSplit> getSplitClass()
{
    return ElasticsearchSplit.class;
}