Search in sources :

Example 11 with RecordSet

use of com.facebook.presto.spi.RecordSet in project presto by prestodb.

the class ThriftIndexedTpchService method lookupIndexKeys.

/**
 * Get lookup result and re-map output columns based on requested order.
 */
private static RecordSet lookupIndexKeys(RecordSet keys, IndexedTable table, List<String> outputColumnNames) {
    RecordSet allColumnsOutputRecordSet = table.lookupKeys(keys);
    List<Integer> outputRemap = computeRemap(table.getOutputColumns(), outputColumnNames);
    return new MappedRecordSet(allColumnsOutputRecordSet, outputRemap);
}
Also used : MappedRecordSet(com.facebook.presto.split.MappedRecordSet) RecordSet(com.facebook.presto.spi.RecordSet) MappedRecordSet(com.facebook.presto.split.MappedRecordSet)

Example 12 with RecordSet

use of com.facebook.presto.spi.RecordSet in project presto by prestodb.

the class ThriftIndexedTpchService method createLookupPageSource.

@Override
protected ConnectorPageSource createLookupPageSource(SplitInfo splitInfo, List<String> outputColumnNames) {
    IndexedTable indexedTable = indexedData.getIndexedTable(splitInfo.getTableName(), schemaNameToScaleFactor(splitInfo.getSchemaName()), ImmutableSet.copyOf(splitInfo.getLookupColumnNames())).orElseThrow(() -> new IllegalArgumentException(String.format("No such index: %s%s", splitInfo.getTableName(), splitInfo.getLookupColumnNames())));
    List<Type> lookupColumnTypes = types(splitInfo.getTableName(), splitInfo.getLookupColumnNames());
    RecordSet keyRecordSet = new MappedRecordSet(new ListBasedRecordSet(splitInfo.getKeys(), lookupColumnTypes), computeRemap(splitInfo.getLookupColumnNames(), indexedTable.getKeyColumns()));
    RecordSet outputRecordSet = lookupIndexKeys(keyRecordSet, indexedTable, outputColumnNames);
    return new RecordPageSource(outputRecordSet);
}
Also used : Type(com.facebook.presto.common.type.Type) MappedRecordSet(com.facebook.presto.split.MappedRecordSet) RecordSet(com.facebook.presto.spi.RecordSet) MappedRecordSet(com.facebook.presto.split.MappedRecordSet) IndexedTable(com.facebook.presto.tests.tpch.TpchIndexedData.IndexedTable) RecordPageSource(com.facebook.presto.spi.RecordPageSource)

Example 13 with RecordSet

use of com.facebook.presto.spi.RecordSet 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);
    List<KafkaColumnHandle> kafkaColumns = columns.stream().map(KafkaHandleResolver::convertColumnHandle).collect(ImmutableList.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, consumerManager, kafkaColumns, keyDecoder, messageDecoder);
}
Also used : ImmutableMap(com.google.common.collect.ImmutableMap) KafkaHandleResolver.convertSplit(com.facebook.presto.kafka.KafkaHandleResolver.convertSplit) RowDecoder(com.facebook.presto.decoder.RowDecoder) ConnectorTransactionHandle(com.facebook.presto.spi.connector.ConnectorTransactionHandle) RecordSet(com.facebook.presto.spi.RecordSet) ConnectorSession(com.facebook.presto.spi.ConnectorSession) Inject(javax.inject.Inject) ConnectorSplit(com.facebook.presto.spi.ConnectorSplit) List(java.util.List) ConnectorRecordSetProvider(com.facebook.presto.spi.connector.ConnectorRecordSetProvider) ImmutableList(com.google.common.collect.ImmutableList) ColumnHandle(com.facebook.presto.spi.ColumnHandle) Map(java.util.Map) Objects.requireNonNull(java.util.Objects.requireNonNull) Optional(java.util.Optional) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) DispatchingRowDecoderFactory(com.facebook.presto.decoder.DispatchingRowDecoderFactory) RowDecoder(com.facebook.presto.decoder.RowDecoder)

Example 14 with RecordSet

use of com.facebook.presto.spi.RecordSet in project presto by prestodb.

the class TestJmxSplitManager method testHistoryRecordSetProvider.

@Test
public void testHistoryRecordSetProvider() throws Exception {
    for (SchemaTableName schemaTableName : metadata.listTables(SESSION, HISTORY_SCHEMA_NAME)) {
        // wait for at least two samples
        List<Long> timeStamps = ImmutableList.of();
        for (int waited = 0; waited < TIMEOUT_TIME; waited += SLEEP_TIME) {
            RecordSet recordSet = getRecordSet(schemaTableName);
            timeStamps = readTimeStampsFrom(recordSet);
            if (timeStamps.size() >= 2) {
                break;
            }
            Thread.sleep(SLEEP_TIME);
        }
        assertTrue(timeStamps.size() >= 2);
        // we don't have equality check here because JmxHistoryDumper scheduling can lag
        assertTrue(timeStamps.get(1) - timeStamps.get(0) >= JMX_STATS_DUMP.toMillis());
    }
}
Also used : RecordSet(com.facebook.presto.spi.RecordSet) SchemaTableName(com.facebook.presto.spi.SchemaTableName) Test(org.testng.annotations.Test)

Example 15 with RecordSet

use of com.facebook.presto.spi.RecordSet in project presto by prestodb.

the class CommonSubExpressionBenchmark method ComputeRecordSet.

@Benchmark
public Optional<Page> ComputeRecordSet() {
    List<Type> types = ImmutableList.of(TYPE_MAP.get(this.functionType));
    PageBuilder pageBuilder = new PageBuilder(projectionTypes);
    RecordSet recordSet = new PageRecordSet(types, inputPage);
    cursorProcessor.process(null, new DriverYieldSignal(), recordSet.cursor(), pageBuilder);
    return Optional.of(pageBuilder.build());
}
Also used : Type(com.facebook.presto.common.type.Type) DriverYieldSignal(com.facebook.presto.operator.DriverYieldSignal) PageBuilder(com.facebook.presto.common.PageBuilder) SequencePageBuilder(com.facebook.presto.SequencePageBuilder) PageRecordSet(com.facebook.presto.operator.index.PageRecordSet) RecordSet(com.facebook.presto.spi.RecordSet) PageRecordSet(com.facebook.presto.operator.index.PageRecordSet) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Aggregations

RecordSet (com.facebook.presto.spi.RecordSet)25 Test (org.testng.annotations.Test)14 RecordCursor (com.facebook.presto.spi.RecordCursor)11 LinkedHashMap (java.util.LinkedHashMap)8 Type (com.facebook.presto.common.type.Type)6 ConnectorTransactionHandle (com.facebook.presto.spi.connector.ConnectorTransactionHandle)5 ColumnHandle (com.facebook.presto.spi.ColumnHandle)4 ImmutableList (com.google.common.collect.ImmutableList)4 List (java.util.List)4 Map (java.util.Map)4 Objects.requireNonNull (java.util.Objects.requireNonNull)4 ConnectorSession (com.facebook.presto.spi.ConnectorSession)3 SchemaTableName (com.facebook.presto.spi.SchemaTableName)3 MappedRecordSet (com.facebook.presto.split.MappedRecordSet)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 ImmutableSet.toImmutableSet (com.google.common.collect.ImmutableSet.toImmutableSet)3 ArrayList (java.util.ArrayList)3 Optional (java.util.Optional)3 PageBuilder (com.facebook.presto.common.PageBuilder)2 Block (com.facebook.presto.common.block.Block)2