Search in sources :

Example 1 with PageSourceOperator

use of io.trino.operator.PageSourceOperator in project trino by trinodb.

the class IndexSourceOperator method addSplit.

@Override
public Supplier<Optional<UpdatablePageSource>> addSplit(Split split) {
    requireNonNull(split, "split is null");
    checkState(source == null, "Index source split already set");
    IndexSplit indexSplit = (IndexSplit) split.getConnectorSplit();
    // Normalize the incoming RecordSet to something that can be consumed by the index
    RecordSet normalizedRecordSet = probeKeyNormalizer.apply(indexSplit.getKeyRecordSet());
    ConnectorPageSource result = index.lookup(normalizedRecordSet);
    source = new PageSourceOperator(result, operatorContext);
    Object splitInfo = split.getInfo();
    if (splitInfo != null) {
        operatorContext.setInfoSupplier(Suppliers.ofInstance(new SplitOperatorInfo(split.getCatalogName(), splitInfo)));
    }
    return Optional::empty;
}
Also used : SplitOperatorInfo(io.trino.operator.SplitOperatorInfo) RecordSet(io.trino.spi.connector.RecordSet) ConnectorPageSource(io.trino.spi.connector.ConnectorPageSource) PageSourceOperator(io.trino.operator.PageSourceOperator)

Example 2 with PageSourceOperator

use of io.trino.operator.PageSourceOperator in project trino by trinodb.

the class AbstractOperatorBenchmark method createTableScanOperator.

protected final OperatorFactory createTableScanOperator(int operatorId, PlanNodeId planNodeId, String tableName, String... columnNames) {
    checkArgument(session.getCatalog().isPresent(), "catalog not set");
    checkArgument(session.getSchema().isPresent(), "schema not set");
    // look up the table
    Metadata metadata = localQueryRunner.getMetadata();
    QualifiedObjectName qualifiedTableName = new QualifiedObjectName(session.getCatalog().get(), session.getSchema().get(), tableName);
    TableHandle tableHandle = metadata.getTableHandle(session, qualifiedTableName).orElse(null);
    checkArgument(tableHandle != null, "Table '%s' does not exist", qualifiedTableName);
    // lookup the columns
    Map<String, ColumnHandle> allColumnHandles = metadata.getColumnHandles(session, tableHandle);
    ImmutableList.Builder<ColumnHandle> columnHandlesBuilder = ImmutableList.builder();
    for (String columnName : columnNames) {
        ColumnHandle columnHandle = allColumnHandles.get(columnName);
        checkArgument(columnHandle != null, "Table '%s' does not have a column '%s'", tableName, columnName);
        columnHandlesBuilder.add(columnHandle);
    }
    List<ColumnHandle> columnHandles = columnHandlesBuilder.build();
    // get the split for this table
    Split split = getLocalQuerySplit(session, tableHandle);
    return new OperatorFactory() {

        @Override
        public Operator createOperator(DriverContext driverContext) {
            OperatorContext operatorContext = driverContext.addOperatorContext(operatorId, planNodeId, "BenchmarkSource");
            ConnectorPageSource pageSource = localQueryRunner.getPageSourceManager().createPageSource(session, split, tableHandle, columnHandles, DynamicFilter.EMPTY);
            return new PageSourceOperator(pageSource, operatorContext);
        }

        @Override
        public void noMoreOperators() {
        }

        @Override
        public OperatorFactory duplicate() {
            throw new UnsupportedOperationException();
        }
    };
}
Also used : ColumnHandle(io.trino.spi.connector.ColumnHandle) DriverContext(io.trino.operator.DriverContext) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ImmutableList(com.google.common.collect.ImmutableList) AggregationMetadata(io.trino.operator.aggregation.AggregationMetadata) Metadata(io.trino.metadata.Metadata) ConnectorPageSource(io.trino.spi.connector.ConnectorPageSource) QualifiedObjectName(io.trino.metadata.QualifiedObjectName) PageSourceOperator(io.trino.operator.PageSourceOperator) OperatorFactory(io.trino.operator.OperatorFactory) OperatorContext(io.trino.operator.OperatorContext) TableHandle(io.trino.metadata.TableHandle) Split(io.trino.metadata.Split)

Aggregations

PageSourceOperator (io.trino.operator.PageSourceOperator)2 ConnectorPageSource (io.trino.spi.connector.ConnectorPageSource)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 Metadata (io.trino.metadata.Metadata)1 QualifiedObjectName (io.trino.metadata.QualifiedObjectName)1 Split (io.trino.metadata.Split)1 TableHandle (io.trino.metadata.TableHandle)1 DriverContext (io.trino.operator.DriverContext)1 OperatorContext (io.trino.operator.OperatorContext)1 OperatorFactory (io.trino.operator.OperatorFactory)1 SplitOperatorInfo (io.trino.operator.SplitOperatorInfo)1 AggregationMetadata (io.trino.operator.aggregation.AggregationMetadata)1 ColumnHandle (io.trino.spi.connector.ColumnHandle)1 RecordSet (io.trino.spi.connector.RecordSet)1