Search in sources :

Example 1 with UpsertTargetDescriptor

use of com.hazelcast.jet.sql.impl.inject.UpsertTargetDescriptor in project hazelcast by hazelcast.

the class SinkMapPhysicalRel method entriesFn.

public Function<ExpressionEvalContext, Map<Object, Object>> entriesFn() {
    PartitionedMapTable table = table();
    List<ExpressionValues> values = this.values;
    return evalContext -> {
        KvProjector projector = KvProjector.supplier(table.paths(), table.types(), (UpsertTargetDescriptor) table.getKeyJetMetadata(), (UpsertTargetDescriptor) table.getValueJetMetadata(), true).get(evalContext.getSerializationService());
        return values.stream().flatMap(vs -> vs.toValues(evalContext)).map(projector::project).collect(toMap(Entry::getKey, Entry::getValue));
    };
}
Also used : RelOptCluster(org.apache.calcite.plan.RelOptCluster) RelDataType(org.apache.calcite.rel.type.RelDataType) SqlKind(org.apache.calcite.sql.SqlKind) PlanNodeSchema(com.hazelcast.sql.impl.plan.node.PlanNodeSchema) AbstractRelNode(org.apache.calcite.rel.AbstractRelNode) ExpressionValues(com.hazelcast.jet.sql.impl.opt.ExpressionValues) PlanObjectKey(com.hazelcast.sql.impl.optimizer.PlanObjectKey) RelNode(org.apache.calcite.rel.RelNode) RelOptUtil(org.apache.calcite.plan.RelOptUtil) Function(java.util.function.Function) QueryParameterMetadata(com.hazelcast.sql.impl.QueryParameterMetadata) RelOptTable(org.apache.calcite.plan.RelOptTable) RelWriter(org.apache.calcite.rel.RelWriter) Vertex(com.hazelcast.jet.core.Vertex) HazelcastTable(com.hazelcast.jet.sql.impl.schema.HazelcastTable) List(java.util.List) ExpressionEvalContext(com.hazelcast.sql.impl.expression.ExpressionEvalContext) Collectors.toMap(java.util.stream.Collectors.toMap) KvProjector(com.hazelcast.jet.sql.impl.connector.keyvalue.KvProjector) UpsertTargetDescriptor(com.hazelcast.jet.sql.impl.inject.UpsertTargetDescriptor) Map(java.util.Map) Entry(java.util.Map.Entry) PartitionedMapTable(com.hazelcast.sql.impl.schema.map.PartitionedMapTable) RelTraitSet(org.apache.calcite.plan.RelTraitSet) ExpressionValues(com.hazelcast.jet.sql.impl.opt.ExpressionValues) Entry(java.util.Map.Entry) KvProjector(com.hazelcast.jet.sql.impl.connector.keyvalue.KvProjector) PartitionedMapTable(com.hazelcast.sql.impl.schema.map.PartitionedMapTable)

Example 2 with UpsertTargetDescriptor

use of com.hazelcast.jet.sql.impl.inject.UpsertTargetDescriptor in project hazelcast by hazelcast.

the class InsertMapPhysicalRel method entriesFn.

public Function<ExpressionEvalContext, List<Entry<Object, Object>>> entriesFn() {
    PartitionedMapTable table = table();
    ExpressionValues values = this.values;
    return evalContext -> {
        KvProjector projector = KvProjector.supplier(table.paths(), table.types(), (UpsertTargetDescriptor) table.getKeyJetMetadata(), (UpsertTargetDescriptor) table.getValueJetMetadata(), true).get(evalContext.getSerializationService());
        return values.toValues(evalContext).map(projector::project).collect(toList());
    };
}
Also used : RelOptCluster(org.apache.calcite.plan.RelOptCluster) RelDataType(org.apache.calcite.rel.type.RelDataType) SqlKind(org.apache.calcite.sql.SqlKind) PlanNodeSchema(com.hazelcast.sql.impl.plan.node.PlanNodeSchema) AbstractRelNode(org.apache.calcite.rel.AbstractRelNode) ExpressionValues(com.hazelcast.jet.sql.impl.opt.ExpressionValues) PlanObjectKey(com.hazelcast.sql.impl.optimizer.PlanObjectKey) RelNode(org.apache.calcite.rel.RelNode) RelOptUtil(org.apache.calcite.plan.RelOptUtil) Function(java.util.function.Function) QueryParameterMetadata(com.hazelcast.sql.impl.QueryParameterMetadata) RelOptTable(org.apache.calcite.plan.RelOptTable) RelWriter(org.apache.calcite.rel.RelWriter) Vertex(com.hazelcast.jet.core.Vertex) HazelcastTable(com.hazelcast.jet.sql.impl.schema.HazelcastTable) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) ExpressionEvalContext(com.hazelcast.sql.impl.expression.ExpressionEvalContext) KvProjector(com.hazelcast.jet.sql.impl.connector.keyvalue.KvProjector) UpsertTargetDescriptor(com.hazelcast.jet.sql.impl.inject.UpsertTargetDescriptor) Entry(java.util.Map.Entry) PartitionedMapTable(com.hazelcast.sql.impl.schema.map.PartitionedMapTable) RelTraitSet(org.apache.calcite.plan.RelTraitSet) ExpressionValues(com.hazelcast.jet.sql.impl.opt.ExpressionValues) KvProjector(com.hazelcast.jet.sql.impl.connector.keyvalue.KvProjector) PartitionedMapTable(com.hazelcast.sql.impl.schema.map.PartitionedMapTable)

Example 3 with UpsertTargetDescriptor

use of com.hazelcast.jet.sql.impl.inject.UpsertTargetDescriptor in project hazelcast by hazelcast.

the class IMapSqlConnector method insertProcessor.

@Nonnull
@Override
public VertexWithInputConfig insertProcessor(@Nonnull DAG dag, @Nonnull Table table0) {
    PartitionedMapTable table = (PartitionedMapTable) table0;
    Vertex vertex = dag.newUniqueVertex(toString(table), new InsertProcessorSupplier(table.getMapName(), KvProjector.supplier(table.paths(), table.types(), (UpsertTargetDescriptor) table.getKeyJetMetadata(), (UpsertTargetDescriptor) table.getValueJetMetadata(), true))).localParallelism(1);
    return new VertexWithInputConfig(vertex, edge -> edge.distributed().allToOne(newUnsecureUuidString()));
}
Also used : Vertex(com.hazelcast.jet.core.Vertex) UpsertTargetDescriptor(com.hazelcast.jet.sql.impl.inject.UpsertTargetDescriptor) PartitionedMapTable(com.hazelcast.sql.impl.schema.map.PartitionedMapTable) Nonnull(javax.annotation.Nonnull)

Example 4 with UpsertTargetDescriptor

use of com.hazelcast.jet.sql.impl.inject.UpsertTargetDescriptor in project hazelcast by hazelcast.

the class IMapSqlConnector method sinkProcessor.

@Nonnull
@Override
public Vertex sinkProcessor(@Nonnull DAG dag, @Nonnull Table table0) {
    PartitionedMapTable table = (PartitionedMapTable) table0;
    Vertex vStart = dag.newUniqueVertex("Project(" + toString(table) + ")", KvProcessors.entryProjector(table.paths(), table.types(), (UpsertTargetDescriptor) table.getKeyJetMetadata(), (UpsertTargetDescriptor) table.getValueJetMetadata(), true));
    Vertex vEnd = dag.newUniqueVertex(toString(table), writeMapP(table.getMapName()));
    dag.edge(between(vStart, vEnd));
    return vStart;
}
Also used : Vertex(com.hazelcast.jet.core.Vertex) UpsertTargetDescriptor(com.hazelcast.jet.sql.impl.inject.UpsertTargetDescriptor) PartitionedMapTable(com.hazelcast.sql.impl.schema.map.PartitionedMapTable) Nonnull(javax.annotation.Nonnull)

Aggregations

Vertex (com.hazelcast.jet.core.Vertex)4 UpsertTargetDescriptor (com.hazelcast.jet.sql.impl.inject.UpsertTargetDescriptor)4 PartitionedMapTable (com.hazelcast.sql.impl.schema.map.PartitionedMapTable)4 KvProjector (com.hazelcast.jet.sql.impl.connector.keyvalue.KvProjector)2 ExpressionValues (com.hazelcast.jet.sql.impl.opt.ExpressionValues)2 HazelcastTable (com.hazelcast.jet.sql.impl.schema.HazelcastTable)2 QueryParameterMetadata (com.hazelcast.sql.impl.QueryParameterMetadata)2 ExpressionEvalContext (com.hazelcast.sql.impl.expression.ExpressionEvalContext)2 PlanObjectKey (com.hazelcast.sql.impl.optimizer.PlanObjectKey)2 PlanNodeSchema (com.hazelcast.sql.impl.plan.node.PlanNodeSchema)2 List (java.util.List)2 Entry (java.util.Map.Entry)2 Function (java.util.function.Function)2 Nonnull (javax.annotation.Nonnull)2 RelOptCluster (org.apache.calcite.plan.RelOptCluster)2 RelOptTable (org.apache.calcite.plan.RelOptTable)2 RelOptUtil (org.apache.calcite.plan.RelOptUtil)2 RelTraitSet (org.apache.calcite.plan.RelTraitSet)2 AbstractRelNode (org.apache.calcite.rel.AbstractRelNode)2 RelNode (org.apache.calcite.rel.RelNode)2