Search in sources :

Example 26 with ExpressionEvalContext

use of com.hazelcast.sql.impl.expression.ExpressionEvalContext in project hazelcast by hazelcast.

the class CreateDagVisitor method onSlidingWindow.

public Vertex onSlidingWindow(SlidingWindowPhysicalRel rel) {
    int orderingFieldIndex = rel.orderingFieldIndex();
    FunctionEx<ExpressionEvalContext, SlidingWindowPolicy> windowPolicySupplier = rel.windowPolicyProvider();
    // this vertex is used only if there's no aggregation by a window bound
    Vertex vertex = dag.newUniqueVertex("Sliding-Window", flatMapUsingServiceP(ServiceFactories.nonSharedService(ctx -> {
        ExpressionEvalContext evalContext = ExpressionEvalContext.from(ctx);
        SlidingWindowPolicy windowPolicy = windowPolicySupplier.apply(evalContext);
        return row -> WindowUtils.addWindowBounds(row, orderingFieldIndex, windowPolicy);
    }), (BiFunctionEx<Function<JetSqlRow, Traverser<JetSqlRow>>, JetSqlRow, Traverser<JetSqlRow>>) Function::apply));
    connectInput(rel.getInput(), vertex, null);
    return vertex;
}
Also used : ExpressionEvalContext(com.hazelcast.sql.impl.expression.ExpressionEvalContext) Address(com.hazelcast.cluster.Address) Traverser(com.hazelcast.jet.Traverser) ExpressionValues(com.hazelcast.jet.sql.impl.opt.ExpressionValues) PlanObjectKey(com.hazelcast.sql.impl.optimizer.PlanObjectKey) Processors.mapP(com.hazelcast.jet.core.processor.Processors.mapP) SourceProcessors.convenientSourceP(com.hazelcast.jet.core.processor.SourceProcessors.convenientSourceP) QueryParameterMetadata(com.hazelcast.sql.impl.QueryParameterMetadata) Collections.singletonList(java.util.Collections.singletonList) BiFunctionEx(com.hazelcast.function.BiFunctionEx) HazelcastTable(com.hazelcast.jet.sql.impl.schema.HazelcastTable) ObjectArrayKey(com.hazelcast.jet.sql.impl.ObjectArrayKey) SlidingWindowPolicy(com.hazelcast.jet.core.SlidingWindowPolicy) SqlConnectorUtil(com.hazelcast.jet.sql.impl.connector.SqlConnectorUtil) AggregateOperation(com.hazelcast.jet.aggregate.AggregateOperation) Functions.entryKey(com.hazelcast.function.Functions.entryKey) SqlConnectorUtil.getJetSqlConnector(com.hazelcast.jet.sql.impl.connector.SqlConnectorUtil.getJetSqlConnector) DAG(com.hazelcast.jet.core.DAG) RootResultConsumerSink.rootResultConsumerSink(com.hazelcast.jet.sql.impl.processors.RootResultConsumerSink.rootResultConsumerSink) ServiceFactories(com.hazelcast.jet.pipeline.ServiceFactories) FunctionEx(com.hazelcast.function.FunctionEx) KeyedWindowResultFunction(com.hazelcast.jet.core.function.KeyedWindowResultFunction) Predicate(java.util.function.Predicate) Collections.emptyList(java.util.Collections.emptyList) Set(java.util.Set) ConsumerEx(com.hazelcast.function.ConsumerEx) IMapSqlConnector(com.hazelcast.jet.sql.impl.connector.map.IMapSqlConnector) ExpressionUtil(com.hazelcast.jet.sql.impl.ExpressionUtil) Processors.filterUsingServiceP(com.hazelcast.jet.core.processor.Processors.filterUsingServiceP) List(java.util.List) ExpressionEvalContext(com.hazelcast.sql.impl.expression.ExpressionEvalContext) Processors.mapUsingServiceP(com.hazelcast.jet.core.processor.Processors.mapUsingServiceP) Table(com.hazelcast.sql.impl.schema.Table) ComparatorEx(com.hazelcast.function.ComparatorEx) QueryDataType(com.hazelcast.sql.impl.type.QueryDataType) Processors(com.hazelcast.jet.core.processor.Processors) Processors.flatMapUsingServiceP(com.hazelcast.jet.core.processor.Processors.flatMapUsingServiceP) TimestampKind(com.hazelcast.jet.core.TimestampKind) Function(java.util.function.Function) JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow) HashSet(java.util.HashSet) Edge.from(com.hazelcast.jet.core.Edge.from) Edge(com.hazelcast.jet.core.Edge) Expression(com.hazelcast.sql.impl.expression.Expression) ProcessorSupplier(com.hazelcast.jet.core.ProcessorSupplier) VertexWithInputConfig(com.hazelcast.jet.sql.impl.connector.SqlConnector.VertexWithInputConfig) SingleRel(org.apache.calcite.rel.SingleRel) Nullable(javax.annotation.Nullable) JetJoinInfo(com.hazelcast.jet.sql.impl.JetJoinInfo) NodeEngine(com.hazelcast.spi.impl.NodeEngine) ProcessorMetaSupplier(com.hazelcast.jet.core.ProcessorMetaSupplier) RelNode(org.apache.calcite.rel.RelNode) Consumer(java.util.function.Consumer) Vertex(com.hazelcast.jet.core.Vertex) ToLongFunctionEx(com.hazelcast.function.ToLongFunctionEx) SqlHashJoinP(com.hazelcast.jet.sql.impl.processors.SqlHashJoinP) ConstantExpression(com.hazelcast.sql.impl.expression.ConstantExpression) Processors.sortP(com.hazelcast.jet.core.processor.Processors.sortP) DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) WindowUtils(com.hazelcast.jet.sql.impl.aggregate.WindowUtils) Edge.between(com.hazelcast.jet.core.Edge.between) Vertex(com.hazelcast.jet.core.Vertex) KeyedWindowResultFunction(com.hazelcast.jet.core.function.KeyedWindowResultFunction) Function(java.util.function.Function) SlidingWindowPolicy(com.hazelcast.jet.core.SlidingWindowPolicy) Traverser(com.hazelcast.jet.Traverser) JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow) BiFunctionEx(com.hazelcast.function.BiFunctionEx)

Example 27 with ExpressionEvalContext

use of com.hazelcast.sql.impl.expression.ExpressionEvalContext in project hazelcast by hazelcast.

the class UpdatingEntryProcessor method setSerializationService.

@Override
public void setSerializationService(SerializationService serializationService) {
    this.evalContext = new ExpressionEvalContext(arguments, (InternalSerializationService) serializationService);
    this.extractors = Extractors.newBuilder(evalContext.getSerializationService()).build();
}
Also used : ExpressionEvalContext(com.hazelcast.sql.impl.expression.ExpressionEvalContext) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService)

Aggregations

ExpressionEvalContext (com.hazelcast.sql.impl.expression.ExpressionEvalContext)27 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)9 QuickTest (com.hazelcast.test.annotation.QuickTest)9 Test (org.junit.Test)9 IndexConfig (com.hazelcast.config.IndexConfig)7 HazelcastInstance (com.hazelcast.core.HazelcastInstance)7 InternalIndex (com.hazelcast.query.impl.InternalIndex)7 Expression (com.hazelcast.sql.impl.expression.Expression)6 Vertex (com.hazelcast.jet.core.Vertex)5 IndexRangeFilter (com.hazelcast.sql.impl.exec.scan.index.IndexRangeFilter)5 List (java.util.List)5 FunctionEx (com.hazelcast.function.FunctionEx)4 PlanObjectKey (com.hazelcast.sql.impl.optimizer.PlanObjectKey)4 JetSqlRow (com.hazelcast.sql.impl.row.JetSqlRow)4 DAG (com.hazelcast.jet.core.DAG)3 ProcessorMetaSupplier (com.hazelcast.jet.core.ProcessorMetaSupplier)3 QueryParameterMetadata (com.hazelcast.sql.impl.QueryParameterMetadata)3 Map (java.util.Map)3 Entry (java.util.Map.Entry)3 RelOptCluster (org.apache.calcite.plan.RelOptCluster)3