use of com.hazelcast.jet.core.Processor.Context in project hazelcast by hazelcast.
the class TestAbstractSqlConnector method fullScanReader.
@Nonnull
@Override
public Vertex fullScanReader(@Nonnull DAG dag, @Nonnull Table table_, @Nullable Expression<Boolean> predicate, @Nonnull List<Expression<?>> projection, @Nullable FunctionEx<ExpressionEvalContext, EventTimePolicy<JetSqlRow>> eventTimePolicyProvider) {
TestTable table = (TestTable) table_;
List<Object[]> rows = table.rows;
boolean streaming = table.streaming;
FunctionEx<Context, TestDataGenerator> createContextFn = ctx -> {
ExpressionEvalContext evalContext = ExpressionEvalContext.from(ctx);
EventTimePolicy<JetSqlRow> eventTimePolicy = eventTimePolicyProvider == null ? EventTimePolicy.noEventTime() : eventTimePolicyProvider.apply(evalContext);
return new TestDataGenerator(rows, predicate, projection, evalContext, eventTimePolicy, streaming);
};
ProcessorMetaSupplier pms = createProcessorSupplier(createContextFn);
return dag.newUniqueVertex(table.toString(), pms);
}
use of com.hazelcast.jet.core.Processor.Context in project hazelcast by hazelcast.
the class SessionWindowP_failoverTest method init.
private void init(ProcessingGuarantee guarantee) throws Exception {
AggregateOperation1<Object, LongAccumulator, Long> aggrOp = counting();
p = new SessionWindowP<>(5000, 0L, singletonList((ToLongFunctionEx<Entry<?, Long>>) Entry::getValue), singletonList(entryKey()), aggrOp, KeyedWindowResult::new);
Outbox outbox = new TestOutbox(128);
Context context = new TestProcessorContext().setProcessingGuarantee(guarantee);
p.init(outbox, context);
}
use of com.hazelcast.jet.core.Processor.Context in project hazelcast by hazelcast.
the class SlidingWindowP_failoverTest method init.
private void init(ProcessingGuarantee guarantee) throws Exception {
SlidingWindowPolicy wDef = SlidingWindowPolicy.tumblingWinPolicy(1);
AggregateOperation1<Object, LongAccumulator, Long> aggrOp = counting();
p = new SlidingWindowP<>(singletonList(entryKey()), singletonList((ToLongFunctionEx<Entry<?, Long>>) Entry::getValue), wDef, 0L, aggrOp, KeyedWindowResult::new, true);
Outbox outbox = new TestOutbox(128);
Context context = new TestProcessorContext().setProcessingGuarantee(guarantee);
p.init(outbox, context);
}
use of com.hazelcast.jet.core.Processor.Context in project hazelcast by hazelcast.
the class StreamSourceTest method test.
private void test(long idleTimeout) {
StreamSource<Object> source = SourceBuilder.stream("src", Context::globalProcessorIndex).distributed(1).fillBufferFn((index, buf) -> {
// idle, there should be no output.
if (index == 0) {
buf.add("item");
Thread.sleep(10);
}
}).build();
if (idleTimeout != DEFAULT_IDLE_TIMEOUT) {
source = source.setPartitionIdleTimeout(idleTimeout);
}
Pipeline p = Pipeline.create();
p.readFrom(source).withTimestamps(o -> System.currentTimeMillis(), 0).window(WindowDefinition.tumbling(100)).aggregate(counting()).writeTo(sink);
Job job = allHazelcastInstances()[0].getJet().newJob(p);
if (idleTimeout > 10_000) {
assertTrueAllTheTime(() -> assertEquals("unexpected sink size", 0, sinkList.size()), 5);
} else if (idleTimeout < 1000) {
assertTrueEventually(() -> assertTrue("sink empty", sinkList.size() > 0));
} else {
fail("test not designed for idleTimeout=" + idleTimeout);
}
cancelAndJoin(job);
}
use of com.hazelcast.jet.core.Processor.Context in project hazelcast-jet by hazelcast.
the class SessionWindowP_failoverTest method init.
private void init(ProcessingGuarantee guarantee) {
AggregateOperation1<Object, LongAccumulator, Long> aggrOp = counting();
p = new SessionWindowP<>(5000, singletonList((DistributedToLongFunction<Entry<?, Long>>) Entry::getValue), singletonList(entryKey()), aggrOp, WindowResult::new);
Outbox outbox = new TestOutbox(128);
Context context = new TestProcessorContext().setProcessingGuarantee(guarantee);
p.init(outbox, context);
}
Aggregations