Search in sources :

Example 1 with TransformP

use of com.hazelcast.jet.impl.processor.TransformP 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 TransformP

use of com.hazelcast.jet.impl.processor.TransformP 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)

Example 3 with TransformP

use of com.hazelcast.jet.impl.processor.TransformP in project hazelcast by hazelcast.

the class MetricsTest method availableViaJmx.

@Test
public void availableViaJmx() throws Exception {
    int generatedItems = 1000;
    pipeline.readFrom(TestSources.itemStream(1_000)).withIngestionTimestamps().filter(l -> l.sequence() < generatedItems).map(t -> {
        Metrics.metric("total").increment();
        return t;
    }).writeTo(Sinks.noop());
    Job job = instance.getJet().newJob(pipeline, JOB_CONFIG_WITH_METRICS);
    JobMetricsChecker jobMetricsChecker = new JobMetricsChecker(job);
    assertTrueEventually(() -> jobMetricsChecker.assertSummedMetricValue("total", generatedItems));
    String instanceName = instance.getName();
    long sum = 0;
    int availableProcessors = config.getJetConfig().getCooperativeThreadCount();
    for (int i = 0; i < availableProcessors; i++) {
        JmxMetricsChecker jmxMetricsChecker = new JmxMetricsChecker(instanceName, job, "vertex=fused(filter, map)", "procType=TransformP", "proc=" + i, "user=true");
        long attributeValue = jmxMetricsChecker.getMetricValue("total");
        sum += attributeValue;
    }
    assertEquals(generatedItems, sum);
}
Also used : ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) AggregateOperations.counting(com.hazelcast.jet.aggregate.AggregateOperations.counting) Arrays(java.util.Arrays) QuickTest(com.hazelcast.test.annotation.QuickTest) RunWith(org.junit.runner.RunWith) Processor(com.hazelcast.jet.core.Processor) Processors(com.hazelcast.jet.core.processor.Processors) CompletableFuture(java.util.concurrent.CompletableFuture) ServiceFactories.nonSharedService(com.hazelcast.jet.pipeline.ServiceFactories.nonSharedService) HashSet(java.util.HashSet) TestProcessors(com.hazelcast.jet.core.TestProcessors) Arrays.asList(java.util.Arrays.asList) DAG(com.hazelcast.jet.core.DAG) Edge(com.hazelcast.jet.core.Edge) Job(com.hazelcast.jet.Job) Before(org.junit.Before) JobRepository(com.hazelcast.jet.impl.JobRepository) Config(com.hazelcast.config.Config) HazelcastInstance(com.hazelcast.core.HazelcastInstance) FunctionEx(com.hazelcast.function.FunctionEx) Pipeline(com.hazelcast.jet.pipeline.Pipeline) JetTestSupport(com.hazelcast.jet.core.JetTestSupport) EXACTLY_ONCE(com.hazelcast.jet.config.ProcessingGuarantee.EXACTLY_ONCE) JobConfig(com.hazelcast.jet.config.JobConfig) Sinks(com.hazelcast.jet.pipeline.Sinks) Assert.assertTrue(org.junit.Assert.assertTrue) ResettableSingletonTraverser(com.hazelcast.jet.core.ResettableSingletonTraverser) Test(org.junit.Test) Category(org.junit.experimental.categories.Category) SupplierEx(com.hazelcast.function.SupplierEx) NoOutputSourceP(com.hazelcast.jet.core.TestProcessors.NoOutputSourceP) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) Vertex(com.hazelcast.jet.core.Vertex) TestSources(com.hazelcast.jet.pipeline.test.TestSources) List(java.util.List) LongAccumulator(com.hazelcast.jet.accumulator.LongAccumulator) Assert.assertFalse(org.junit.Assert.assertFalse) TransformP(com.hazelcast.jet.impl.processor.TransformP) FunctionEx.identity(com.hazelcast.function.FunctionEx.identity) HazelcastParallelClassRunner(com.hazelcast.test.HazelcastParallelClassRunner) RUNNING(com.hazelcast.jet.core.JobStatus.RUNNING) Assert.assertEquals(org.junit.Assert.assertEquals) Edge.between(com.hazelcast.jet.core.Edge.between) SinkProcessors.writeListP(com.hazelcast.jet.core.processor.SinkProcessors.writeListP) Job(com.hazelcast.jet.Job) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

Processor (com.hazelcast.jet.core.Processor)3 TransformP (com.hazelcast.jet.impl.processor.TransformP)3 ResettableSingletonTraverser (com.hazelcast.jet.core.ResettableSingletonTraverser)2 KvRowProjector (com.hazelcast.jet.sql.impl.connector.keyvalue.KvRowProjector)2 ArrayList (java.util.ArrayList)2 Nonnull (javax.annotation.Nonnull)2 Config (com.hazelcast.config.Config)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 FunctionEx (com.hazelcast.function.FunctionEx)1 FunctionEx.identity (com.hazelcast.function.FunctionEx.identity)1 SupplierEx (com.hazelcast.function.SupplierEx)1 PartitionIdSet (com.hazelcast.internal.util.collection.PartitionIdSet)1 Job (com.hazelcast.jet.Job)1 LongAccumulator (com.hazelcast.jet.accumulator.LongAccumulator)1 AggregateOperations.counting (com.hazelcast.jet.aggregate.AggregateOperations.counting)1 JobConfig (com.hazelcast.jet.config.JobConfig)1 EXACTLY_ONCE (com.hazelcast.jet.config.ProcessingGuarantee.EXACTLY_ONCE)1 DAG (com.hazelcast.jet.core.DAG)1 Edge (com.hazelcast.jet.core.Edge)1 Edge.between (com.hazelcast.jet.core.Edge.between)1