Tabnine Logo
SourceFunction$SourceContext.collect
Code IndexAdd Tabnine to your IDE (free)

How to use
collect
method
in
org.apache.flink.streaming.api.functions.source.SourceFunction$SourceContext

Best Java code snippets using org.apache.flink.streaming.api.functions.source.SourceFunction$SourceContext.collect (Showing top 20 results out of 468)

origin: apache/flink

@Override
public void run(SourceContext<T> ctx) throws Exception {
  while (isRunning && iterator.hasNext()) {
    ctx.collect(iterator.next());
  }
}
origin: apache/flink

@Override
public void run(SourceContext<Object> ctx) throws Exception {
  try {
    while (isRunning && this.fun.hasNext()) {
      ctx.collect(this.fun.next());
    }
  } catch (PyException pe) {
    throw AbstractPythonUDF.createAndLogException(pe, LOG);
  }
}
origin: apache/flink

@Override
public void run(SourceContext<Long> ctx) throws Exception {
  while (isRunning && !this.valuesToEmit.isEmpty()) {
    synchronized (ctx.getCheckpointLock()) {
      ctx.collect(this.valuesToEmit.poll());
    }
  }
}
origin: apache/flink

@Override
public void run(SourceContext<Integer> ctx) throws Exception {
  while (!cancel) {
    synchronized (ctx.getCheckpointLock()) {
      ctx.collect(1);
    }
    Thread.sleep(100L);
  }
}
origin: apache/flink

  @Override
  public void emitEvent(SourceFunction.SourceContext<Tuple2<Long, IntType>> ctx, int eventSequenceNo) {
    ctx.collect(new Tuple2<>((long) eventSequenceNo, new IntType(eventSequenceNo)));
  }
}
origin: apache/flink

@Override
public void run(SourceContext<Integer> collector) throws Exception {
  while (counter < 8200) {
    collector.collect(getTrainingData());
  }
}
origin: apache/flink

@Override
public void run(SourceContext<Tuple2<Integer, Integer>> ctx) throws Exception {
  int cnt = 0;
  int partition = getRuntimeContext().getIndexOfThisSubtask();
  while (running && cnt < numElements) {
    ctx.collect(new Tuple2<>(partition, cnt));
    cnt++;
  }
}
origin: apache/flink

@Override
public void run(SourceContext<Tuple2<String, Integer>> out) throws Exception {
  Random random = new Random(42);
  while (running) {
    Tuple2<String, Integer> tuple = new Tuple2<String, Integer>("Tuple " + (random.nextInt(numKeys)), 1);
    out.collect(tuple);
  }
}
origin: apache/flink

@Override
public void run(SourceContext<Tuple3<String, String, Integer>> ctx) throws Exception {
  ctx.collect(Tuple3.of("a", "x", 0));
  ctx.collect(Tuple3.of("a", "y", 1));
  ctx.collect(Tuple3.of("a", "z", 2));
  ctx.collect(Tuple3.of("b", "u", 3));
  ctx.collect(Tuple3.of("b", "w", 5));
  ctx.collect(Tuple3.of("a", "i", 6));
  ctx.collect(Tuple3.of("a", "j", 7));
  ctx.collect(Tuple3.of("a", "k", 8));
  // source is finite, so it will have an implicit MAX watermark when it finishes
}
origin: apache/flink

@Override
public void run(SourceContext<Tuple3<String, String, Integer>> ctx) throws Exception {
  ctx.collect(Tuple3.of("a", "u", 0));
  ctx.collect(Tuple3.of("a", "w", 1));
  ctx.collect(Tuple3.of("b", "i", 3));
  ctx.collect(Tuple3.of("b", "k", 5));
  ctx.collect(Tuple3.of("a", "x", 6));
  ctx.collect(Tuple3.of("a", "z", 8));
  // source is finite, so it will have an implicit MAX watermark when it finishes
}
origin: apache/flink

@Override
public void run(SourceContext<Tuple3<String, String, Integer>> ctx) throws Exception {
  ctx.collect(Tuple3.of("a", "x", 0));
  ctx.collect(Tuple3.of("a", "y", 1));
  ctx.collect(Tuple3.of("a", "z", 2));
  ctx.collect(Tuple3.of("b", "u", 3));
  ctx.collect(Tuple3.of("b", "w", 5));
  ctx.collect(Tuple3.of("a", "i", 6));
  ctx.collect(Tuple3.of("a", "j", 7));
  ctx.collect(Tuple3.of("a", "k", 8));
  // source is finite, so it will have an implicit MAX watermark when it finishes
}
origin: apache/flink

@Override
public void run(SourceContext<Tuple2<String, Integer>> ctx) throws Exception {
  ctx.collect(Tuple2.of("a", 0));
  ctx.collect(Tuple2.of("a", 1));
  ctx.collect(Tuple2.of("b", 3));
  ctx.collect(Tuple2.of("c", 6));
  ctx.collect(Tuple2.of("c", 7));
  ctx.collect(Tuple2.of("c", 8));
  // source is finite, so it will have an implicit MAX watermark when it finishes
}
origin: apache/flink

@Override
public void run(SourceContext<String> ctx) throws Exception {
  if (!openCalled) {
    Assert.fail("Open was not called before run.");
  }
  for (int i = 0; i < 10; i++) {
    ctx.collect("Hello" + i);
  }
}
origin: apache/flink

@Override
public void run(SourceContext<Tuple2<Integer, Long>> ctx) throws Exception {
  Object lock = ctx.getCheckpointLock();
  while (count < NUM_INPUT){
    synchronized (lock){
      for (int i = 0; i < PARALLELISM; i++) {
        ctx.collect(Tuple2.of(i, count + 1));
      }
      count++;
    }
  }
}
origin: apache/flink

@Override
public void run(SourceContext<String> ctx) throws Exception {
  while (running && !CheckpointBlockingFunction.afterMessWithZooKeeper.get()) {
    ctx.collect("hello");
    // don't overdo it ... ;-)
    Thread.sleep(50);
  }
}
origin: apache/flink

@Override
public void run(SourceContext<Integer> ctx) throws Exception {
  Thread.sleep(15);
  while (counter < 50) {
    ctx.collect(getNewData());
  }
}
origin: apache/flink

@Override
public void run(SourceContext<Tuple2<Long, String>> ctx) throws InterruptedException {
  int cnt = getRuntimeContext().getIndexOfThisSubtask() * elementsPerPartition;
  int limit = cnt + elementsPerPartition;
  while (running && cnt < limit) {
    ctx.collect(new Tuple2<>(1000L + cnt, "kafka-" + cnt));
    cnt++;
    // we delay data generation a bit so that we are sure that some checkpoints are
    // triggered (for FLINK-3156)
    Thread.sleep(50);
  }
}
origin: apache/flink

@Override
public void run(SourceContext<Tuple2<Integer, Integer>> out) throws Exception {
  Random random = new Random(42);
  while (--remainingEvents >= 0) {
    synchronized (out.getCheckpointLock()) {
      out.collect(new Tuple2<>(random.nextInt(numKeys), 1));
    }
  }
}
origin: apache/flink

@Override
public void run(SourceContext<String> ctx) throws Exception {
  while (isRunning) {
    if (readyToFail && getRuntimeContext().getIndexOfThisSubtask() == 0) {
      throw new Exception("Artificial failure.");
    }
    synchronized (ctx.getCheckpointLock()) {
      ctx.collect("test-element");
    }
    Thread.sleep(1);
  }
}
origin: apache/flink

@Override
public void run(SourceContext<Tuple3<Integer, Long, String>> ctx) throws Exception {
  while (ms < durationMs) {
    synchronized (ctx.getCheckpointLock()) {
      for (int i = 0; i < numKeys; i++) {
        ctx.collect(Tuple3.of(i, ms, "Some payload..."));
      }
      ms += idlenessMs;
    }
    Thread.sleep(idlenessMs);
  }
}
org.apache.flink.streaming.api.functions.sourceSourceFunction$SourceContextcollect

Javadoc

Emits one element from the source, without attaching a timestamp. In most cases, this is the default way of emitting elements.

The timestamp that the element will get assigned depends on the time characteristic of the streaming program:

  • On TimeCharacteristic#ProcessingTime, the element has no timestamp.
  • On TimeCharacteristic#IngestionTime, the element gets the system's current time as the timestamp.
  • On TimeCharacteristic#EventTime, the element will have no timestamp initially. It needs to get a timestamp (via a TimestampAssigner) before any time-dependent operation (like time windows).

Popular methods of SourceFunction$SourceContext

  • getCheckpointLock
    Returns the checkpoint lock. Please refer to the class-level comment in SourceFunction for details a
  • emitWatermark
    Emits the given Watermark. A Watermark of value t declares that no elements with a timestamp t' late
  • collectWithTimestamp
    Emits one element from the source, and attaches the given timestamp. This method is relevant for pro
  • close
    This method is called by the system to shut down the context.
  • markAsTemporarilyIdle
    Marks the source to be temporarily idle. This tells the system that this source will temporarily sto

Popular in Java

  • Reading from database using SQL prepared statement
  • putExtra (Intent)
  • notifyDataSetChanged (ArrayAdapter)
  • onRequestPermissionsResult (Fragment)
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now