Search in sources :

Example 6 with KStreamHolder

use of io.confluent.ksql.execution.plan.KStreamHolder in project ksql by confluentinc.

the class StreamGroupByBuilderBase method build.

public <K> KGroupedStreamHolder build(final KStreamHolder<K> stream, final QueryContext queryContext, final Formats formats, final List<Expression> groupByExpressions) {
    final LogicalSchema sourceSchema = stream.getSchema();
    final List<CompiledExpression> groupBy = CodeGenRunner.compileExpressions(groupByExpressions.stream(), "Group By", sourceSchema, buildContext.getKsqlConfig(), buildContext.getFunctionRegistry());
    final ProcessingLogger logger = buildContext.getProcessingLogger(queryContext);
    final GroupByParams params = paramsFactory.build(sourceSchema, groupBy, logger);
    final Grouped<GenericKey, GenericRow> grouped = buildGrouped(formats, params.getSchema(), queryContext, buildContext, groupedFactory);
    final KGroupedStream<GenericKey, GenericRow> groupedStream = stream.getStream().filter((k, v) -> v != null).groupBy((k, v) -> params.getMapper().apply(v), grouped);
    return KGroupedStreamHolder.of(groupedStream, params.getSchema());
}
Also used : GenericRow(io.confluent.ksql.GenericRow) PhysicalSchema(io.confluent.ksql.schema.ksql.PhysicalSchema) RuntimeBuildContext(io.confluent.ksql.execution.runtime.RuntimeBuildContext) KGroupedStream(org.apache.kafka.streams.kstream.KGroupedStream) Expression(io.confluent.ksql.execution.expression.tree.Expression) QueryContext(io.confluent.ksql.execution.context.QueryContext) CompiledExpression(io.confluent.ksql.execution.codegen.CompiledExpression) Formats(io.confluent.ksql.execution.plan.Formats) StreamGroupByKey(io.confluent.ksql.execution.plan.StreamGroupByKey) LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) CodeGenRunner(io.confluent.ksql.execution.codegen.CodeGenRunner) Grouped(org.apache.kafka.streams.kstream.Grouped) KGroupedStreamHolder(io.confluent.ksql.execution.plan.KGroupedStreamHolder) KStreamHolder(io.confluent.ksql.execution.plan.KStreamHolder) List(java.util.List) GenericRow(io.confluent.ksql.GenericRow) Serde(org.apache.kafka.common.serialization.Serde) Objects.requireNonNull(java.util.Objects.requireNonNull) ProcessingLogger(io.confluent.ksql.logging.processing.ProcessingLogger) GenericKey(io.confluent.ksql.GenericKey) ProcessingLogger(io.confluent.ksql.logging.processing.ProcessingLogger) LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) GenericKey(io.confluent.ksql.GenericKey) CompiledExpression(io.confluent.ksql.execution.codegen.CompiledExpression)

Aggregations

KStreamHolder (io.confluent.ksql.execution.plan.KStreamHolder)6 GenericRow (io.confluent.ksql.GenericRow)5 GenericKey (io.confluent.ksql.GenericKey)3 ProcessingLogger (io.confluent.ksql.logging.processing.ProcessingLogger)3 LogicalSchema (io.confluent.ksql.schema.ksql.LogicalSchema)3 PhysicalSchema (io.confluent.ksql.schema.ksql.PhysicalSchema)3 CodeGenRunner (io.confluent.ksql.execution.codegen.CodeGenRunner)2 CompiledExpression (io.confluent.ksql.execution.codegen.CompiledExpression)2 QueryContext (io.confluent.ksql.execution.context.QueryContext)2 RuntimeBuildContext (io.confluent.ksql.execution.runtime.RuntimeBuildContext)2 SourceBuilderUtils.getPhysicalSchema (io.confluent.ksql.execution.streams.SourceBuilderUtils.getPhysicalSchema)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Expression (io.confluent.ksql.execution.expression.tree.Expression)1 ExecutionKeyFactory (io.confluent.ksql.execution.plan.ExecutionKeyFactory)1 Formats (io.confluent.ksql.execution.plan.Formats)1 KGroupedStreamHolder (io.confluent.ksql.execution.plan.KGroupedStreamHolder)1 StreamGroupByKey (io.confluent.ksql.execution.plan.StreamGroupByKey)1 StreamSelectKeyV1 (io.confluent.ksql.execution.plan.StreamSelectKeyV1)1 KeyFormat (io.confluent.ksql.serde.KeyFormat)1 WindowInfo (io.confluent.ksql.serde.WindowInfo)1