Search in sources :

Example 1 with KvProjector

use of com.hazelcast.jet.sql.impl.connector.keyvalue.KvProjector 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 KvProjector

use of com.hazelcast.jet.sql.impl.connector.keyvalue.KvProjector 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)

Aggregations

Vertex (com.hazelcast.jet.core.Vertex)2 KvProjector (com.hazelcast.jet.sql.impl.connector.keyvalue.KvProjector)2 UpsertTargetDescriptor (com.hazelcast.jet.sql.impl.inject.UpsertTargetDescriptor)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 PartitionedMapTable (com.hazelcast.sql.impl.schema.map.PartitionedMapTable)2 List (java.util.List)2 Entry (java.util.Map.Entry)2 Function (java.util.function.Function)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 RelWriter (org.apache.calcite.rel.RelWriter)2