Skip to content

Instantly share code, notes, and snippets.

View tkaitchuck's full-sized avatar

Tom Kaitchuck tkaitchuck

  • Dell
  • United States
View GitHub Profile
@tkaitchuck
tkaitchuck / OnProcessingTime.java
Created November 8, 2019 01:14
Implementing TimestampsAndPeriodicWatermarksOperator
@Override 
public void onProcessingTime(long timestamp) throws Exception { 
// register next timer 
Watermark newWatermark = userFunction.getCurrentWatermark(); 
if (newWatermark != null && newWatermark.getTimestamp() > currentWatermark) { 
currentWatermark = newWatermark.getTimestamp(); 
// emit watermark 
output.emitWatermark(newWatermark); 
long now = getProcessingTimeService().getCurrentProcessingTime(); 
@tkaitchuck
tkaitchuck / CreateEventWriater.java
Created November 8, 2019 01:11
Create Event writer
        EventStreamWriter<EventType> writer = clientFactory.createEventWriter(stream, serializer, 
                EventWriterConfig.builder().automaticallyNoteTime(true).build()); 
@tkaitchuck
tkaitchuck / TxnCommit.java
Created November 8, 2019 01:09
Transaction Commit
Transaction<EventType> txn = writer.beginTxn(); 
//... write events to transaction. 
txn.commit(txnTimestamp); 
@tkaitchuck
tkaitchuck / WriterNoteTime.java
Created November 8, 2019 01:07
Writers supplying a timestamp
        EventStreamWriter<EventType> writer = clientFactory.createEventWriter(stream, serializer, 
                EventWriterConfig.builder().build()); 
        //... write events ... 
        writer.noteTime(currentTime); 
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); 
env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime);