Skip to content

Instantly share code, notes, and snippets.

View alpinegizmo's full-sized avatar

David Anderson alpinegizmo

View GitHub Profile
@alpinegizmo
alpinegizmo / CEPPatternAB.java
Created December 17, 2021 09:31
Matching a simple pattern using Flink's CEP library
/*
* Copyright 2021 Ververica GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
import org.apache.flink.cep.CEP;
import org.apache.flink.cep.PatternStream;
import org.apache.flink.cep.functions.PatternProcessFunction;
import org.apache.flink.cep.pattern.Pattern;
import org.apache.flink.cep.pattern.conditions.IterativeCondition;
import org.apache.flink.streaming.api.TimeCharacteristic;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.util.Collector;
@alpinegizmo
alpinegizmo / Bootstrap.java
Last active November 23, 2020 10:04
Create a Flink savepoint by bootstrapping its state
package com.ververica.flinktraining.examples.datastream_java.state;
import org.apache.flink.api.common.state.ValueState;
import org.apache.flink.api.common.state.ValueStateDescriptor;
import org.apache.flink.api.common.typeinfo.Types;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.runtime.state.filesystem.FsStateBackend;
import org.apache.flink.state.api.BootstrapTransformation;
import org.apache.flink.state.api.OperatorTransformation;
@alpinegizmo
alpinegizmo / PerKeyTriggeringSimple.java
Last active February 13, 2020 14:15
Simpler per-key triggering
/*
* Copyright 2019 Ververica GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@alpinegizmo
alpinegizmo / PerKeyTriggering.java
Last active January 28, 2020 20:47
Event-time windows that are triggered when no more events have been added for some specified duration, rather than by watermarks. This can be used in situations where per-key watermarking would be desirable..
/*
* Copyright 2020 Ververica GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
package com.dataartisans.flinktraining.examples.datastream_java.basics;
import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.api.common.state.ValueState;
import org.apache.flink.api.common.state.ValueStateDescriptor;
import org.apache.flink.api.java.io.TextInputFormat;
import org.apache.flink.api.java.tuple.Tuple3;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.core.fs.Path;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
@alpinegizmo
alpinegizmo / UserSessions.java
Last active July 10, 2018 12:29
Flink job to mark clickstream events with user-ids, connecting pre-registration sessions with later, authenticated sessions.
/*
* Copyright 2018 data Artisans GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@alpinegizmo
alpinegizmo / dvd-dump.sql
Created January 17, 2017 11:23
dvdrental postgres database dump
This file has been truncated, but you can view the full file.
--
-- PostgreSQL database cluster dump
--
SET default_transaction_read_only = off;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
--
#
# a smoke test to check basic programming skills
#
# Task:
# - print out the numbers 1 to 100
# - output "foo" for every number divisible by 3
# - output "bar" for every number divisible by 5
# - output "foobar" for every number divisible by 3 and 5
#