Search in sources :

Example 1 with KvRowProjector

use of com.hazelcast.jet.sql.impl.connector.keyvalue.KvRowProjector in project hazelcast by hazelcast.

the class JoinByEquiJoinProcessorSupplier method get.

@Nonnull
@Override
public Collection<? extends Processor> get(int count) {
    List<Processor> processors = new ArrayList<>(count);
    for (int i = 0; i < count; i++) {
        PartitionIdSet partitions = this.partitions == null ? null : new PartitionIdSet(partitionCount, this.partitions);
        QueryPath[] rightPaths = rightRowProjectorSupplier.paths();
        KvRowProjector rightProjector = rightRowProjectorSupplier.get(evalContext, extractors);
        Processor processor = new TransformP<JetSqlRow, JetSqlRow>(joinFn(joinInfo, map, partitions, rightPaths, rightProjector, evalContext)) {

            @Override
            public boolean isCooperative() {
                return false;
            }
        };
        processors.add(processor);
    }
    return processors;
}
Also used : QueryPath(com.hazelcast.sql.impl.extract.QueryPath) KvRowProjector(com.hazelcast.jet.sql.impl.connector.keyvalue.KvRowProjector) Processor(com.hazelcast.jet.core.Processor) TransformP(com.hazelcast.jet.impl.processor.TransformP) PartitionIdSet(com.hazelcast.internal.util.collection.PartitionIdSet) ArrayList(java.util.ArrayList) Nonnull(javax.annotation.Nonnull)

Example 2 with KvRowProjector

use of com.hazelcast.jet.sql.impl.connector.keyvalue.KvRowProjector in project hazelcast by hazelcast.

the class RowProjectorProcessorSupplier method get.

@Nonnull
@Override
public Collection<? extends Processor> get(int count) {
    List<Processor> processors = new ArrayList<>(count);
    for (int i = 0; i < count; i++) {
        KvRowProjector projector = projectorSupplier.get(evalContext, extractors);
        Processor processor = new StreamKafkaP<>(properties, singletonList(topic), record -> projector.project(record.key(), record.value()), eventTimePolicy);
        processors.add(processor);
    }
    return processors;
}
Also used : KvRowProjector(com.hazelcast.jet.sql.impl.connector.keyvalue.KvRowProjector) Processor(com.hazelcast.jet.core.Processor) StreamKafkaP(com.hazelcast.jet.kafka.impl.StreamKafkaP) ArrayList(java.util.ArrayList) Nonnull(javax.annotation.Nonnull)

Example 3 with KvRowProjector

use of com.hazelcast.jet.sql.impl.connector.keyvalue.KvRowProjector in project hazelcast by hazelcast.

the class JoinByPrimitiveKeyProcessorSupplier method get.

@Nonnull
@Override
public Collection<? extends Processor> get(int count) {
    List<Processor> processors = new ArrayList<>(count);
    for (int i = 0; i < count; i++) {
        String mapName = this.mapName;
        KvRowProjector projector = rightRowProjectorSupplier.get(evalContext, extractors);
        Processor processor = new AsyncTransformUsingServiceOrderedP<>(ServiceFactories.nonSharedService(SecuredFunctions.iMapFn(mapName)), null, MAX_CONCURRENT_OPS, (IMap<Object, Object> map, JetSqlRow left) -> {
            Object key = left.get(leftEquiJoinIndex);
            if (key == null) {
                return inner ? null : completedFuture(null);
            }
            return map.getAsync(key).toCompletableFuture();
        }, (left, value) -> {
            JetSqlRow joined = join(left, left.get(leftEquiJoinIndex), value, projector, condition, evalContext);
            return joined != null ? singleton(joined) : inner ? null : singleton(left.extendedRow(projector.getColumnCount()));
        });
        processors.add(processor);
    }
    return processors;
}
Also used : IMap(com.hazelcast.map.IMap) KvRowProjector(com.hazelcast.jet.sql.impl.connector.keyvalue.KvRowProjector) Processor(com.hazelcast.jet.core.Processor) AsyncTransformUsingServiceOrderedP(com.hazelcast.jet.impl.processor.AsyncTransformUsingServiceOrderedP) ArrayList(java.util.ArrayList) JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow) Nonnull(javax.annotation.Nonnull)

Example 4 with KvRowProjector

use of com.hazelcast.jet.sql.impl.connector.keyvalue.KvRowProjector in project hazelcast by hazelcast.

the class RowProjectorProcessorSupplier method get.

@Nonnull
@Override
public Collection<? extends Processor> get(int count) {
    List<Processor> processors = new ArrayList<>(count);
    for (int i = 0; i < count; i++) {
        ResettableSingletonTraverser<JetSqlRow> traverser = new ResettableSingletonTraverser<>();
        KvRowProjector projector = projectorSupplier.get(evalContext, extractors);
        Processor processor = new TransformP<LazyMapEntry<Object, Object>, JetSqlRow>(entry -> {
            traverser.accept(projector.project(entry.getKeyData(), entry.getValueData()));
            return traverser;
        });
        processors.add(processor);
    }
    return processors;
}
Also used : ResettableSingletonTraverser(com.hazelcast.jet.core.ResettableSingletonTraverser) KvRowProjector(com.hazelcast.jet.sql.impl.connector.keyvalue.KvRowProjector) Processor(com.hazelcast.jet.core.Processor) TransformP(com.hazelcast.jet.impl.processor.TransformP) ArrayList(java.util.ArrayList) JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow) Nonnull(javax.annotation.Nonnull)

Aggregations

Processor (com.hazelcast.jet.core.Processor)4 KvRowProjector (com.hazelcast.jet.sql.impl.connector.keyvalue.KvRowProjector)4 ArrayList (java.util.ArrayList)4 Nonnull (javax.annotation.Nonnull)4 TransformP (com.hazelcast.jet.impl.processor.TransformP)2 JetSqlRow (com.hazelcast.sql.impl.row.JetSqlRow)2 PartitionIdSet (com.hazelcast.internal.util.collection.PartitionIdSet)1 ResettableSingletonTraverser (com.hazelcast.jet.core.ResettableSingletonTraverser)1 AsyncTransformUsingServiceOrderedP (com.hazelcast.jet.impl.processor.AsyncTransformUsingServiceOrderedP)1 StreamKafkaP (com.hazelcast.jet.kafka.impl.StreamKafkaP)1 IMap (com.hazelcast.map.IMap)1 QueryPath (com.hazelcast.sql.impl.extract.QueryPath)1